Lines Matching full:nf

122 	struct nfsd_file *nf = container_of(rcu, struct nfsd_file, nf_rcu);  in nfsd_file_slab_free()  local
124 put_cred(nf->nf_cred); in nfsd_file_slab_free()
125 kmem_cache_free(nfsd_file_slab, nf); in nfsd_file_slab_free()
213 struct nfsd_file *nf; in nfsd_file_alloc() local
215 nf = kmem_cache_alloc(nfsd_file_slab, GFP_KERNEL); in nfsd_file_alloc()
216 if (unlikely(!nf)) in nfsd_file_alloc()
220 INIT_LIST_HEAD(&nf->nf_lru); in nfsd_file_alloc()
221 INIT_LIST_HEAD(&nf->nf_gc); 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 nfsd_filp_close(nf->nf_file); 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_obj(&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_obj(&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()
395 * @nf: nfsd_file of which to put the references
401 nfsd_file_put_local(struct nfsd_file *nf) __must_hold(rcu) in nfsd_file_put_local() argument
403 struct net *net = nf->nf_net; in nfsd_file_put_local()
405 nfsd_file_put(nf); in nfsd_file_put_local()
411 * @nf: nfsd_file of which to access the backing file.
413 * Return backing file for @nf.
416 nfsd_file_file(struct nfsd_file *nf) in nfsd_file_file() argument
418 return nf->nf_file; in nfsd_file_file()
424 struct nfsd_file *nf; in nfsd_file_dispose_list() local
427 nf = list_first_entry(dispose, struct nfsd_file, nf_gc); in nfsd_file_dispose_list()
428 list_del_init(&nf->nf_gc); in nfsd_file_dispose_list()
429 nfsd_file_free(nf); in nfsd_file_dispose_list()
444 struct nfsd_file *nf = list_first_entry(dispose, in nfsd_file_dispose_list_delayed() local
446 struct nfsd_net *nn = net_generic(nf->nf_net, nfsd_net_id); in nfsd_file_dispose_list_delayed()
450 list_move_tail(&nf->nf_gc, &l->freeme); in nfsd_file_dispose_list_delayed()
505 struct nfsd_file *nf = list_entry(item, struct nfsd_file, nf_lru); in nfsd_file_lru_cb() local
508 WARN_ON_ONCE(!test_bit(NFSD_FILE_GC, &nf->nf_flags)); in nfsd_file_lru_cb()
514 if (nfsd_file_check_writeback(nf)) { in nfsd_file_lru_cb()
515 trace_nfsd_file_gc_writeback(nf); in nfsd_file_lru_cb()
520 if (test_and_clear_bit(NFSD_FILE_REFERENCED, &nf->nf_flags)) { in nfsd_file_lru_cb()
521 trace_nfsd_file_gc_referenced(nf); in nfsd_file_lru_cb()
529 if (!refcount_dec_and_test(&nf->nf_ref)) { in nfsd_file_lru_cb()
530 trace_nfsd_file_gc_in_use(nf); in nfsd_file_lru_cb()
531 list_lru_isolate(lru, &nf->nf_lru); in nfsd_file_lru_cb()
536 nfsd_file_unhash(nf); in nfsd_file_lru_cb()
537 list_lru_isolate(lru, &nf->nf_lru); in nfsd_file_lru_cb()
538 list_add(&nf->nf_gc, head); in nfsd_file_lru_cb()
540 trace_nfsd_file_gc_disposed(nf); in nfsd_file_lru_cb()
587 * @nf: nfsd_file to attempt to queue
594 nfsd_file_cond_queue(struct nfsd_file *nf, struct list_head *dispose) in nfsd_file_cond_queue() argument
600 if (!nfsd_file_unhash(nf)) in nfsd_file_cond_queue()
604 if (!nfsd_file_get(nf)) in nfsd_file_cond_queue()
608 if (nfsd_file_lru_remove(nf)) in nfsd_file_cond_queue()
612 if (refcount_sub_and_test(decrement, &nf->nf_ref)) { in nfsd_file_cond_queue()
613 list_add(&nf->nf_gc, dispose); in nfsd_file_cond_queue()
614 trace_nfsd_file_closing(nf); in nfsd_file_cond_queue()
638 struct nfsd_file *nf; in nfsd_file_queue_for_close() local
643 rhl_for_each_entry_rcu(nf, tmp, list, nf_rlist) { in nfsd_file_queue_for_close()
644 if (!test_bit(NFSD_FILE_GC, &nf->nf_flags)) in nfsd_file_queue_for_close()
646 nfsd_file_cond_queue(nf, dispose); in nfsd_file_queue_for_close()
682 struct nfsd_file *nf; in nfsd_file_close_inode_sync() local
689 nf = list_first_entry(&dispose, struct nfsd_file, nf_gc); in nfsd_file_close_inode_sync()
690 list_del_init(&nf->nf_gc); in nfsd_file_close_inode_sync()
691 nfsd_file_free(nf); in nfsd_file_close_inode_sync()
836 struct nfsd_file *nf; in __nfsd_file_cache_purge() local
843 nf = rhashtable_walk_next(&iter); in __nfsd_file_cache_purge()
844 while (!IS_ERR_OR_NULL(nf)) { in __nfsd_file_cache_purge()
845 if (!net || nf->nf_net == net) in __nfsd_file_cache_purge()
846 nfsd_file_cond_queue(nf, &dispose); in __nfsd_file_cache_purge()
847 nf = rhashtable_walk_next(&iter); in __nfsd_file_cache_purge()
851 } while (nf == ERR_PTR(-EAGAIN)); in __nfsd_file_cache_purge()
959 struct nfsd_file *nf; in nfsd_file_lookup_locked() local
963 rhl_for_each_entry_rcu(nf, tmp, list, nf_rlist) { in nfsd_file_lookup_locked()
964 if (nf->nf_may != need) in nfsd_file_lookup_locked()
966 if (nf->nf_net != net) in nfsd_file_lookup_locked()
968 if (!nfsd_match_cred(nf->nf_cred, cred)) in nfsd_file_lookup_locked()
970 if (test_bit(NFSD_FILE_GC, &nf->nf_flags) != want_gc) in nfsd_file_lookup_locked()
972 if (test_bit(NFSD_FILE_HASHED, &nf->nf_flags) == 0) in nfsd_file_lookup_locked()
975 if (!nfsd_file_get(nf)) in nfsd_file_lookup_locked()
977 return nf; in nfsd_file_lookup_locked()
997 struct nfsd_file *nf; in nfsd_file_is_cached() local
1003 rhl_for_each_entry_rcu(nf, tmp, list, nf_rlist) in nfsd_file_is_cached()
1004 if (test_bit(NFSD_FILE_GC, &nf->nf_flags)) { in nfsd_file_is_cached()
1023 struct nfsd_file *new, *nf; in nfsd_file_do_acquire() local
1043 nf = nfsd_file_lookup_locked(net, current_cred(), inode, need, want_gc); in nfsd_file_do_acquire()
1046 if (nf) { in nfsd_file_do_acquire()
1048 * If the nf is on the LRU then it holds an extra reference in nfsd_file_do_acquire()
1052 if (nfsd_file_lru_remove(nf)) in nfsd_file_do_acquire()
1053 WARN_ON_ONCE(refcount_dec_and_test(&nf->nf_ref)); in nfsd_file_do_acquire()
1065 nf = nfsd_file_lookup_locked(net, current_cred(), inode, need, want_gc); in nfsd_file_do_acquire()
1066 if (unlikely(nf)) { in nfsd_file_do_acquire()
1072 nf = new; in nfsd_file_do_acquire()
1073 ret = rhltable_insert(&nfsd_file_rhltable, &nf->nf_rlist, in nfsd_file_do_acquire()
1085 wait_on_bit(&nf->nf_flags, NFSD_FILE_PENDING, TASK_UNINTERRUPTIBLE); in nfsd_file_do_acquire()
1088 if (!test_bit(NFSD_FILE_HASHED, &nf->nf_flags)) { in nfsd_file_do_acquire()
1089 trace_nfsd_file_cons_err(rqstp, inode, may_flags, nf); in nfsd_file_do_acquire()
1094 nfsd_file_put(nf); in nfsd_file_do_acquire()
1101 status = nfserrno(nfsd_open_break_lease(file_inode(nf->nf_file), may_flags)); in nfsd_file_do_acquire()
1103 nfsd_file_put(nf); in nfsd_file_do_acquire()
1104 nf = NULL; in nfsd_file_do_acquire()
1110 nfsd_file_check_write_error(nf); in nfsd_file_do_acquire()
1111 *pnf = nf; in nfsd_file_do_acquire()
1113 trace_nfsd_file_acquire(rqstp, inode, may_flags, nf, status); in nfsd_file_do_acquire()
1117 trace_nfsd_file_alloc(nf); in nfsd_file_do_acquire()
1118 nf->nf_mark = nfsd_file_mark_find_or_create(inode); in nfsd_file_do_acquire()
1119 if (nf->nf_mark) { in nfsd_file_do_acquire()
1122 nf->nf_file = file; in nfsd_file_do_acquire()
1124 trace_nfsd_file_opened(nf, status); in nfsd_file_do_acquire()
1127 &nf->nf_file); in nfsd_file_do_acquire()
1130 nfsd_file_unhash(nf); in nfsd_file_do_acquire()
1132 &nf->nf_flags); in nfsd_file_do_acquire()
1133 if (refcount_dec_and_test(&nf->nf_ref)) in nfsd_file_do_acquire()
1134 nfsd_file_free(nf); in nfsd_file_do_acquire()
1135 nf = NULL; in nfsd_file_do_acquire()
1140 trace_nfsd_file_open(nf, status); in nfsd_file_do_acquire()
1149 nfsd_file_unhash(nf); in nfsd_file_do_acquire()
1150 clear_and_wake_up_bit(NFSD_FILE_PENDING, &nf->nf_flags); in nfsd_file_do_acquire()
1155 if (refcount_dec_and_test(&nf->nf_ref)) in nfsd_file_do_acquire()
1156 nfsd_file_free(nf); in nfsd_file_do_acquire()
1157 nf = NULL; in nfsd_file_do_acquire()