Skip to contentSkip to conversation

fs: Work around NFS wreckage

PATCH In review Thomas Gleixner 6 participants 12 messages Jan 13, 2011 – Jan 14, 2011 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs: Work around NFS wreckage

The dcache scalability work broke NFS root filesystems.

"cd /" results in the following problem:

    link_path_walk("/",...);
	jumps to return_reval
	need_reval_dot() returns true for NFS
	d_revalidate()
		dentry->d_op->d_revalidate(dentry, nd);
		 	returns -ECHILD due to nd->flags & LOOKUP_RCU
		nameidata_dentry_drop_rcu()
			spin_lock(&parent->d_lock);
			spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED);

			This deadlocks because dentry == parent

This problem exists for any filesystem which implements d_revalidate.

Uwe bisected is down to commit 34286d6(fs: rcu-walk aware d_revalidate method), but reverting that patch causes different wreckage to show up.

Check for parent equal dentry and skip the nested lock to avoid the deadlock. I'm sure this is the wrong fix, but at least it "works" :)

---
 fs/namei.c |    4 ++++
 1 file changed, 4 insertions(+)
fs/namei.c +4 -0
Index: linux-2.6/fs/namei.c
===================================================================
@@ -487,6 +487,8 @@ static int nameidata_dentry_drop_rcu(str
 			goto err_root;
 	}
 	spin_lock(&parent->d_lock);
+	if (parent == dentry)
+		goto same;
 	spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED);
 	if (!__d_rcu_to_refcount(dentry, nd->seq))
 		goto err;
