mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH -rt 1/2] Revert select_parent locking fix
@ 2010-06-30 19:12 John Stultz
  2010-06-30 19:12 ` [PATCH -rt 2/2] Make sure d_kill sets d_parent to null John Stultz
  0 siblings, 1 reply; 2+ messages in thread
From: John Stultz @ 2010-06-30 19:12 UTC (permalink / raw)
  To: linux-kernel
  Cc: John Stultz, Thomas Gleixner, Nick Piggin, Peter Zijlstra, John Kacur

Patch against currrent 2.6.33-rt tree.

This reverts 697684652c217b241a07d9e261c7a20e9b072d43 which resolved a
locking issue with select_parent. Unfortunately the fix, which keeps
the entire subchain locked, breaks lockdep.

Reverting so a proper fix can follow.

Signed-off-by: John Stultz <johnstul@us.ibm.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Nick Piggin <npiggin@suse.de>
CC: Peter Zijlstra <peterz@infradead.org>
CC: John Kacur <jkacur@redhat.com>
---
 fs/dcache.c |   29 +++++++++++++++++------------
 1 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/fs/dcache.c b/fs/dcache.c
index 18a3b76..da90157 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1052,12 +1052,12 @@ resume:
 
 		/*
 		 * Descend a level if the d_subdirs list is non-empty.
-		 * Note that we keep a hold on the parent lock while
-		 * we descend, so we don't have to reacquire it on
-		 * ascend.
 		 */
 		if (!list_empty(&dentry->d_subdirs)) {
+			spin_unlock(&this_parent->d_lock);
+			spin_release(&dentry->d_lock.dep_map, 1, _RET_IP_);
 			this_parent = dentry;
+			spin_acquire(&this_parent->d_lock.dep_map, 0, 1, _RET_IP_);
 			goto repeat;
 		}
 
@@ -1071,20 +1071,25 @@ resume:
 		struct dentry *child;
 
 		tmp = this_parent->d_parent;
-		child = this_parent;
-		next = child->d_u.d_child.next;
+		rcu_read_lock();
 		spin_unlock(&this_parent->d_lock);
+		child = this_parent;
 		this_parent = tmp;
+		spin_lock(&this_parent->d_lock);
+		/* might go back up the wrong parent if we have had a rename
+		 * or deletion */
+		if (this_parent != child->d_parent ||
+				// d_unlinked(this_parent) || XXX
+				read_seqretry(&rename_lock, seq)) {
+			spin_unlock(&this_parent->d_lock);
+			rcu_read_unlock();
+			goto rename_retry;
+		}
+		rcu_read_unlock();
+		next = child->d_u.d_child.next;
 		goto resume;
 	}
-
 out:
-	/* Make sure we unlock all the way back up the tree */
-	while (this_parent != parent) {
-		struct dentry *tmp = this_parent->d_parent;
-		spin_unlock(&this_parent->d_lock);
-		this_parent = tmp;
-	}
 	spin_unlock(&this_parent->d_lock);
 	if (read_seqretry(&rename_lock, seq))
 		goto rename_retry;
-- 
1.6.0.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH -rt 2/2] Make sure d_kill sets d_parent to null
  2010-06-30 19:12 [PATCH -rt 1/2] Revert select_parent locking fix John Stultz
@ 2010-06-30 19:12 ` John Stultz
  0 siblings, 0 replies; 2+ messages in thread
From: John Stultz @ 2010-06-30 19:12 UTC (permalink / raw)
  To: linux-kernel
  Cc: John Stultz, Thomas Gleixner, Nick Piggin, Peter Zijlstra, John Kacur

Patch against currrent 2.6.33-rt tree.

This patch is an alternative fix to the select_parent panic that was
suggested by Nick Piggin.

It resolves the issue by making sure d_parent is set to null so that
the dentry ascending code in select_parent will restart if the child
or next dentry was dkilled while the locks were released.

Credit and thanks to Nick for finding the solution.

Signed-off-by: John Stultz <johnstul@us.ibm.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Nick Piggin <npiggin@suse.de>
CC: Peter Zijlstra <peterz@infradead.org>
CC: John Kacur <jkacur@redhat.com>
---
 fs/dcache.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/fs/dcache.c b/fs/dcache.c
index da90157..c9d21ae 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -225,13 +225,15 @@ static struct dentry *d_kill(struct dentry *dentry)
 {
 	struct dentry *parent;
 
-	list_del(&dentry->d_u.d_child);
-	if (dentry->d_parent && dentry != dentry->d_parent)
-		spin_unlock(&dentry->d_parent->d_lock);
 	if (IS_ROOT(dentry))
 		parent = NULL;
 	else
 		parent = dentry->d_parent;
+
+	dentry->d_parent = NULL;
+	list_del(&dentry->d_u.d_child);
+	if (parent)
+		spin_unlock(&parent->d_lock);
 	/*drops the locks, at that point nobody can reach this dentry */
 	dentry_iput(dentry);
 	d_free(dentry);
-- 
1.6.0.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-06-30 19:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-30 19:12 [PATCH -rt 1/2] Revert select_parent locking fix John Stultz
2010-06-30 19:12 ` [PATCH -rt 2/2] Make sure d_kill sets d_parent to null John Stultz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome