Skip to content

Commit f77ce2e

Browse files
neilbrownchucklever
authored andcommitted
nfsd: filecache: remove race handling.
The race that this code tries to protect against is not interesting. The code is problematic as we access the "nf" after we have given our reference to the lru system. While that takes 2+ seconds to free things, it is still poor form. The only interesting race I can find would be with nfsd_file_close_inode_sync(); This is the only place that really doesn't want the file to stay on the LRU when unhashed (which is the direct consequence of the race). However for the race to happen, some other thread must own a reference to a file and be putting it while nfsd_file_close_inode_sync() is trying to close all files for an inode. If this is possible, that other thread could simply call nfsd_file_put() a little bit later and the result would be the same: not all files are closed when nfsd_file_close_inode_sync() completes. If this was really a problem, we would need to wait in close_inode_sync for the other references to be dropped. We probably don't want to do that. So it is best to simply remove this code. Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent dfd500d commit f77ce2e

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

fs/nfsd/filecache.c

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -370,22 +370,8 @@ nfsd_file_put(struct nfsd_file *nf)
370370
if (refcount_dec_not_one(&nf->nf_ref))
371371
return;
372372

373-
/* Try to add it to the LRU. If that fails, decrement. */
374-
if (nfsd_file_lru_add(nf)) {
375-
/* If it's still hashed, we're done */
376-
if (test_bit(NFSD_FILE_HASHED, &nf->nf_flags)) {
377-
nfsd_file_schedule_laundrette();
378-
return;
379-
}
380-
381-
/*
382-
* We're racing with unhashing, so try to remove it from
383-
* the LRU. If removal fails, then someone else already
384-
* has our reference.
385-
*/
386-
if (!nfsd_file_lru_remove(nf))
387-
return;
388-
}
373+
if (nfsd_file_lru_add(nf))
374+
return;
389375
}
390376
if (refcount_dec_and_test(&nf->nf_ref))
391377
nfsd_file_free(nf);

0 commit comments

Comments
 (0)