@@ -499,6 +501,8 @@ static int nameidata_dentry_drop_rcu(str
 	BUG_ON(!parent->d_count);
 	parent->d_count++;
 	spin_unlock(&dentry->d_lock);
+
+same:
 	spin_unlock(&parent->d_lock);
 	if (nd->root.mnt) {
 		path_get(&nd->root);
#1 lore raw

Thomas Gleixner:

Quoted 1 line

The dcache scalability work broke NFS root filesystems.

	:::
Quoted 2 lines

Check for parent equal dentry and skip the nested lock to avoid the deadlock. I'm sure this is the wrong fix, but at least it "works" :)

With this patch, can you unmount it cleanly?
It skips incrementing d_count for both dentries.
Do we need at least one?

J. R. Okajima

#2 lore raw

Hello,

Quoted 9 lines · J. R. Okajima

Thomas Gleixner:

Quoted 1 line

The dcache scalability work broke NFS root filesystems.

	:::
Quoted 2 lines

Check for parent equal dentry and skip the nested lock to avoid the deadlock. I'm sure this is the wrong fix, but at least it "works" :)

With this patch, can you unmount it cleanly?
It skips incrementing d_count for both dentries.
Do we need at least one?

If you tell me how to test that, I volunteer to try. Something involving pivot_root?

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#3 lore raw

Uwe Kleine-Knig:

Quoted 5 lines
Quoted 3 lines

With this patch, can you unmount it cleanly?
It skips incrementing d_count for both dentries.
Do we need at least one?

If you tell me how to test that, I volunteer to try. Something involving pivot_root?

For example,

# mount host:/dir /nfs
# chroot /nfs
# umount /nfs

It is ok if /nfs is empty.

J. R. Okajima

#4 lore raw
In reply to J. R. Okajima
Quoted 9 lines · J. R. Okajima

Thomas Gleixner:

Quoted 1 line

The dcache scalability work broke NFS root filesystems.

	:::
Quoted 2 lines

Check for parent equal dentry and skip the nested lock to avoid the deadlock. I'm sure this is the wrong fix, but at least it "works" :)

With this patch, can you unmount it cleanly?
It skips incrementing d_count for both dentries.
Do we need at least one?

Not sure, as we should not end up there at all I guess.

#5 lore raw
Quoted 11 lines · Thomas Gleixner
Quoted 9 lines · J. R. Okajima

Thomas Gleixner:

Quoted 1 line

The dcache scalability work broke NFS root filesystems.

      :::

Quoted 2 lines

Check for parent equal dentry and skip the nested lock to avoid the deadlock. I'm sure this is the wrong fix, but at least it "works" :)

With this patch, can you unmount it cleanly?
It skips incrementing d_count for both dentries.
Do we need at least one?

Yeah thanks everyone for reporting this.

I have a fix for it in a slightly different way, and a couple of other reported bugs, which are going through stress testing now.

Thanks,
Nick

#6 lore raw
Quoted 13 lines · Nick Piggin
Quoted 11 lines · Thomas Gleixner
Quoted 9 lines · J. R. Okajima

Thomas Gleixner:

Quoted 1 line

The dcache scalability work broke NFS root filesystems.

      :::

Quoted 2 lines

Check for parent equal dentry and skip the nested lock to avoid the deadlock. I'm sure this is the wrong fix, but at least it "works" :)

With this patch, can you unmount it cleanly?
It skips incrementing d_count for both dentries.
Do we need at least one?

Quoted 4 lines

Yeah thanks everyone for reporting this.

I have a fix for it in a slightly different way, and a couple of other reported bugs, which are going through stress testing now.

Can you point us to the patches, so we can run our own set of tests in paralell?

Thanks,

tglx

#7 lore raw
Quoted 20 lines · Thomas Gleixner
Quoted 13 lines · Nick Piggin
Quoted 11 lines · Thomas Gleixner
Quoted 9 lines · J. R. Okajima

Thomas Gleixner:

Quoted 1 line

The dcache scalability work broke NFS root filesystems.

      :::

Quoted 2 lines

Check for parent equal dentry and skip the nested lock to avoid the deadlock. I'm sure this is the wrong fix, but at least it "works" :)

With this patch, can you unmount it cleanly?
It skips incrementing d_count for both dentries.
Do we need at least one?

Quoted 4 lines

Yeah thanks everyone for reporting this.

I have a fix for it in a slightly different way, and a couple of other reported bugs, which are going through stress testing now.

Quoted 6 lines

Can you point us to the patches, so we can run our own set of tests in paralell?

Thanks,

       tglx

I guess several mentionned patches are now in [1] and I am testing them against linux-next (next-20110114).

- Sedat -

[1] http://git.kernel.org/?p=linux/kernel/git/npiggin/linux-npiggin.git;a=shortlog;h=refs/heads/vfs-scale-working

#8 lore raw
In reply to Thomas Gleixner
Quoted 3 lines · Thomas Gleixner

Can you point us to the patches, so we can run our own set of tests in paralell?

They should be in current -git as of yesterday evening.

In particular, I think this one is commit 90dbb77ba48d.

Linus

#9 lore raw
Quoted 8 lines · Linus Torvalds
Quoted 3 lines · Thomas Gleixner

Can you point us to the patches, so we can run our own set of tests in paralell?

They should be in current -git as of yesterday evening.

In particular, I think this one is commit 90dbb77ba48d.

Yep, that works - though it needs the pending fixes from Nick latest pull request as well

Thanks,

tglx

#10 lore raw
Quoted 7 lines · Thomas Gleixner
Quoted 5 lines · Linus Torvalds
Quoted 3 lines · Thomas Gleixner

Can you point us to the patches, so we can run our own set of tests in paralell?

Quoted 6 lines
Quoted 3 lines

They should be in current -git as of yesterday evening.

In particular, I think this one is commit 90dbb77ba48d.

Yep, that works - though it needs the pending fixes from Nick latest pull request as well

Thanks for reporting and testing.

Nick

#11 lore raw
In reply to Thomas Gleixner

Hello,

Quoted 46 lines · Thomas Gleixner

The dcache scalability work broke NFS root filesystems.

"cd /" results in the following problem:

    link_path_walk("/",...);
	jumps to return_reval
	need_reval_dot() returns true for NFS
	d_revalidate()
		dentry->d_op->d_revalidate(dentry, nd);
		 	returns -ECHILD due to nd->flags & LOOKUP_RCU
		nameidata_dentry_drop_rcu()
			spin_lock(&parent->d_lock);
			spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED);

			This deadlocks because dentry == parent

This problem exists for any filesystem which implements d_revalidate.

Uwe bisected is down to commit 34286d6(fs: rcu-walk aware d_revalidate method), but reverting that patch causes different wreckage to show up.

Check for parent equal dentry and skip the nested lock to avoid the deadlock. I'm sure this is the wrong fix, but at least it "works" :)

---
 fs/namei.c |    4 ++++
 1 file changed, 4 insertions(+)

Index: linux-2.6/fs/namei.c
===================================================================

fs/namei.c +2 -0
@@ -487,6 +487,8 @@ static int nameidata_dentry_drop_rcu(str
 			goto err_root;
 	}
 	spin_lock(&parent->d_lock);
+	if (parent == dentry)
+		goto same;
 	spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED);
 	if (!__d_rcu_to_refcount(dentry, nd->seq))
 		goto err;

fs/namei.c static int nameidata_dentry_drop_rcu(str · line 508

Quoted 8 lines
fs/namei.c +2 -0
@@ -499,6 +501,8 @@ static int nameidata_dentry_drop_rcu(str
 	BUG_ON(!parent->d_count);
 	parent->d_count++;
 	spin_unlock(&dentry->d_lock);
+
+same:
 	spin_unlock(&parent->d_lock);
 	if (nd->root.mnt) {
 		path_get(&nd->root);

Note there is a different patch available in the thread here:

	http://thread.gmane.org/gmane.linux.kernel/1087013/focus=1087048

The differences are that it tests for IS_ROOT(dentry) instead of parent == dentry (which looks more reasonable IMVHO) and that it increases parent->d_count even if the test triggered.
(And it doesn't skip the BUG_ONs which hopefully doesn't make a difference.)

Note I really have no glue about the code below fs/, but I wonder if the toplevel directories of mounts need some treatment here, too. (But I expect that they don't. So I ask just in case ...)

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |