kill-the-bkl/reiserfs: acquire the inode mutex safely
authorFrederic Weisbecker <fweisbec@gmail.com>
Sat, 16 May 2009 16:12:08 +0000 (18:12 +0200)
committerFrederic Weisbecker <fweisbec@gmail.com>
Mon, 14 Sep 2009 05:18:24 +0000 (07:18 +0200)
commitc72e05756b900b3be24cd73a16de52bab80984c0
tree4fc35ad9efc1a6a9ca14baa3612e551fb4da793e
parent2ac626955ed62ee8596f00581f959cc86e6198d1
kill-the-bkl/reiserfs: acquire the inode mutex safely

While searching a pathname, an inode mutex can be acquired
in do_lookup() which calls reiserfs_lookup() which in turn
acquires the write lock.

On the other side reiserfs_fill_super() can acquire the write_lock
and then call reiserfs_lookup_privroot() which can acquire an
inode mutex (the root of the mount point).

So we theoretically risk an AB - BA lock inversion that could lead
to a deadlock.

As for other lock dependencies found since the bkl to mutex
conversion, the fix is to use reiserfs_mutex_lock_safe() which
drops the lock dependency to the write lock.

[ Impact: fix a possible deadlock with reiserfs ]

Cc: Jeff Mahoney <jeffm@suse.com>
Cc: Chris Mason <chris.mason@oracle.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Alexander Beregalov <a.beregalov@gmail.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
fs/reiserfs/journal.c
fs/reiserfs/xattr.c
include/linux/reiserfs_fs.h