Lines Matching refs:ucounts

11 struct ucounts init_ucounts = {
134 static struct ucounts *find_ucounts(struct user_namespace *ns, kuid_t uid, struct hlist_head *hashe… in find_ucounts()
136 struct ucounts *ucounts; in find_ucounts() local
138 hlist_for_each_entry(ucounts, hashent, node) { in find_ucounts()
139 if (uid_eq(ucounts->uid, uid) && (ucounts->ns == ns)) in find_ucounts()
140 return ucounts; in find_ucounts()
145 static void hlist_add_ucounts(struct ucounts *ucounts) in hlist_add_ucounts() argument
147 struct hlist_head *hashent = ucounts_hashentry(ucounts->ns, ucounts->uid); in hlist_add_ucounts()
149 hlist_add_head(&ucounts->node, hashent); in hlist_add_ucounts()
153 static inline bool get_ucounts_or_wrap(struct ucounts *ucounts) in get_ucounts_or_wrap() argument
156 return !atomic_add_negative(1, &ucounts->count); in get_ucounts_or_wrap()
159 struct ucounts *get_ucounts(struct ucounts *ucounts) in get_ucounts() argument
161 if (!get_ucounts_or_wrap(ucounts)) { in get_ucounts()
162 put_ucounts(ucounts); in get_ucounts()
163 ucounts = NULL; in get_ucounts()
165 return ucounts; in get_ucounts()
168 struct ucounts *alloc_ucounts(struct user_namespace *ns, kuid_t uid) in alloc_ucounts()
171 struct ucounts *ucounts, *new; in alloc_ucounts() local
175 ucounts = find_ucounts(ns, uid, hashent); in alloc_ucounts()
176 if (!ucounts) { in alloc_ucounts()
188 ucounts = find_ucounts(ns, uid, hashent); in alloc_ucounts()
189 if (ucounts) { in alloc_ucounts()
197 wrapped = !get_ucounts_or_wrap(ucounts); in alloc_ucounts()
200 put_ucounts(ucounts); in alloc_ucounts()
203 return ucounts; in alloc_ucounts()
206 void put_ucounts(struct ucounts *ucounts) in put_ucounts() argument
210 if (atomic_dec_and_lock_irqsave(&ucounts->count, &ucounts_lock, flags)) { in put_ucounts()
211 hlist_del_init(&ucounts->node); in put_ucounts()
213 kfree(ucounts); in put_ucounts()
231 struct ucounts *inc_ucount(struct user_namespace *ns, kuid_t uid, in inc_ucount()
234 struct ucounts *ucounts, *iter, *bad; in inc_ucount() local
236 ucounts = alloc_ucounts(ns, uid); in inc_ucount()
237 for (iter = ucounts; iter; iter = tns->ucounts) { in inc_ucount()
244 return ucounts; in inc_ucount()
247 for (iter = ucounts; iter != bad; iter = iter->ns->ucounts) in inc_ucount()
250 put_ucounts(ucounts); in inc_ucount()
254 void dec_ucount(struct ucounts *ucounts, enum ucount_type type) in dec_ucount() argument
256 struct ucounts *iter; in dec_ucount()
257 for (iter = ucounts; iter; iter = iter->ns->ucounts) { in dec_ucount()
261 put_ucounts(ucounts); in dec_ucount()
264 long inc_rlimit_ucounts(struct ucounts *ucounts, enum ucount_type type, long v) in inc_rlimit_ucounts() argument
266 struct ucounts *iter; in inc_rlimit_ucounts()
270 for (iter = ucounts; iter; iter = iter->ns->ucounts) { in inc_rlimit_ucounts()
274 else if (iter == ucounts) in inc_rlimit_ucounts()
281 bool dec_rlimit_ucounts(struct ucounts *ucounts, enum ucount_type type, long v) in dec_rlimit_ucounts() argument
283 struct ucounts *iter; in dec_rlimit_ucounts()
285 for (iter = ucounts; iter; iter = iter->ns->ucounts) { in dec_rlimit_ucounts()
288 if (iter == ucounts) in dec_rlimit_ucounts()
294 static void do_dec_rlimit_put_ucounts(struct ucounts *ucounts, in do_dec_rlimit_put_ucounts() argument
295 struct ucounts *last, enum ucount_type type) in do_dec_rlimit_put_ucounts()
297 struct ucounts *iter, *next; in do_dec_rlimit_put_ucounts()
298 for (iter = ucounts; iter != last; iter = next) { in do_dec_rlimit_put_ucounts()
301 next = iter->ns->ucounts; in do_dec_rlimit_put_ucounts()
307 void dec_rlimit_put_ucounts(struct ucounts *ucounts, enum ucount_type type) in dec_rlimit_put_ucounts() argument
309 do_dec_rlimit_put_ucounts(ucounts, NULL, type); in dec_rlimit_put_ucounts()
312 long inc_rlimit_get_ucounts(struct ucounts *ucounts, enum ucount_type type) in inc_rlimit_get_ucounts() argument
315 struct ucounts *iter; in inc_rlimit_get_ucounts()
319 for (iter = ucounts; iter; iter = iter->ns->ucounts) { in inc_rlimit_get_ucounts()
323 if (iter == ucounts) in inc_rlimit_get_ucounts()
340 do_dec_rlimit_put_ucounts(ucounts, iter, type); in inc_rlimit_get_ucounts()
344 bool is_ucounts_overlimit(struct ucounts *ucounts, enum ucount_type type, unsigned long rlimit) in is_ucounts_overlimit() argument
346 struct ucounts *iter; in is_ucounts_overlimit()
350 for (iter = ucounts; iter; iter = iter->ns->ucounts) { in is_ucounts_overlimit()