Lines Matching refs:ucounts
11 struct ucounts init_ucounts = {
131 static struct ucounts *find_ucounts(struct user_namespace *ns, kuid_t uid, struct hlist_head *hashe… in find_ucounts()
133 struct ucounts *ucounts; in find_ucounts() local
135 hlist_for_each_entry(ucounts, hashent, node) { in find_ucounts()
136 if (uid_eq(ucounts->uid, uid) && (ucounts->ns == ns)) in find_ucounts()
137 return ucounts; in find_ucounts()
142 static void hlist_add_ucounts(struct ucounts *ucounts) in hlist_add_ucounts() argument
144 struct hlist_head *hashent = ucounts_hashentry(ucounts->ns, ucounts->uid); in hlist_add_ucounts()
146 hlist_add_head(&ucounts->node, hashent); in hlist_add_ucounts()
150 static inline bool get_ucounts_or_wrap(struct ucounts *ucounts) in get_ucounts_or_wrap() argument
153 return !atomic_add_negative(1, &ucounts->count); in get_ucounts_or_wrap()
156 struct ucounts *get_ucounts(struct ucounts *ucounts) in get_ucounts() argument
158 if (!get_ucounts_or_wrap(ucounts)) { in get_ucounts()
159 put_ucounts(ucounts); in get_ucounts()
160 ucounts = NULL; in get_ucounts()
162 return ucounts; in get_ucounts()
165 struct ucounts *alloc_ucounts(struct user_namespace *ns, kuid_t uid) in alloc_ucounts()
168 struct ucounts *ucounts, *new; in alloc_ucounts() local
172 ucounts = find_ucounts(ns, uid, hashent); in alloc_ucounts()
173 if (!ucounts) { in alloc_ucounts()
185 ucounts = find_ucounts(ns, uid, hashent); in alloc_ucounts()
186 if (ucounts) { in alloc_ucounts()
195 wrapped = !get_ucounts_or_wrap(ucounts); in alloc_ucounts()
198 put_ucounts(ucounts); in alloc_ucounts()
201 return ucounts; in alloc_ucounts()
204 void put_ucounts(struct ucounts *ucounts) in put_ucounts() argument
208 if (atomic_dec_and_lock_irqsave(&ucounts->count, &ucounts_lock, flags)) { in put_ucounts()
209 hlist_del_init(&ucounts->node); in put_ucounts()
211 put_user_ns(ucounts->ns); in put_ucounts()
212 kfree(ucounts); in put_ucounts()
230 struct ucounts *inc_ucount(struct user_namespace *ns, kuid_t uid, in inc_ucount()
233 struct ucounts *ucounts, *iter, *bad; in inc_ucount() local
235 ucounts = alloc_ucounts(ns, uid); in inc_ucount()
236 for (iter = ucounts; iter; iter = tns->ucounts) { in inc_ucount()
243 return ucounts; in inc_ucount()
246 for (iter = ucounts; iter != bad; iter = iter->ns->ucounts) in inc_ucount()
249 put_ucounts(ucounts); in inc_ucount()
253 void dec_ucount(struct ucounts *ucounts, enum ucount_type type) in dec_ucount() argument
255 struct ucounts *iter; in dec_ucount()
256 for (iter = ucounts; iter; iter = iter->ns->ucounts) { in dec_ucount()
260 put_ucounts(ucounts); in dec_ucount()
263 long inc_rlimit_ucounts(struct ucounts *ucounts, enum rlimit_type type, long v) in inc_rlimit_ucounts() argument
265 struct ucounts *iter; in inc_rlimit_ucounts()
269 for (iter = ucounts; iter; iter = iter->ns->ucounts) { in inc_rlimit_ucounts()
273 else if (iter == ucounts) in inc_rlimit_ucounts()
280 bool dec_rlimit_ucounts(struct ucounts *ucounts, enum rlimit_type type, long v) in dec_rlimit_ucounts() argument
282 struct ucounts *iter; in dec_rlimit_ucounts()
284 for (iter = ucounts; iter; iter = iter->ns->ucounts) { in dec_rlimit_ucounts()
287 if (iter == ucounts) in dec_rlimit_ucounts()
293 static void do_dec_rlimit_put_ucounts(struct ucounts *ucounts, in do_dec_rlimit_put_ucounts() argument
294 struct ucounts *last, enum rlimit_type type) in do_dec_rlimit_put_ucounts()
296 struct ucounts *iter, *next; in do_dec_rlimit_put_ucounts()
297 for (iter = ucounts; iter != last; iter = next) { in do_dec_rlimit_put_ucounts()
300 next = iter->ns->ucounts; in do_dec_rlimit_put_ucounts()
306 void dec_rlimit_put_ucounts(struct ucounts *ucounts, enum rlimit_type type) in dec_rlimit_put_ucounts() argument
308 do_dec_rlimit_put_ucounts(ucounts, NULL, type); in dec_rlimit_put_ucounts()
311 long inc_rlimit_get_ucounts(struct ucounts *ucounts, enum rlimit_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_rlimit_overlimit(struct ucounts *ucounts, enum rlimit_type type, unsigned long rlimit) in is_rlimit_overlimit() argument
346 struct ucounts *iter; in is_rlimit_overlimit()
350 for (iter = ucounts; iter; iter = iter->ns->ucounts) { in is_rlimit_overlimit()