From: Tao Guo <guotao-U4AKAne5IzAR5TUyvShJeg@public.gmane.org>
To: linux-nfs@vger.kernel.org
Cc: "J. Bruce Fields" <bfields@fieldses.org>,
Benny Halevy <bhalevy@panasas.com>
Subject: [PATCH] nfs: avoid possible deadlock bug when setting up delegation.
Date: Thu, 20 May 2010 13:42:24 +0800 [thread overview]
Message-ID: <20100520054216.GA27457@vmware> (raw)
Unlock clp->cl_lock before taking inode->i_lock when setting up
delegation to avoid possible deadlock bug.
Signed-off-by: Tao Guo <guotao-U4AKAne5IzAR5TUyvShJeg@public.gmane.org>
---
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
next reply other threads:[~2010-05-20 5:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-20 5:42 Tao Guo [this message]
2010-05-20 12:57 ` [PATCH] nfs: avoid possible deadlock bug when setting up delegation Trond Myklebust
[not found] ` <1274360236.2949.1.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2010-05-20 13:20 ` Tao Guo
[not found] ` <AANLkTilrfrlhyJ7G8jy6X9emrGIGnEAxFjqlYns8K0OT-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-05-20 13:47 ` Trond Myklebust
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100520054216.GA27457@vmware \
--to=guotao-u4akane5izar5tuyvshjeg@public.gmane.org \
--cc=bfields@fieldses.org \
--cc=bhalevy@panasas.com \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).