nfsd: simplify put of fi_deleg_file
authorJ. Bruce Fields <bfields@redhat.com>
Thu, 15 Feb 2018 20:29:15 +0000 (15:29 -0500)
committerJ. Bruce Fields <bfields@redhat.com>
Tue, 20 Mar 2018 21:51:10 +0000 (17:51 -0400)
fi_delegees is basically just a reference count on users of
fi_deleg_file, which is cleared when fi_delegees goes to zero.  The
fi_deleg_file check here is redundant.  Also add an assertion to make
sure we don't have unbalanced puts.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
fs/nfsd/nfs4state.c

index 16efbe2b18535d9cc682f9ca07fcaecceb7dfb5a..9072d0f8340b530d3bf203d11980c616ff7254c0 100644 (file)
@@ -879,9 +879,12 @@ static void nfs4_put_deleg_lease(struct nfs4_file *fp)
 {
        struct file *filp = NULL;
 
+       WARN_ON_ONCE(!fp->fi_delegees);
+
        spin_lock(&fp->fi_lock);
-       if (fp->fi_deleg_file && --fp->fi_delegees == 0)
+       if (--fp->fi_delegees == 0) {
                swap(filp, fp->fi_deleg_file);
+       }
        spin_unlock(&fp->fi_lock);
 
        if (filp) {