VFS: Fix the nfs sillyrename regression in kernel 2.6.38
The new vfs locking scheme introduced in 2.6.38 breaks NFS sillyrename
because the latter relies on being able to determine the parent
directory of the dentry in the ->iput() callback in order to send the
appropriate unlink rpc call.
Looking at the code that cares about races with dput(), there doesn't
seem to be anything that specifically uses d_parent as a test for
whether or not there is a race:
- __d_lookup_rcu(), __d_lookup() all test for d_hashed() after d_parent
- shrink_dcache_for_umount() is safe since nothing else can rearrange
the dentries in that super block.
- have_submount(), select_parent() and d_genocide() can test for a
deletion if we set the DCACHE_DISCONNECTED flag when the dentry
is removed from the parent's d_subdirs list.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: stable@kernel.org (2.6.38, needs commit c826cb7dfc
"dcache.c:
create helper function for duplicated functionality" )
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
c826cb7dfc
commit
c83ce989cb
|
@ -296,8 +296,12 @@ static struct dentry *d_kill(struct dentry *dentry, struct dentry *parent)
|
||||||
__releases(parent->d_lock)
|
__releases(parent->d_lock)
|
||||||
__releases(dentry->d_inode->i_lock)
|
__releases(dentry->d_inode->i_lock)
|
||||||
{
|
{
|
||||||
dentry->d_parent = NULL;
|
|
||||||
list_del(&dentry->d_u.d_child);
|
list_del(&dentry->d_u.d_child);
|
||||||
|
/*
|
||||||
|
* Inform try_to_ascend() that we are no longer attached to the
|
||||||
|
* dentry tree
|
||||||
|
*/
|
||||||
|
dentry->d_flags |= DCACHE_DISCONNECTED;
|
||||||
if (parent)
|
if (parent)
|
||||||
spin_unlock(&parent->d_lock);
|
spin_unlock(&parent->d_lock);
|
||||||
dentry_iput(dentry);
|
dentry_iput(dentry);
|
||||||
|
@ -1030,6 +1034,7 @@ static struct dentry *try_to_ascend(struct dentry *old, int locked, unsigned seq
|
||||||
* or deletion
|
* or deletion
|
||||||
*/
|
*/
|
||||||
if (new != old->d_parent ||
|
if (new != old->d_parent ||
|
||||||
|
(old->d_flags & DCACHE_DISCONNECTED) ||
|
||||||
(!locked && read_seqretry(&rename_lock, seq))) {
|
(!locked && read_seqretry(&rename_lock, seq))) {
|
||||||
spin_unlock(&new->d_lock);
|
spin_unlock(&new->d_lock);
|
||||||
new = NULL;
|
new = NULL;
|
||||||
|
|
Loading…
Reference in New Issue