Lines Matching refs:nf
85 struct nfsd_file *nf = container_of(rcu, struct nfsd_file, nf_rcu); in nfsd_file_slab_free() local
87 put_cred(nf->nf_cred); in nfsd_file_slab_free()
88 kmem_cache_free(nfsd_file_slab, nf); in nfsd_file_slab_free()
118 nfsd_file_mark_find_or_create(struct nfsd_file *nf) in nfsd_file_mark_find_or_create() argument
123 struct inode *inode = nf->nf_inode; in nfsd_file_mark_find_or_create()
176 struct nfsd_file *nf; in nfsd_file_alloc() local
178 nf = kmem_cache_alloc(nfsd_file_slab, GFP_KERNEL); in nfsd_file_alloc()
179 if (nf) { in nfsd_file_alloc()
180 INIT_HLIST_NODE(&nf->nf_node); in nfsd_file_alloc()
181 INIT_LIST_HEAD(&nf->nf_lru); in nfsd_file_alloc()
182 nf->nf_file = NULL; in nfsd_file_alloc()
183 nf->nf_cred = get_current_cred(); in nfsd_file_alloc()
184 nf->nf_net = net; in nfsd_file_alloc()
185 nf->nf_flags = 0; in nfsd_file_alloc()
186 nf->nf_inode = inode; in nfsd_file_alloc()
187 nf->nf_hashval = hashval; in nfsd_file_alloc()
188 refcount_set(&nf->nf_ref, 1); in nfsd_file_alloc()
189 nf->nf_may = may & NFSD_FILE_MAY_MASK; in nfsd_file_alloc()
192 __set_bit(NFSD_FILE_BREAK_WRITE, &nf->nf_flags); in nfsd_file_alloc()
194 __set_bit(NFSD_FILE_BREAK_READ, &nf->nf_flags); in nfsd_file_alloc()
196 nf->nf_mark = NULL; in nfsd_file_alloc()
197 init_rwsem(&nf->nf_rwsem); in nfsd_file_alloc()
198 trace_nfsd_file_alloc(nf); in nfsd_file_alloc()
200 return nf; in nfsd_file_alloc()
204 nfsd_file_free(struct nfsd_file *nf) in nfsd_file_free() argument
208 trace_nfsd_file_put_final(nf); in nfsd_file_free()
209 if (nf->nf_mark) in nfsd_file_free()
210 nfsd_file_mark_put(nf->nf_mark); in nfsd_file_free()
211 if (nf->nf_file) { in nfsd_file_free()
212 get_file(nf->nf_file); in nfsd_file_free()
213 filp_close(nf->nf_file, NULL); in nfsd_file_free()
214 fput(nf->nf_file); in nfsd_file_free()
217 call_rcu(&nf->nf_rcu, nfsd_file_slab_free); in nfsd_file_free()
222 nfsd_file_check_writeback(struct nfsd_file *nf) in nfsd_file_check_writeback() argument
224 struct file *file = nf->nf_file; in nfsd_file_check_writeback()
235 nfsd_file_check_write_error(struct nfsd_file *nf) in nfsd_file_check_write_error() argument
237 struct file *file = nf->nf_file; in nfsd_file_check_write_error()
245 nfsd_file_do_unhash(struct nfsd_file *nf) in nfsd_file_do_unhash() argument
247 lockdep_assert_held(&nfsd_file_hashtbl[nf->nf_hashval].nfb_lock); in nfsd_file_do_unhash()
249 trace_nfsd_file_unhash(nf); in nfsd_file_do_unhash()
251 if (nfsd_file_check_write_error(nf)) in nfsd_file_do_unhash()
252 nfsd_reset_boot_verifier(net_generic(nf->nf_net, nfsd_net_id)); in nfsd_file_do_unhash()
253 --nfsd_file_hashtbl[nf->nf_hashval].nfb_count; in nfsd_file_do_unhash()
254 hlist_del_rcu(&nf->nf_node); in nfsd_file_do_unhash()
259 nfsd_file_unhash(struct nfsd_file *nf) in nfsd_file_unhash() argument
261 if (test_and_clear_bit(NFSD_FILE_HASHED, &nf->nf_flags)) { in nfsd_file_unhash()
262 nfsd_file_do_unhash(nf); in nfsd_file_unhash()
263 if (!list_empty(&nf->nf_lru)) in nfsd_file_unhash()
264 list_lru_del(&nfsd_file_lru, &nf->nf_lru); in nfsd_file_unhash()
274 nfsd_file_unhash_and_release_locked(struct nfsd_file *nf, struct list_head *dispose) in nfsd_file_unhash_and_release_locked() argument
276 lockdep_assert_held(&nfsd_file_hashtbl[nf->nf_hashval].nfb_lock); in nfsd_file_unhash_and_release_locked()
278 trace_nfsd_file_unhash_and_release_locked(nf); in nfsd_file_unhash_and_release_locked()
279 if (!nfsd_file_unhash(nf)) in nfsd_file_unhash_and_release_locked()
282 if (refcount_dec_not_one(&nf->nf_ref)) in nfsd_file_unhash_and_release_locked()
285 list_add(&nf->nf_lru, dispose); in nfsd_file_unhash_and_release_locked()
290 nfsd_file_put_noref(struct nfsd_file *nf) in nfsd_file_put_noref() argument
292 trace_nfsd_file_put(nf); in nfsd_file_put_noref()
294 if (refcount_dec_and_test(&nf->nf_ref)) { in nfsd_file_put_noref()
295 WARN_ON(test_bit(NFSD_FILE_HASHED, &nf->nf_flags)); in nfsd_file_put_noref()
296 nfsd_file_free(nf); in nfsd_file_put_noref()
301 nfsd_file_put(struct nfsd_file *nf) in nfsd_file_put() argument
305 set_bit(NFSD_FILE_REFERENCED, &nf->nf_flags); in nfsd_file_put()
306 if (refcount_read(&nf->nf_ref) > 2 || !nf->nf_file) { in nfsd_file_put()
307 nfsd_file_put_noref(nf); in nfsd_file_put()
311 filemap_flush(nf->nf_file->f_mapping); in nfsd_file_put()
312 is_hashed = test_bit(NFSD_FILE_HASHED, &nf->nf_flags) != 0; in nfsd_file_put()
313 nfsd_file_put_noref(nf); in nfsd_file_put()
321 nfsd_file_get(struct nfsd_file *nf) in nfsd_file_get() argument
323 if (likely(refcount_inc_not_zero(&nf->nf_ref))) in nfsd_file_get()
324 return nf; in nfsd_file_get()
331 struct nfsd_file *nf; in nfsd_file_dispose_list() local
334 nf = list_first_entry(dispose, struct nfsd_file, nf_lru); in nfsd_file_dispose_list()
335 list_del(&nf->nf_lru); in nfsd_file_dispose_list()
336 nfsd_file_put_noref(nf); in nfsd_file_dispose_list()
344 struct nfsd_file *nf; in nfsd_file_dispose_list_sync() local
347 nf = list_first_entry(dispose, struct nfsd_file, nf_lru); in nfsd_file_dispose_list_sync()
348 list_del(&nf->nf_lru); in nfsd_file_dispose_list_sync()
349 if (!refcount_dec_and_test(&nf->nf_ref)) in nfsd_file_dispose_list_sync()
351 if (nfsd_file_free(nf)) in nfsd_file_dispose_list_sync()
389 struct nfsd_file *nf, *tmp; in nfsd_file_list_add_pernet() local
391 list_for_each_entry_safe(nf, tmp, src, nf_lru) { in nfsd_file_list_add_pernet()
392 if (nf->nf_net == net) in nfsd_file_list_add_pernet()
393 list_move_tail(&nf->nf_lru, dst); in nfsd_file_list_add_pernet()
401 struct nfsd_file *nf; in nfsd_file_dispose_list_delayed() local
404 nf = list_first_entry(dispose, struct nfsd_file, nf_lru); in nfsd_file_dispose_list_delayed()
405 nfsd_file_list_add_pernet(&list, dispose, nf->nf_net); in nfsd_file_dispose_list_delayed()
406 nfsd_file_list_add_disposal(&list, nf->nf_net); in nfsd_file_dispose_list_delayed()
420 struct nfsd_file *nf = list_entry(item, struct nfsd_file, nf_lru); in nfsd_file_lru_cb() local
432 if (refcount_read(&nf->nf_ref) > 1) in nfsd_file_lru_cb()
439 if (nfsd_file_check_writeback(nf)) in nfsd_file_lru_cb()
442 if (test_and_clear_bit(NFSD_FILE_REFERENCED, &nf->nf_flags)) in nfsd_file_lru_cb()
445 if (!test_and_clear_bit(NFSD_FILE_HASHED, &nf->nf_flags)) in nfsd_file_lru_cb()
448 list_lru_isolate_move(lru, &nf->nf_lru, head); in nfsd_file_lru_cb()
458 struct nfsd_file *nf; in nfsd_file_lru_walk_list() local
468 list_for_each_entry(nf, &head, nf_lru) { in nfsd_file_lru_walk_list()
469 spin_lock(&nfsd_file_hashtbl[nf->nf_hashval].nfb_lock); in nfsd_file_lru_walk_list()
470 nfsd_file_do_unhash(nf); in nfsd_file_lru_walk_list()
471 spin_unlock(&nfsd_file_hashtbl[nf->nf_hashval].nfb_lock); in nfsd_file_lru_walk_list()
512 struct nfsd_file *nf; in __nfsd_file_close_inode() local
516 hlist_for_each_entry_safe(nf, tmp, &nfsd_file_hashtbl[hashval].nfb_head, nf_node) { in __nfsd_file_close_inode()
517 if (inode == nf->nf_inode) in __nfsd_file_close_inode()
518 nfsd_file_unhash_and_release_locked(nf, dispose); in __nfsd_file_close_inode()
729 struct nfsd_file *nf; in nfsd_file_cache_purge() local
741 hlist_for_each_entry_safe(nf, next, &nfb->nfb_head, nf_node) { in nfsd_file_cache_purge()
742 if (net && nf->nf_net != net) in nfsd_file_cache_purge()
744 del = nfsd_file_unhash_and_release_locked(nf, &dispose); in nfsd_file_cache_purge()
891 struct nfsd_file *nf; in nfsd_file_find_locked() local
894 hlist_for_each_entry_rcu(nf, &nfsd_file_hashtbl[hashval].nfb_head, in nfsd_file_find_locked()
896 if (nf->nf_may != need) in nfsd_file_find_locked()
898 if (nf->nf_inode != inode) in nfsd_file_find_locked()
900 if (nf->nf_net != net) in nfsd_file_find_locked()
902 if (!nfsd_match_cred(nf->nf_cred, current_cred())) in nfsd_file_find_locked()
904 if (!test_bit(NFSD_FILE_HASHED, &nf->nf_flags)) in nfsd_file_find_locked()
906 if (nfsd_file_get(nf) != NULL) in nfsd_file_find_locked()
907 return nf; in nfsd_file_find_locked()
923 struct nfsd_file *nf; in nfsd_file_is_cached() local
929 hlist_for_each_entry_rcu(nf, &nfsd_file_hashtbl[hashval].nfb_head, in nfsd_file_is_cached()
931 if (inode == nf->nf_inode) { in nfsd_file_is_cached()
947 struct nfsd_file *nf, *new; in nfsd_file_acquire() local
962 nf = nfsd_file_find_locked(inode, may_flags, hashval, net); in nfsd_file_acquire()
964 if (nf) in nfsd_file_acquire()
975 nf = nfsd_file_find_locked(inode, may_flags, hashval, net); in nfsd_file_acquire()
976 if (nf == NULL) in nfsd_file_acquire()
982 wait_on_bit(&nf->nf_flags, NFSD_FILE_PENDING, TASK_UNINTERRUPTIBLE); in nfsd_file_acquire()
985 if (!test_bit(NFSD_FILE_HASHED, &nf->nf_flags)) { in nfsd_file_acquire()
991 nfsd_file_put_noref(nf); in nfsd_file_acquire()
1000 if (test_bit(NFSD_FILE_BREAK_READ, &nf->nf_flags) || in nfsd_file_acquire()
1001 (test_bit(NFSD_FILE_BREAK_WRITE, &nf->nf_flags) && write)) { in nfsd_file_acquire()
1003 file_inode(nf->nf_file), may_flags)); in nfsd_file_acquire()
1005 clear_bit(NFSD_FILE_BREAK_READ, &nf->nf_flags); in nfsd_file_acquire()
1008 &nf->nf_flags); in nfsd_file_acquire()
1014 *pnf = nf; in nfsd_file_acquire()
1016 nfsd_file_put(nf); in nfsd_file_acquire()
1017 nf = NULL; in nfsd_file_acquire()
1020 trace_nfsd_file_acquire(rqstp, hashval, inode, may_flags, nf, status); in nfsd_file_acquire()
1023 nf = new; in nfsd_file_acquire()
1025 refcount_inc(&nf->nf_ref); in nfsd_file_acquire()
1026 __set_bit(NFSD_FILE_HASHED, &nf->nf_flags); in nfsd_file_acquire()
1027 __set_bit(NFSD_FILE_PENDING, &nf->nf_flags); in nfsd_file_acquire()
1028 list_lru_add(&nfsd_file_lru, &nf->nf_lru); in nfsd_file_acquire()
1029 hlist_add_head_rcu(&nf->nf_node, &nfsd_file_hashtbl[hashval].nfb_head); in nfsd_file_acquire()
1037 nf->nf_mark = nfsd_file_mark_find_or_create(nf); in nfsd_file_acquire()
1038 if (nf->nf_mark) in nfsd_file_acquire()
1040 may_flags, &nf->nf_file); in nfsd_file_acquire()
1050 do_free = nfsd_file_unhash(nf); in nfsd_file_acquire()
1053 nfsd_file_put_noref(nf); in nfsd_file_acquire()
1055 clear_bit_unlock(NFSD_FILE_PENDING, &nf->nf_flags); in nfsd_file_acquire()
1057 wake_up_bit(&nf->nf_flags, NFSD_FILE_PENDING); in nfsd_file_acquire()