]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
nfsd: Clean up nfsd_file_put()
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Thu, 31 Mar 2022 13:54:02 +0000 (09:54 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Apr 2024 14:19:02 +0000 (16:19 +0200)
[ Upstream commit 999397926ab3f78c7d1235cc4ca6e3c89d2769bf ]

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>
fs/nfsd/filecache.c

index 6cde6ef68996e1e0d6a213a372f0b37218efa291..429ae485ebbbef2d984f3052b01b3b943a2acea4 100644 (file)
@@ -295,21 +295,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();