OSDN Git Service

NFS: Clear NFS_DELEGATION_RETURN_IF_CLOSED when the delegation is returned
authorTrond Myklebust <trondmy@gmail.com>
Mon, 27 Jan 2020 14:58:16 +0000 (09:58 -0500)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Mon, 3 Feb 2020 21:35:07 +0000 (16:35 -0500)
If a delegation is marked as needing to be returned when the file is
closed, then don't clear that marking until we're ready to return
it.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
fs/nfs/delegation.c

index a7e4272..b5b1461 100644 (file)
@@ -479,7 +479,7 @@ static bool nfs_delegation_need_return(struct nfs_delegation *delegation)
 
        if (test_and_clear_bit(NFS_DELEGATION_RETURN, &delegation->flags))
                ret = true;
-       if (test_and_clear_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags) && !ret) {
+       else if (test_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags)) {
                struct inode *inode;
 
                spin_lock(&delegation->lock);
@@ -488,6 +488,8 @@ static bool nfs_delegation_need_return(struct nfs_delegation *delegation)
                        ret = true;
                spin_unlock(&delegation->lock);
        }
+       if (ret)
+               clear_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags);
        if (test_bit(NFS_DELEGATION_RETURNING, &delegation->flags) ||
            test_bit(NFS_DELEGATION_REVOKED, &delegation->flags))
                ret = false;