Lines Matching refs:nf

124 	struct nfsd_file *nf = container_of(rcu, struct nfsd_file, nf_rcu);
126 put_cred(nf->nf_cred);
127 kmem_cache_free(nfsd_file_slab, nf);
157 nfsd_file_mark_find_or_create(struct nfsd_file *nf, struct inode *inode)
215 struct nfsd_file *nf;
217 nf = kmem_cache_alloc(nfsd_file_slab, GFP_KERNEL);
218 if (unlikely(!nf))
221 INIT_LIST_HEAD(&nf->nf_lru);
222 nf->nf_birthtime = ktime_get();
223 nf->nf_file = NULL;
224 nf->nf_cred = get_current_cred();
225 nf->nf_net = net;
226 nf->nf_flags = want_gc ?
229 nf->nf_inode = inode;
230 refcount_set(&nf->nf_ref, 1);
231 nf->nf_may = need;
232 nf->nf_mark = NULL;
233 return nf;
238 * @nf: nfsd_file to check for writeback errors
244 nfsd_file_check_write_error(struct nfsd_file *nf)
246 struct file *file = nf->nf_file;
250 nfsd_reset_write_verifier(net_generic(nf->nf_net, nfsd_net_id));
254 nfsd_file_hash_remove(struct nfsd_file *nf)
256 trace_nfsd_file_unhash(nf);
257 rhltable_remove(&nfsd_file_rhltable, &nf->nf_rlist,
262 nfsd_file_unhash(struct nfsd_file *nf)
264 if (test_and_clear_bit(NFSD_FILE_HASHED, &nf->nf_flags)) {
265 nfsd_file_hash_remove(nf);
272 nfsd_file_free(struct nfsd_file *nf)
274 s64 age = ktime_to_ms(ktime_sub(ktime_get(), nf->nf_birthtime));
276 trace_nfsd_file_free(nf);
281 nfsd_file_unhash(nf);
282 if (nf->nf_mark)
283 nfsd_file_mark_put(nf->nf_mark);
284 if (nf->nf_file) {
285 nfsd_file_check_write_error(nf);
286 filp_close(nf->nf_file, NULL);
293 if (WARN_ON_ONCE(!list_empty(&nf->nf_lru)))
296 call_rcu(&nf->nf_rcu, nfsd_file_slab_free);
300 nfsd_file_check_writeback(struct nfsd_file *nf)
302 struct file *file = nf->nf_file;
322 static bool nfsd_file_lru_add(struct nfsd_file *nf)
324 set_bit(NFSD_FILE_REFERENCED, &nf->nf_flags);
325 if (list_lru_add(&nfsd_file_lru, &nf->nf_lru)) {
326 trace_nfsd_file_lru_add(nf);
332 static bool nfsd_file_lru_remove(struct nfsd_file *nf)
334 if (list_lru_del(&nfsd_file_lru, &nf->nf_lru)) {
335 trace_nfsd_file_lru_del(nf);
342 nfsd_file_get(struct nfsd_file *nf)
344 if (nf && refcount_inc_not_zero(&nf->nf_ref))
345 return nf;
351 * @nf: nfsd_file of which to put the reference
358 nfsd_file_put(struct nfsd_file *nf)
361 trace_nfsd_file_put(nf);
363 if (test_bit(NFSD_FILE_GC, &nf->nf_flags) &&
364 test_bit(NFSD_FILE_HASHED, &nf->nf_flags)) {
369 if (refcount_dec_not_one(&nf->nf_ref))
373 if (nfsd_file_lru_add(nf)) {
375 if (test_bit(NFSD_FILE_HASHED, &nf->nf_flags)) {
385 if (!nfsd_file_lru_remove(nf))
389 if (refcount_dec_and_test(&nf->nf_ref))
390 nfsd_file_free(nf);
396 struct nfsd_file *nf;
399 nf = list_first_entry(dispose, struct nfsd_file, nf_lru);
400 list_del_init(&nf->nf_lru);
401 nfsd_file_free(nf);
416 struct nfsd_file *nf = list_first_entry(dispose,
418 struct nfsd_net *nn = net_generic(nf->nf_net, nfsd_net_id);
422 list_move_tail(&nf->nf_lru, &l->freeme);
447 struct nfsd_file *nf = list_entry(item, struct nfsd_file, nf_lru);
450 WARN_ON_ONCE(!test_bit(NFSD_FILE_GC, &nf->nf_flags));
456 if (nfsd_file_check_writeback(nf)) {
457 trace_nfsd_file_gc_writeback(nf);
462 if (test_and_clear_bit(NFSD_FILE_REFERENCED, &nf->nf_flags)) {
463 trace_nfsd_file_gc_referenced(nf);
471 if (!refcount_dec_and_test(&nf->nf_ref)) {
472 trace_nfsd_file_gc_in_use(nf);
473 list_lru_isolate(lru, &nf->nf_lru);
478 nfsd_file_unhash(nf);
479 list_lru_isolate_move(lru, &nf->nf_lru, head);
481 trace_nfsd_file_gc_disposed(nf);
532 * @nf: nfsd_file to attempt to queue
539 nfsd_file_cond_queue(struct nfsd_file *nf, struct list_head *dispose)
545 if (!nfsd_file_unhash(nf))
549 if (!nfsd_file_get(nf))
553 if (nfsd_file_lru_remove(nf))
557 if (refcount_sub_and_test(decrement, &nf->nf_ref)) {
558 list_add(&nf->nf_lru, dispose);
559 trace_nfsd_file_closing(nf);
583 struct nfsd_file *nf;
588 rhl_for_each_entry_rcu(nf, tmp, list, nf_rlist) {
589 if (!test_bit(NFSD_FILE_GC, &nf->nf_flags))
591 nfsd_file_cond_queue(nf, dispose);
627 struct nfsd_file *nf;
634 nf = list_first_entry(&dispose, struct nfsd_file, nf_lru);
635 list_del_init(&nf->nf_lru);
636 nfsd_file_free(nf);
803 struct nfsd_file *nf;
810 nf = rhashtable_walk_next(&iter);
811 while (!IS_ERR_OR_NULL(nf)) {
812 if (!net || nf->nf_net == net)
813 nfsd_file_cond_queue(nf, &dispose);
814 nf = rhashtable_walk_next(&iter);
818 } while (nf == ERR_PTR(-EAGAIN));
929 struct nfsd_file *nf;
933 rhl_for_each_entry_rcu(nf, tmp, list, nf_rlist) {
934 if (nf->nf_may != need)
936 if (nf->nf_net != net)
938 if (!nfsd_match_cred(nf->nf_cred, cred))
940 if (test_bit(NFSD_FILE_GC, &nf->nf_flags) != want_gc)
942 if (test_bit(NFSD_FILE_HASHED, &nf->nf_flags) == 0)
945 if (!nfsd_file_get(nf))
947 return nf;
967 struct nfsd_file *nf;
973 rhl_for_each_entry_rcu(nf, tmp, list, nf_rlist)
974 if (test_bit(NFSD_FILE_GC, &nf->nf_flags)) {
991 struct nfsd_file *new, *nf;
1006 nf = nfsd_file_lookup_locked(net, current_cred(), inode, need, want_gc);
1009 if (nf) {
1011 * If the nf is on the LRU then it holds an extra reference
1015 if (nfsd_file_lru_remove(nf))
1016 WARN_ON_ONCE(refcount_dec_and_test(&nf->nf_ref));
1028 nf = nfsd_file_lookup_locked(net, current_cred(), inode, need, want_gc);
1029 if (unlikely(nf)) {
1035 nf = new;
1036 ret = rhltable_insert(&nfsd_file_rhltable, &nf->nf_rlist,
1050 wait_on_bit(&nf->nf_flags, NFSD_FILE_PENDING, TASK_UNINTERRUPTIBLE);
1053 if (!test_bit(NFSD_FILE_HASHED, &nf->nf_flags)) {
1054 trace_nfsd_file_cons_err(rqstp, inode, may_flags, nf);
1065 status = nfserrno(nfsd_open_break_lease(file_inode(nf->nf_file), may_flags));
1067 nfsd_file_put(nf);
1068 nf = NULL;
1074 nfsd_file_check_write_error(nf);
1075 *pnf = nf;
1077 trace_nfsd_file_acquire(rqstp, inode, may_flags, nf, status);
1081 trace_nfsd_file_alloc(nf);
1082 nf->nf_mark = nfsd_file_mark_find_or_create(nf, inode);
1083 if (nf->nf_mark) {
1086 nf->nf_file = file;
1088 trace_nfsd_file_opened(nf, status);
1091 &nf->nf_file);
1094 nfsd_file_unhash(nf);
1096 &nf->nf_flags);
1097 if (refcount_dec_and_test(&nf->nf_ref))
1098 nfsd_file_free(nf);
1099 nf = NULL;
1104 trace_nfsd_file_open(nf, status);
1113 nfsd_file_unhash(nf);
1114 clear_and_wake_up_bit(NFSD_FILE_PENDING, &nf->nf_flags);
1119 if (refcount_dec_and_test(&nf->nf_ref))
1120 nfsd_file_free(nf);
1121 nf = NULL;