Lines Matching full:permits

78  * Dispose of a list of permits.
82 struct afs_permits *permits = in afs_permits_rcu() local
86 for (i = 0; i < permits->nr_permits; i++) in afs_permits_rcu()
87 key_put(permits->permits[i].key); in afs_permits_rcu()
88 kfree(permits); in afs_permits_rcu()
94 void afs_put_permits(struct afs_permits *permits) in afs_put_permits() argument
96 if (permits && refcount_dec_and_test(&permits->usage)) { in afs_put_permits()
98 hash_del_rcu(&permits->hash_node); in afs_put_permits()
100 call_rcu(&permits->rcu, afs_permits_rcu); in afs_put_permits()
109 struct afs_permits *permits; in afs_clear_permits() local
112 permits = rcu_dereference_protected(vnode->permit_cache, in afs_clear_permits()
117 afs_put_permits(permits); in afs_clear_permits()
121 * Hash a list of permits. Use simple addition to make it easy to add an extra
124 static void afs_hash_permits(struct afs_permits *permits) in afs_hash_permits() argument
126 unsigned long h = permits->nr_permits; in afs_hash_permits()
129 for (i = 0; i < permits->nr_permits; i++) { in afs_hash_permits()
130 h += (unsigned long)permits->permits[i].key / sizeof(void *); in afs_hash_permits()
131 h += permits->permits[i].access; in afs_hash_permits()
134 permits->h = h; in afs_hash_permits()
146 struct afs_permits *permits, *xpermits, *replacement, *zap, *new = NULL; in afs_cache_permit() local
160 permits = rcu_dereference(vnode->permit_cache); in afs_cache_permit()
161 if (permits) { in afs_cache_permit()
162 if (!permits->invalidated) { in afs_cache_permit()
163 for (i = 0; i < permits->nr_permits; i++) { in afs_cache_permit()
164 if (permits->permits[i].key < key) in afs_cache_permit()
166 if (permits->permits[i].key > key) in afs_cache_permit()
168 if (permits->permits[i].access != caller_access) { in afs_cache_permit()
184 changed |= permits->invalidated; in afs_cache_permit()
185 size = permits->nr_permits; in afs_cache_permit()
187 /* If this set of permits is now wrong, clear the permits in afs_cache_permit()
192 if (permits != rcu_access_pointer(vnode->permit_cache)) in afs_cache_permit()
197 afs_put_permits(permits); in afs_cache_permit()
198 permits = NULL; in afs_cache_permit()
206 /* We need a ref on any permits list we want to copy as we'll have to in afs_cache_permit()
209 if (permits && !refcount_inc_not_zero(&permits->usage)) in afs_cache_permit()
222 new = kzalloc(struct_size(new, permits, size), GFP_NOFS); in afs_cache_permit()
229 if (permits) { in afs_cache_permit()
230 for (i = 0; i < permits->nr_permits; i++) { in afs_cache_permit()
231 if (j == i && permits->permits[i].key > key) { in afs_cache_permit()
232 new->permits[j].key = key; in afs_cache_permit()
233 new->permits[j].access = caller_access; in afs_cache_permit()
236 new->permits[j].key = permits->permits[i].key; in afs_cache_permit()
237 new->permits[j].access = permits->permits[i].access; in afs_cache_permit()
243 new->permits[j].key = key; in afs_cache_permit()
244 new->permits[j].access = caller_access; in afs_cache_permit()
256 memcmp(xpermits->permits, new->permits, in afs_cache_permit()
269 key_get(new->permits[i].key); in afs_cache_permit()
282 if (!afs_cb_is_broken(cb_break, vnode) && zap == permits) in afs_cache_permit()
290 afs_put_permits(permits); in afs_cache_permit()
306 const struct afs_permits *permits; in afs_check_permit_rcu() local
312 /* check the permits to see if we've got one yet */ in afs_check_permit_rcu()
319 permits = rcu_dereference(vnode->permit_cache); in afs_check_permit_rcu()
320 if (permits) { in afs_check_permit_rcu()
321 for (i = 0; i < permits->nr_permits; i++) { in afs_check_permit_rcu()
322 if (permits->permits[i].key < key) in afs_check_permit_rcu()
324 if (permits->permits[i].key > key) in afs_check_permit_rcu()
327 *_access = permits->permits[i].access; in afs_check_permit_rcu()
328 _leave(" = %u [perm %x]", !permits->invalidated, *_access); in afs_check_permit_rcu()
329 return !permits->invalidated; in afs_check_permit_rcu()
345 struct afs_permits *permits; in afs_check_permit() local
352 /* check the permits to see if we've got one yet */ in afs_check_permit()
359 permits = rcu_dereference(vnode->permit_cache); in afs_check_permit()
360 if (permits) { in afs_check_permit()
361 for (i = 0; i < permits->nr_permits; i++) { in afs_check_permit()
362 if (permits->permits[i].key < key) in afs_check_permit()
364 if (permits->permits[i].key > key) in afs_check_permit()
367 *_access = permits->permits[i].access; in afs_check_permit()
368 valid = !permits->invalidated; in afs_check_permit()
429 /* check the permits to see if we've got one yet */ in afs_permission()