Lines Matching refs:nf

85 	struct nfsd_file *nf = container_of(rcu, struct nfsd_file, nf_rcu);
87 put_cred(nf->nf_cred);
88 kmem_cache_free(nfsd_file_slab, nf);
118 nfsd_file_mark_find_or_create(struct nfsd_file *nf)
123 struct inode *inode = nf->nf_inode;
176 struct nfsd_file *nf;
178 nf = kmem_cache_alloc(nfsd_file_slab, GFP_KERNEL);
179 if (nf) {
180 INIT_HLIST_NODE(&nf->nf_node);
181 INIT_LIST_HEAD(&nf->nf_lru);
182 nf->nf_file = NULL;
183 nf->nf_cred = get_current_cred();
184 nf->nf_net = net;
185 nf->nf_flags = 0;
186 nf->nf_inode = inode;
187 nf->nf_hashval = hashval;
188 refcount_set(&nf->nf_ref, 1);
189 nf->nf_may = may & NFSD_FILE_MAY_MASK;
192 __set_bit(NFSD_FILE_BREAK_WRITE, &nf->nf_flags);
194 __set_bit(NFSD_FILE_BREAK_READ, &nf->nf_flags);
196 nf->nf_mark = NULL;
197 trace_nfsd_file_alloc(nf);
199 return nf;
203 nfsd_file_free(struct nfsd_file *nf)
207 trace_nfsd_file_put_final(nf);
208 if (nf->nf_mark)
209 nfsd_file_mark_put(nf->nf_mark);
210 if (nf->nf_file) {
211 get_file(nf->nf_file);
212 filp_close(nf->nf_file, NULL);
213 fput(nf->nf_file);
216 call_rcu(&nf->nf_rcu, nfsd_file_slab_free);
221 nfsd_file_check_writeback(struct nfsd_file *nf)
223 struct file *file = nf->nf_file;
234 nfsd_file_check_write_error(struct nfsd_file *nf)
236 struct file *file = nf->nf_file;
244 nfsd_file_do_unhash(struct nfsd_file *nf)
246 lockdep_assert_held(&nfsd_file_hashtbl[nf->nf_hashval].nfb_lock);
248 trace_nfsd_file_unhash(nf);
250 if (nfsd_file_check_write_error(nf))
251 nfsd_reset_boot_verifier(net_generic(nf->nf_net, nfsd_net_id));
252 --nfsd_file_hashtbl[nf->nf_hashval].nfb_count;
253 hlist_del_rcu(&nf->nf_node);
258 nfsd_file_unhash(struct nfsd_file *nf)
260 if (test_and_clear_bit(NFSD_FILE_HASHED, &nf->nf_flags)) {
261 nfsd_file_do_unhash(nf);
262 if (!list_empty(&nf->nf_lru))
263 list_lru_del(&nfsd_file_lru, &nf->nf_lru);
273 nfsd_file_unhash_and_release_locked(struct nfsd_file *nf, struct list_head *dispose)
275 lockdep_assert_held(&nfsd_file_hashtbl[nf->nf_hashval].nfb_lock);
277 trace_nfsd_file_unhash_and_release_locked(nf);
278 if (!nfsd_file_unhash(nf))
281 if (refcount_dec_not_one(&nf->nf_ref))
284 list_add(&nf->nf_lru, dispose);
289 nfsd_file_put_noref(struct nfsd_file *nf)
291 trace_nfsd_file_put(nf);
293 if (refcount_dec_and_test(&nf->nf_ref)) {
294 WARN_ON(test_bit(NFSD_FILE_HASHED, &nf->nf_flags));
295 nfsd_file_free(nf);
300 nfsd_file_put(struct nfsd_file *nf)
304 set_bit(NFSD_FILE_REFERENCED, &nf->nf_flags);
305 if (refcount_read(&nf->nf_ref) > 2 || !nf->nf_file) {
306 nfsd_file_put_noref(nf);
310 filemap_flush(nf->nf_file->f_mapping);
311 is_hashed = test_bit(NFSD_FILE_HASHED, &nf->nf_flags) != 0;
312 nfsd_file_put_noref(nf);
320 nfsd_file_get(struct nfsd_file *nf)
322 if (likely(refcount_inc_not_zero(&nf->nf_ref)))
323 return nf;
330 struct nfsd_file *nf;
333 nf = list_first_entry(dispose, struct nfsd_file, nf_lru);
334 list_del(&nf->nf_lru);
335 nfsd_file_put_noref(nf);
343 struct nfsd_file *nf;
346 nf = list_first_entry(dispose, struct nfsd_file, nf_lru);
347 list_del(&nf->nf_lru);
348 if (!refcount_dec_and_test(&nf->nf_ref))
350 if (nfsd_file_free(nf))
388 struct nfsd_file *nf, *tmp;
390 list_for_each_entry_safe(nf, tmp, src, nf_lru) {
391 if (nf->nf_net == net)
392 list_move_tail(&nf->nf_lru, dst);
400 struct nfsd_file *nf;
403 nf = list_first_entry(dispose, struct nfsd_file, nf_lru);
404 nfsd_file_list_add_pernet(&list, dispose, nf->nf_net);
405 nfsd_file_list_add_disposal(&list, nf->nf_net);
419 struct nfsd_file *nf = list_entry(item, struct nfsd_file, nf_lru);
431 if (refcount_read(&nf->nf_ref) > 1)
438 if (nfsd_file_check_writeback(nf))
441 if (test_and_clear_bit(NFSD_FILE_REFERENCED, &nf->nf_flags))
444 if (!test_and_clear_bit(NFSD_FILE_HASHED, &nf->nf_flags))
447 list_lru_isolate_move(lru, &nf->nf_lru, head);
457 struct nfsd_file *nf;
467 list_for_each_entry(nf, &head, nf_lru) {
468 spin_lock(&nfsd_file_hashtbl[nf->nf_hashval].nfb_lock);
469 nfsd_file_do_unhash(nf);
470 spin_unlock(&nfsd_file_hashtbl[nf->nf_hashval].nfb_lock);
511 struct nfsd_file *nf;
515 hlist_for_each_entry_safe(nf, tmp, &nfsd_file_hashtbl[hashval].nfb_head, nf_node) {
516 if (inode == nf->nf_inode)
517 nfsd_file_unhash_and_release_locked(nf, dispose);
724 struct nfsd_file *nf;
736 hlist_for_each_entry_safe(nf, next, &nfb->nfb_head, nf_node) {
737 if (net && nf->nf_net != net)
739 del = nfsd_file_unhash_and_release_locked(nf, &dispose);
886 struct nfsd_file *nf;
889 hlist_for_each_entry_rcu(nf, &nfsd_file_hashtbl[hashval].nfb_head,
891 if (nf->nf_may != need)
893 if (nf->nf_inode != inode)
895 if (nf->nf_net != net)
897 if (!nfsd_match_cred(nf->nf_cred, current_cred()))
899 if (!test_bit(NFSD_FILE_HASHED, &nf->nf_flags))
901 if (nfsd_file_get(nf) != NULL)
902 return nf;
918 struct nfsd_file *nf;
924 hlist_for_each_entry_rcu(nf, &nfsd_file_hashtbl[hashval].nfb_head,
926 if (inode == nf->nf_inode) {
942 struct nfsd_file *nf, *new;
957 nf = nfsd_file_find_locked(inode, may_flags, hashval, net);
959 if (nf)
970 nf = nfsd_file_find_locked(inode, may_flags, hashval, net);
971 if (nf == NULL)
977 wait_on_bit(&nf->nf_flags, NFSD_FILE_PENDING, TASK_UNINTERRUPTIBLE);
980 if (!test_bit(NFSD_FILE_HASHED, &nf->nf_flags)) {
986 nfsd_file_put_noref(nf);
995 if (test_bit(NFSD_FILE_BREAK_READ, &nf->nf_flags) ||
996 (test_bit(NFSD_FILE_BREAK_WRITE, &nf->nf_flags) && write)) {
998 file_inode(nf->nf_file), may_flags));
1000 clear_bit(NFSD_FILE_BREAK_READ, &nf->nf_flags);
1003 &nf->nf_flags);
1009 *pnf = nf;
1011 nfsd_file_put(nf);
1012 nf = NULL;
1015 trace_nfsd_file_acquire(rqstp, hashval, inode, may_flags, nf, status);
1018 nf = new;
1020 refcount_inc(&nf->nf_ref);
1021 __set_bit(NFSD_FILE_HASHED, &nf->nf_flags);
1022 __set_bit(NFSD_FILE_PENDING, &nf->nf_flags);
1023 list_lru_add(&nfsd_file_lru, &nf->nf_lru);
1024 hlist_add_head_rcu(&nf->nf_node, &nfsd_file_hashtbl[hashval].nfb_head);
1032 nf->nf_mark = nfsd_file_mark_find_or_create(nf);
1033 if (nf->nf_mark)
1035 may_flags, &nf->nf_file);
1045 do_free = nfsd_file_unhash(nf);
1048 nfsd_file_put_noref(nf);
1050 clear_bit_unlock(NFSD_FILE_PENDING, &nf->nf_flags);
1052 wake_up_bit(&nf->nf_flags, NFSD_FILE_PENDING);