nfs: avoid possible deadlock bug when setting up delegation.
Subsystems (2)
PATCH 1/1 nfs: avoid possible deadlock bug when setting up delegation.
Unlock clp->cl_lock before taking inode->i_lock when setting up delegation to avoid possible deadlock bug.
--- fs/nfs/delegation.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
fs/nfs/delegation.c +3 -1
@@ -233,6 +233,7 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, structif (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, structif (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, structspin_unlock (&inode->i_lock); out: -spin_unlock (&clp->cl_lock);if (delegation !=NULL )nfs_free_delegation (delegation);if (freeme !=NULL )
Signature · 1 line
1.6.3.3
Quoted 2 lines · Tao Guo
Unlock
clp->cl_lockbefore takinginode->i_lockwhen setting up delegation to avoid possible deadlock bug.
What deadlock? inode->i_lock should always be the innermost lock, so it should always be safe to take it while already holding the nfs_client lock.
If somebody is taking the nfs_client lock while holding the inode lock, then that would be the deadlock bug that needs to be fixed.
Trond
A message that is not in the archive (sent off-list or not yet received): 1274360236.2949.1.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org
Quoted 5 lines · Trond Myklebust
Quoted 2 lines · Tao Guo
Unlock
clp->cl_lockbefore takinginode->i_lockwhen setting up delegation to avoid possible deadlock bug.What deadlock?
inode->i_lockshould always be the innermost lock, so =
it
Quoted 2 lines
should always be safe to take it while already holding the
nfs_clientlock.
here is: http://marc.info/?l=3Dlinux-nfs&m=3D127424502009958&w=3D2
Quoted 2 lines
If somebody is taking the
nfs_clientlock while holding the inode loc=
k,
Quoted 2 lines
then that would be the deadlock bug that needs to be fixed.
mm, I will reconsider that carefully~
Quoted 4 lines
Trond
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" =
in
Quoted 2 lines
the body of a message to [email protected]
More majordomo info at =C2=A0http://vger.kernel.org/majordomo-info.ht=
ml
Quoted 1 line
--=20
tao.
A message that is not in the archive (sent off-list or not yet received): AANLkTilrfrlhyJ7G8jy6X9emrGIGnEAxFjqlYns8K0OT-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 11 lines · Tao Guo
Quoted 7 lines · Trond Myklebust
Quoted 2 lines · Tao Guo
Unlock
clp->cl_lockbefore takinginode->i_lockwhen setting up delegation to avoid possible deadlock bug.What deadlock?
inode->i_lockshould always be the innermost lock, so it should always be safe to take it while already holding thenfs_clientlock.here is: http://marc.info/?l=linux-nfs&m=127424502009958&w=2
Quoted 1 line
That would be a pnfs bug... Please fix it so that it adheres to the locking rules in mainline.
Trond