summaryrefslogtreecommitdiff
path: root/fs/nfsd
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@hammerspace.com>2022-03-31 09:54:02 -0400
committerChuck Lever <chuck.lever@oracle.com>2022-03-31 10:39:59 -0400
commit999397926ab3f78c7d1235cc4ca6e3c89d2769bf (patch)
tree3874a20ce5217c531fb74f3ff7c92469973892dd /fs/nfsd
parent6b8a94332ee4f7d9a8ae0cbac7609f79c212f06c (diff)
nfsd: Clean up nfsd_file_put()
Make it a little less racy, by removing the refcount_read() test. Then remove the redundant 'is_hashed' variable. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Diffstat (limited to 'fs/nfsd')
-rw-r--r--fs/nfsd/filecache.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c
index 496f7b3f7523..8f7ed5dbb003 100644
--- a/fs/nfsd/filecache.c
+++ b/fs/nfsd/filecache.c
@@ -301,21 +301,14 @@ nfsd_file_put_noref(struct nfsd_file *nf)
void
nfsd_file_put(struct nfsd_file *nf)
{
- bool is_hashed;
-
set_bit(NFSD_FILE_REFERENCED, &nf->nf_flags);
- if (refcount_read(&nf->nf_ref) > 2 || !nf->nf_file) {
- nfsd_file_put_noref(nf);
- return;
- }
-
- is_hashed = test_bit(NFSD_FILE_HASHED, &nf->nf_flags) != 0;
- if (!is_hashed) {
+ if (test_bit(NFSD_FILE_HASHED, &nf->nf_flags) == 0) {
nfsd_file_flush(nf);
nfsd_file_put_noref(nf);
} else {
nfsd_file_put_noref(nf);
- nfsd_file_schedule_laundrette();
+ if (nf->nf_file)
+ nfsd_file_schedule_laundrette();
}
if (atomic_long_read(&nfsd_filecache_count) >= NFSD_FILE_LRU_LIMIT)
nfsd_file_gc();