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 struct ucounts *get_ucounts(struct ucounts *ucounts) in get_ucounts() argument
155 if (ucounts && atomic_add_negative(1, &ucounts->count)) { in get_ucounts()
156 put_ucounts(ucounts); in get_ucounts()
157 ucounts = NULL; in get_ucounts()
159 return ucounts; in get_ucounts()
162 struct ucounts *alloc_ucounts(struct user_namespace *ns, kuid_t uid) in alloc_ucounts()
165 struct ucounts *ucounts, *new; in alloc_ucounts() local
169 ucounts = find_ucounts(ns, uid, hashent); in alloc_ucounts()
170 if (!ucounts) { in alloc_ucounts()
182 ucounts = find_ucounts(ns, uid, hashent); in alloc_ucounts()
183 if (ucounts) { in alloc_ucounts()
191 overflow = atomic_add_negative(1, &ucounts->count); in alloc_ucounts()
194 put_ucounts(ucounts); in alloc_ucounts()
197 return ucounts; in alloc_ucounts()
200 void put_ucounts(struct ucounts *ucounts) in put_ucounts() argument
204 if (atomic_dec_and_lock_irqsave(&ucounts->count, &ucounts_lock, flags)) { in put_ucounts()
205 hlist_del_init(&ucounts->node); in put_ucounts()
207 kfree(ucounts); in put_ucounts()
225 struct ucounts *inc_ucount(struct user_namespace *ns, kuid_t uid, in inc_ucount()
228 struct ucounts *ucounts, *iter, *bad; in inc_ucount() local
230 ucounts = alloc_ucounts(ns, uid); in inc_ucount()
231 for (iter = ucounts; iter; iter = tns->ucounts) { in inc_ucount()
238 return ucounts; in inc_ucount()
241 for (iter = ucounts; iter != bad; iter = iter->ns->ucounts) in inc_ucount()
244 put_ucounts(ucounts); in inc_ucount()
248 void dec_ucount(struct ucounts *ucounts, enum ucount_type type) in dec_ucount() argument
250 struct ucounts *iter; in dec_ucount()
251 for (iter = ucounts; iter; iter = iter->ns->ucounts) { in dec_ucount()
255 put_ucounts(ucounts); in dec_ucount()
258 long inc_rlimit_ucounts(struct ucounts *ucounts, enum ucount_type type, long v) in inc_rlimit_ucounts() argument
260 struct ucounts *iter; in inc_rlimit_ucounts()
263 for (iter = ucounts; iter; iter = iter->ns->ucounts) { in inc_rlimit_ucounts()
268 else if (iter == ucounts) in inc_rlimit_ucounts()
274 bool dec_rlimit_ucounts(struct ucounts *ucounts, enum ucount_type type, long v) in dec_rlimit_ucounts() argument
276 struct ucounts *iter; in dec_rlimit_ucounts()
278 for (iter = ucounts; iter; iter = iter->ns->ucounts) { in dec_rlimit_ucounts()
281 if (iter == ucounts) in dec_rlimit_ucounts()
287 static void do_dec_rlimit_put_ucounts(struct ucounts *ucounts, in do_dec_rlimit_put_ucounts() argument
288 struct ucounts *last, enum ucount_type type) in do_dec_rlimit_put_ucounts()
290 struct ucounts *iter, *next; in do_dec_rlimit_put_ucounts()
291 for (iter = ucounts; iter != last; iter = next) { in do_dec_rlimit_put_ucounts()
294 next = iter->ns->ucounts; in do_dec_rlimit_put_ucounts()
300 void dec_rlimit_put_ucounts(struct ucounts *ucounts, enum ucount_type type) in dec_rlimit_put_ucounts() argument
302 do_dec_rlimit_put_ucounts(ucounts, NULL, type); in dec_rlimit_put_ucounts()
305 long inc_rlimit_get_ucounts(struct ucounts *ucounts, enum ucount_type type) in inc_rlimit_get_ucounts() argument
308 struct ucounts *iter; in inc_rlimit_get_ucounts()
311 for (iter = ucounts; iter; iter = iter->ns->ucounts) { in inc_rlimit_get_ucounts()
316 if (iter == ucounts) in inc_rlimit_get_ucounts()
332 do_dec_rlimit_put_ucounts(ucounts, iter, type); in inc_rlimit_get_ucounts()
336 bool is_ucounts_overlimit(struct ucounts *ucounts, enum ucount_type type, unsigned long max) in is_ucounts_overlimit() argument
338 struct ucounts *iter; in is_ucounts_overlimit()
339 if (get_ucounts_value(ucounts, type) > max) in is_ucounts_overlimit()
341 for (iter = ucounts; iter; iter = iter->ns->ucounts) { in is_ucounts_overlimit()