linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] vfs: dcache: fix deadlock in tree traversal
@ 2012-09-17 20:23 Miklos Szeredi
  2012-09-17 20:31 ` [PATCH 2/2] vfs: dcache: use DCACHE_DENTRY_KILLED instead of DCACHE_DISCONNECTED in d_kill() Miklos Szeredi
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Miklos Szeredi @ 2012-09-17 20:23 UTC (permalink / raw)
  To: viro; +Cc: linux-fsdevel, linux-kernel, hch, torvalds, Trond.Myklebust

From: Miklos Szeredi <mszeredi@suse.cz>

IBM reported a deadlock in select_parent().  This was found to be caused by
taking rename_lock when already locked when restarting the tree traversal.

There are two cases when the traversal needs to be restarted:

 1) concurrent d_move(); this can only happen when not already locked,
 since taking rename_lock protects against concurrent d_move().

 2) racing with final d_put() on child just at the moment of ascending
 to parent; rename_lock doesn't protect against this rare race, so it
 can happen when already locked.

Because of case 2. we need to be able to handle restarting the traversal
when rename_lock is already held.  This patch fixes all three callers of
try_to_ascend().

IBM reported that the deadlock is gone with this patch.  However, there's still
a soft lockup which is addressed by the next patch.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Cc: stable@vger.kernel.org
---
 fs/dcache.c |   19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

Index: linux-2.6/fs/dcache.c
===================================================================
--- linux-2.6.orig/fs/dcache.c	2012-09-17 19:56:19.000000000 +0200
+++ linux-2.6/fs/dcache.c	2012-09-17 20:04:07.000000000 +0200
@@ -1134,8 +1134,10 @@ int have_submounts(struct dentry *parent
 	return 1;
 
 rename_retry:
-	locked = 1;
-	write_seqlock(&rename_lock);
+	if (!locked) {
+		locked = 1;
+		write_seqlock(&rename_lock);
+	}
 	goto again;
 }
 EXPORT_SYMBOL(have_submounts);
@@ -1236,8 +1238,10 @@ static int select_parent(struct dentry *
 rename_retry:
 	if (found)
 		return found;
-	locked = 1;
-	write_seqlock(&rename_lock);
+	if (!locked) {
+		locked = 1;
+		write_seqlock(&rename_lock);
+	}
 	goto again;
 }
 
@@ -3035,8 +3039,11 @@ void d_genocide(struct dentry *root)
 	return;
 
 rename_retry:
-	locked = 1;
-	write_seqlock(&rename_lock);
+	if (!locked) {
+		locked = 1;
+		write_seqlock(&rename_lock);
+
+	}
 	goto again;
 }
 

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

end of thread, other threads:[~2012-09-18 20:35 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-17 20:23 [PATCH 1/2] vfs: dcache: fix deadlock in tree traversal Miklos Szeredi
2012-09-17 20:31 ` [PATCH 2/2] vfs: dcache: use DCACHE_DENTRY_KILLED instead of DCACHE_DISCONNECTED in d_kill() Miklos Szeredi
2012-09-17 20:39 ` [PATCH 1/2] vfs: dcache: fix deadlock in tree traversal Al Viro
2012-09-17 22:09   ` Linus Torvalds
2012-09-18 14:53     ` Miklos Szeredi
2012-09-18 15:56       ` Linus Torvalds
2012-09-18 16:27         ` Miklos Szeredi
2012-09-18 18:22           ` Linus Torvalds
2012-09-18 20:35 ` [PATCH] trivial select_parent documentation fix J. Bruce Fields

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).