Lines Matching refs:ucounts
11 struct ucounts init_ucounts = {
130 static struct ucounts *find_ucounts(struct user_namespace *ns, kuid_t uid, struct hlist_head *hashe… in find_ucounts()
132 struct ucounts *ucounts; in find_ucounts() local
134 hlist_for_each_entry(ucounts, hashent, node) { in find_ucounts()
135 if (uid_eq(ucounts->uid, uid) && (ucounts->ns == ns)) in find_ucounts()
136 return ucounts; in find_ucounts()
141 static void hlist_add_ucounts(struct ucounts *ucounts) in hlist_add_ucounts() argument
143 struct hlist_head *hashent = ucounts_hashentry(ucounts->ns, ucounts->uid); in hlist_add_ucounts()
145 hlist_add_head(&ucounts->node, hashent); in hlist_add_ucounts()
149 static inline bool get_ucounts_or_wrap(struct ucounts *ucounts) in get_ucounts_or_wrap() argument
152 return !atomic_add_negative(1, &ucounts->count); in get_ucounts_or_wrap()
155 struct ucounts *get_ucounts(struct ucounts *ucounts) in get_ucounts() argument
157 if (!get_ucounts_or_wrap(ucounts)) { in get_ucounts()
158 put_ucounts(ucounts); in get_ucounts()
159 ucounts = NULL; in get_ucounts()
161 return ucounts; in get_ucounts()
164 struct ucounts *alloc_ucounts(struct user_namespace *ns, kuid_t uid) in alloc_ucounts()
167 struct ucounts *ucounts, *new; in alloc_ucounts() local
171 ucounts = find_ucounts(ns, uid, hashent); in alloc_ucounts()
172 if (!ucounts) { in alloc_ucounts()
184 ucounts = find_ucounts(ns, uid, hashent); in alloc_ucounts()
185 if (ucounts) { in alloc_ucounts()
194 wrapped = !get_ucounts_or_wrap(ucounts); in alloc_ucounts()
197 put_ucounts(ucounts); in alloc_ucounts()
200 return ucounts; in alloc_ucounts()
203 void put_ucounts(struct ucounts *ucounts) in put_ucounts() argument
207 if (atomic_dec_and_lock_irqsave(&ucounts->count, &ucounts_lock, flags)) { in put_ucounts()
208 hlist_del_init(&ucounts->node); in put_ucounts()
210 put_user_ns(ucounts->ns); in put_ucounts()
211 kfree(ucounts); in put_ucounts()
229 struct ucounts *inc_ucount(struct user_namespace *ns, kuid_t uid, in inc_ucount()
232 struct ucounts *ucounts, *iter, *bad; in inc_ucount() local
234 ucounts = alloc_ucounts(ns, uid); in inc_ucount()
235 for (iter = ucounts; iter; iter = tns->ucounts) { in inc_ucount()
242 return ucounts; in inc_ucount()
245 for (iter = ucounts; iter != bad; iter = iter->ns->ucounts) in inc_ucount()
248 put_ucounts(ucounts); in inc_ucount()
252 void dec_ucount(struct ucounts *ucounts, enum ucount_type type) in dec_ucount() argument
254 struct ucounts *iter; in dec_ucount()
255 for (iter = ucounts; iter; iter = iter->ns->ucounts) { in dec_ucount()
259 put_ucounts(ucounts); in dec_ucount()
262 long inc_rlimit_ucounts(struct ucounts *ucounts, enum rlimit_type type, long v) in inc_rlimit_ucounts() argument
264 struct ucounts *iter; in inc_rlimit_ucounts()
268 for (iter = ucounts; iter; iter = iter->ns->ucounts) { in inc_rlimit_ucounts()
272 else if (iter == ucounts) in inc_rlimit_ucounts()
279 bool dec_rlimit_ucounts(struct ucounts *ucounts, enum rlimit_type type, long v) in dec_rlimit_ucounts() argument
281 struct ucounts *iter; in dec_rlimit_ucounts()
283 for (iter = ucounts; iter; iter = iter->ns->ucounts) { in dec_rlimit_ucounts()
286 if (iter == ucounts) in dec_rlimit_ucounts()
292 static void do_dec_rlimit_put_ucounts(struct ucounts *ucounts, in do_dec_rlimit_put_ucounts() argument
293 struct ucounts *last, enum rlimit_type type) in do_dec_rlimit_put_ucounts()
295 struct ucounts *iter, *next; in do_dec_rlimit_put_ucounts()
296 for (iter = ucounts; iter != last; iter = next) { in do_dec_rlimit_put_ucounts()
299 next = iter->ns->ucounts; in do_dec_rlimit_put_ucounts()
305 void dec_rlimit_put_ucounts(struct ucounts *ucounts, enum rlimit_type type) in dec_rlimit_put_ucounts() argument
307 do_dec_rlimit_put_ucounts(ucounts, NULL, type); in dec_rlimit_put_ucounts()
310 long inc_rlimit_get_ucounts(struct ucounts *ucounts, enum rlimit_type type) in inc_rlimit_get_ucounts() argument
313 struct ucounts *iter; in inc_rlimit_get_ucounts()
317 for (iter = ucounts; iter; iter = iter->ns->ucounts) { in inc_rlimit_get_ucounts()
321 if (iter == ucounts) in inc_rlimit_get_ucounts()
338 do_dec_rlimit_put_ucounts(ucounts, iter, type); in inc_rlimit_get_ucounts()
342 bool is_rlimit_overlimit(struct ucounts *ucounts, enum rlimit_type type, unsigned long rlimit) in is_rlimit_overlimit() argument
344 struct ucounts *iter; in is_rlimit_overlimit()
348 for (iter = ucounts; iter; iter = iter->ns->ucounts) { in is_rlimit_overlimit()