]> git.karo-electronics.de Git - karo-tx-linux.git/commit
reiserfs: fix deadlock with nfs racing on create/lookup
authorJeff Mahoney <jeffm@suse.com>
Thu, 9 May 2013 23:57:48 +0000 (09:57 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 21 May 2013 04:17:58 +0000 (14:17 +1000)
commit0c66900e94ac81940b4d2200e6031fb5904b35fa
tree8d66e692497cfe193ba7d35181014af633ff32f7
parent75dc96dc7afa1fce4cfe6d36398c015716b1e328
reiserfs: fix deadlock with nfs racing on create/lookup

Reiserfs is currently able to be deadlocked by having two NFS clients
where one has removed and recreated a file and another is accessing the
file with an open file handle.

If one client deletes and recreates a file with timing such that the
recreated file obtains the same [dirid, objectid] pair as the original
file while another client accesses the file via file handle, the create
and lookup can race and deadlock if the lookup manages to create the
in-memory inode first.

The create thread, in insert_inode_locked4, will hold the write lock while
waiting on the other inode to be unlocked.  The lookup thread, anywhere in
the iget path, will release and reacquire the write lock while it
schedules.  If it needs to reacquire the lock while the create thread has
it, it will never be able to make forward progress because it needs to
reacquire the lock before ultimately unlocking the inode.

This patch drops the write lock across the insert_inode_locked4 call so
that the ordering of inode_wait -> write lock is retained.  Since this
would have been the case before the BKL push-down, this is safe.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/reiserfs/inode.c