[PATCH] nfs: avoid possible deadlock bug when setting up delegation.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Unlock clp->cl_lock before taking inode->i_lock when setting up
delegation to avoid possible deadlock bug.

Signed-off-by: Tao Guo <guotao@xxxxxxxxxxxx>
---
 fs/nfs/delegation.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index ea61d26..0983930 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -233,6 +233,7 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct
 		if (memcmp(&delegation->stateid, &old_delegation->stateid,
 					sizeof(old_delegation->stateid)) == 0 &&
 				delegation->type == old_delegation->type) {
+			spin_unlock(&clp->cl_lock);
 			goto out;
 		}
 		/*
@@ -245,6 +246,7 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct
 		if (delegation->type <= old_delegation->type) {
 			freeme = delegation;
 			delegation = NULL;
+			spin_unlock(&clp->cl_lock);
 			goto out;
 		}
 		freeme = nfs_detach_delegation_locked(nfsi, NULL, clp);
@@ -253,6 +255,7 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct
 	nfsi->delegation_state = delegation->type;
 	rcu_assign_pointer(nfsi->delegation, delegation);
 	delegation = NULL;
+	spin_unlock(&clp->cl_lock);
 
 	/* Ensure we revalidate the attributes and page cache! */
 	spin_lock(&inode->i_lock);
@@ -260,7 +263,6 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct
 	spin_unlock(&inode->i_lock);
 
 out:
-	spin_unlock(&clp->cl_lock);
 	if (delegation != NULL)
 		nfs_free_delegation(delegation);
 	if (freeme != NULL)
-- 
1.6.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux