]> www.infradead.org Git - users/jedix/linux-maple.git/commit
vfs: dcache: fix deadlock in tree traversal
authorMiklos Szeredi <miklos@szeredi.hu>
Mon, 17 Sep 2012 20:23:30 +0000 (22:23 +0200)
committerMaxim Uvarov <maxim.uvarov@oracle.com>
Mon, 8 Oct 2012 14:02:52 +0000 (07:02 -0700)
commit3e19b237959eadb259b932b36da0d917557b9e99
tree0efc80efa87aa427c946b7bb4a7d45d5a0320708
parentecb5c342eaacfb3472e0c6b64f1c3415962f15ac
vfs: dcache: fix deadlock in tree traversal

commit 8110e16d42d587997bcaee0c864179e6d93603fe upstream.

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.

[ I rewrote the patch to be smaller and just do the "goto again" if the
  lock was already held, but credit goes to Miklos for the real work.
   - Linus ]

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/dcache.c