Lines Matching full:nf
124 struct nfsd_file *nf = container_of(rcu, struct nfsd_file, nf_rcu); in nfsd_file_slab_free() local
126 put_cred(nf->nf_cred); in nfsd_file_slab_free()
127 kmem_cache_free(nfsd_file_slab, nf); in nfsd_file_slab_free()
157 nfsd_file_mark_find_or_create(struct nfsd_file *nf, struct inode *inode) in nfsd_file_mark_find_or_create() argument
215 struct nfsd_file *nf; in nfsd_file_alloc() local
217 nf = kmem_cache_alloc(nfsd_file_slab, GFP_KERNEL); in nfsd_file_alloc()
218 if (unlikely(!nf)) in nfsd_file_alloc()
221 INIT_LIST_HEAD(&nf->nf_lru); in nfsd_file_alloc()
222 nf->nf_birthtime = ktime_get(); in nfsd_file_alloc()
223 nf->nf_file = NULL; in nfsd_file_alloc()
224 nf->nf_cred = get_current_cred(); in nfsd_file_alloc()
225 nf->nf_net = net; in nfsd_file_alloc()
226 nf->nf_flags = want_gc ? in nfsd_file_alloc()
229 nf->nf_inode = inode; in nfsd_file_alloc()
230 refcount_set(&nf->nf_ref, 1); in nfsd_file_alloc()
231 nf->nf_may = need; in nfsd_file_alloc()
232 nf->nf_mark = NULL; in nfsd_file_alloc()
233 return nf; in nfsd_file_alloc()
238 * @nf: nfsd_file to check for writeback errors
244 nfsd_file_check_write_error(struct nfsd_file *nf) in nfsd_file_check_write_error() argument
246 struct file *file = nf->nf_file; in nfsd_file_check_write_error()
250 nfsd_reset_write_verifier(net_generic(nf->nf_net, nfsd_net_id)); in nfsd_file_check_write_error()
254 nfsd_file_hash_remove(struct nfsd_file *nf) in nfsd_file_hash_remove() argument
256 trace_nfsd_file_unhash(nf); in nfsd_file_hash_remove()
257 rhltable_remove(&nfsd_file_rhltable, &nf->nf_rlist, in nfsd_file_hash_remove()
262 nfsd_file_unhash(struct nfsd_file *nf) in nfsd_file_unhash() argument
264 if (test_and_clear_bit(NFSD_FILE_HASHED, &nf->nf_flags)) { in nfsd_file_unhash()
265 nfsd_file_hash_remove(nf); in nfsd_file_unhash()
272 nfsd_file_free(struct nfsd_file *nf) in nfsd_file_free() argument
274 s64 age = ktime_to_ms(ktime_sub(ktime_get(), nf->nf_birthtime)); in nfsd_file_free()
276 trace_nfsd_file_free(nf); in nfsd_file_free()
281 nfsd_file_unhash(nf); in nfsd_file_free()
282 if (nf->nf_mark) in nfsd_file_free()
283 nfsd_file_mark_put(nf->nf_mark); in nfsd_file_free()
284 if (nf->nf_file) { in nfsd_file_free()
285 nfsd_file_check_write_error(nf); in nfsd_file_free()
286 filp_close(nf->nf_file, NULL); in nfsd_file_free()
293 if (WARN_ON_ONCE(!list_empty(&nf->nf_lru))) in nfsd_file_free()
296 call_rcu(&nf->nf_rcu, nfsd_file_slab_free); in nfsd_file_free()
300 nfsd_file_check_writeback(struct nfsd_file *nf) in nfsd_file_check_writeback() argument
302 struct file *file = nf->nf_file; in nfsd_file_check_writeback()
322 static bool nfsd_file_lru_add(struct nfsd_file *nf) in nfsd_file_lru_add() argument
324 set_bit(NFSD_FILE_REFERENCED, &nf->nf_flags); in nfsd_file_lru_add()
325 if (list_lru_add(&nfsd_file_lru, &nf->nf_lru)) { in nfsd_file_lru_add()
326 trace_nfsd_file_lru_add(nf); in nfsd_file_lru_add()
332 static bool nfsd_file_lru_remove(struct nfsd_file *nf) in nfsd_file_lru_remove() argument
334 if (list_lru_del(&nfsd_file_lru, &nf->nf_lru)) { in nfsd_file_lru_remove()
335 trace_nfsd_file_lru_del(nf); in nfsd_file_lru_remove()
342 nfsd_file_get(struct nfsd_file *nf) in nfsd_file_get() argument
344 if (nf && refcount_inc_not_zero(&nf->nf_ref)) in nfsd_file_get()
345 return nf; in nfsd_file_get()
351 * @nf: nfsd_file of which to put the reference
358 nfsd_file_put(struct nfsd_file *nf) in nfsd_file_put() argument
361 trace_nfsd_file_put(nf); in nfsd_file_put()
363 if (test_bit(NFSD_FILE_GC, &nf->nf_flags) && in nfsd_file_put()
364 test_bit(NFSD_FILE_HASHED, &nf->nf_flags)) { in nfsd_file_put()
369 if (refcount_dec_not_one(&nf->nf_ref)) in nfsd_file_put()
373 if (nfsd_file_lru_add(nf)) { in nfsd_file_put()
375 if (test_bit(NFSD_FILE_HASHED, &nf->nf_flags)) { in nfsd_file_put()
385 if (!nfsd_file_lru_remove(nf)) in nfsd_file_put()
389 if (refcount_dec_and_test(&nf->nf_ref)) in nfsd_file_put()
390 nfsd_file_free(nf); in nfsd_file_put()
396 struct nfsd_file *nf; in nfsd_file_dispose_list() local
399 nf = list_first_entry(dispose, struct nfsd_file, nf_lru); in nfsd_file_dispose_list()
400 list_del_init(&nf->nf_lru); in nfsd_file_dispose_list()
401 nfsd_file_free(nf); in nfsd_file_dispose_list()
416 struct nfsd_file *nf = list_first_entry(dispose, in nfsd_file_dispose_list_delayed() local
418 struct nfsd_net *nn = net_generic(nf->nf_net, nfsd_net_id); in nfsd_file_dispose_list_delayed()
422 list_move_tail(&nf->nf_lru, &l->freeme); in nfsd_file_dispose_list_delayed()
447 struct nfsd_file *nf = list_entry(item, struct nfsd_file, nf_lru); in nfsd_file_lru_cb() local
450 WARN_ON_ONCE(!test_bit(NFSD_FILE_GC, &nf->nf_flags)); in nfsd_file_lru_cb()
456 if (nfsd_file_check_writeback(nf)) { in nfsd_file_lru_cb()
457 trace_nfsd_file_gc_writeback(nf); in nfsd_file_lru_cb()
462 if (test_and_clear_bit(NFSD_FILE_REFERENCED, &nf->nf_flags)) { in nfsd_file_lru_cb()
463 trace_nfsd_file_gc_referenced(nf); in nfsd_file_lru_cb()
471 if (!refcount_dec_and_test(&nf->nf_ref)) { in nfsd_file_lru_cb()
472 trace_nfsd_file_gc_in_use(nf); in nfsd_file_lru_cb()
473 list_lru_isolate(lru, &nf->nf_lru); in nfsd_file_lru_cb()
478 nfsd_file_unhash(nf); in nfsd_file_lru_cb()
479 list_lru_isolate_move(lru, &nf->nf_lru, head); in nfsd_file_lru_cb()
481 trace_nfsd_file_gc_disposed(nf); in nfsd_file_lru_cb()
532 * @nf: nfsd_file to attempt to queue
539 nfsd_file_cond_queue(struct nfsd_file *nf, struct list_head *dispose) in nfsd_file_cond_queue() argument
545 if (!nfsd_file_unhash(nf)) in nfsd_file_cond_queue()
549 if (!nfsd_file_get(nf)) in nfsd_file_cond_queue()
553 if (nfsd_file_lru_remove(nf)) in nfsd_file_cond_queue()
557 if (refcount_sub_and_test(decrement, &nf->nf_ref)) { in nfsd_file_cond_queue()
558 list_add(&nf->nf_lru, dispose); in nfsd_file_cond_queue()
559 trace_nfsd_file_closing(nf); in nfsd_file_cond_queue()
583 struct nfsd_file *nf; in nfsd_file_queue_for_close() local
588 rhl_for_each_entry_rcu(nf, tmp, list, nf_rlist) { in nfsd_file_queue_for_close()
589 if (!test_bit(NFSD_FILE_GC, &nf->nf_flags)) in nfsd_file_queue_for_close()
591 nfsd_file_cond_queue(nf, dispose); in nfsd_file_queue_for_close()
627 struct nfsd_file *nf; in nfsd_file_close_inode_sync() local
634 nf = list_first_entry(&dispose, struct nfsd_file, nf_lru); in nfsd_file_close_inode_sync()
635 list_del_init(&nf->nf_lru); in nfsd_file_close_inode_sync()
636 nfsd_file_free(nf); in nfsd_file_close_inode_sync()
805 struct nfsd_file *nf; in __nfsd_file_cache_purge() local
812 nf = rhashtable_walk_next(&iter); in __nfsd_file_cache_purge()
813 while (!IS_ERR_OR_NULL(nf)) { in __nfsd_file_cache_purge()
814 if (!net || nf->nf_net == net) in __nfsd_file_cache_purge()
815 nfsd_file_cond_queue(nf, &dispose); in __nfsd_file_cache_purge()
816 nf = rhashtable_walk_next(&iter); in __nfsd_file_cache_purge()
820 } while (nf == ERR_PTR(-EAGAIN)); in __nfsd_file_cache_purge()
931 struct nfsd_file *nf; in nfsd_file_lookup_locked() local
935 rhl_for_each_entry_rcu(nf, tmp, list, nf_rlist) { in nfsd_file_lookup_locked()
936 if (nf->nf_may != need) in nfsd_file_lookup_locked()
938 if (nf->nf_net != net) in nfsd_file_lookup_locked()
940 if (!nfsd_match_cred(nf->nf_cred, cred)) in nfsd_file_lookup_locked()
942 if (test_bit(NFSD_FILE_GC, &nf->nf_flags) != want_gc) in nfsd_file_lookup_locked()
944 if (test_bit(NFSD_FILE_HASHED, &nf->nf_flags) == 0) in nfsd_file_lookup_locked()
947 if (!nfsd_file_get(nf)) in nfsd_file_lookup_locked()
949 return nf; in nfsd_file_lookup_locked()
969 struct nfsd_file *nf; in nfsd_file_is_cached() local
975 rhl_for_each_entry_rcu(nf, tmp, list, nf_rlist) in nfsd_file_is_cached()
976 if (test_bit(NFSD_FILE_GC, &nf->nf_flags)) { in nfsd_file_is_cached()
993 struct nfsd_file *new, *nf; in nfsd_file_do_acquire() local
1008 nf = nfsd_file_lookup_locked(net, current_cred(), inode, need, want_gc); in nfsd_file_do_acquire()
1011 if (nf) { in nfsd_file_do_acquire()
1013 * If the nf is on the LRU then it holds an extra reference in nfsd_file_do_acquire()
1017 if (nfsd_file_lru_remove(nf)) in nfsd_file_do_acquire()
1018 WARN_ON_ONCE(refcount_dec_and_test(&nf->nf_ref)); in nfsd_file_do_acquire()
1030 nf = nfsd_file_lookup_locked(net, current_cred(), inode, need, want_gc); in nfsd_file_do_acquire()
1031 if (unlikely(nf)) { in nfsd_file_do_acquire()
1037 nf = new; in nfsd_file_do_acquire()
1038 ret = rhltable_insert(&nfsd_file_rhltable, &nf->nf_rlist, in nfsd_file_do_acquire()
1050 wait_on_bit(&nf->nf_flags, NFSD_FILE_PENDING, TASK_UNINTERRUPTIBLE); in nfsd_file_do_acquire()
1053 if (!test_bit(NFSD_FILE_HASHED, &nf->nf_flags)) { in nfsd_file_do_acquire()
1054 trace_nfsd_file_cons_err(rqstp, inode, may_flags, nf); in nfsd_file_do_acquire()
1059 nfsd_file_put(nf); in nfsd_file_do_acquire()
1066 status = nfserrno(nfsd_open_break_lease(file_inode(nf->nf_file), may_flags)); in nfsd_file_do_acquire()
1068 nfsd_file_put(nf); in nfsd_file_do_acquire()
1069 nf = NULL; in nfsd_file_do_acquire()
1075 nfsd_file_check_write_error(nf); in nfsd_file_do_acquire()
1076 *pnf = nf; in nfsd_file_do_acquire()
1078 trace_nfsd_file_acquire(rqstp, inode, may_flags, nf, status); in nfsd_file_do_acquire()
1082 trace_nfsd_file_alloc(nf); in nfsd_file_do_acquire()
1083 nf->nf_mark = nfsd_file_mark_find_or_create(nf, inode); in nfsd_file_do_acquire()
1084 if (nf->nf_mark) { in nfsd_file_do_acquire()
1087 nf->nf_file = file; in nfsd_file_do_acquire()
1089 trace_nfsd_file_opened(nf, status); in nfsd_file_do_acquire()
1092 &nf->nf_file); in nfsd_file_do_acquire()
1095 nfsd_file_unhash(nf); in nfsd_file_do_acquire()
1097 &nf->nf_flags); in nfsd_file_do_acquire()
1098 if (refcount_dec_and_test(&nf->nf_ref)) in nfsd_file_do_acquire()
1099 nfsd_file_free(nf); in nfsd_file_do_acquire()
1100 nf = NULL; in nfsd_file_do_acquire()
1105 trace_nfsd_file_open(nf, status); in nfsd_file_do_acquire()
1114 nfsd_file_unhash(nf); in nfsd_file_do_acquire()
1115 clear_and_wake_up_bit(NFSD_FILE_PENDING, &nf->nf_flags); in nfsd_file_do_acquire()
1120 if (refcount_dec_and_test(&nf->nf_ref)) in nfsd_file_do_acquire()
1121 nfsd_file_free(nf); in nfsd_file_do_acquire()
1122 nf = NULL; in nfsd_file_do_acquire()