aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2011-11-17 15:05:22 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2012-01-08 19:33:24 -0500
commit10f6327b5d26660e06120ba17cff993cb616b1d2 (patch)
treeee1bade28f62a896db62570589abcb9c8f6f2936 /fs
parent6de1d09d9677dce7a04ef485d426821159ab7de9 (diff)
btrfs: fix a deadlock in btrfs_scan_one_device()
pathname resolution under a global mutex, taken on some paths in ->mount() is a Bad Idea(tm) - think what happens if said pathname resolution triggers automount of some btrfs instance and walks into attempt to grab the same mutex. Deadlock - we are waiting for daemon to finish walking the path, daemon is waiting for us to release the mutex... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/volumes.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index f4b839fd3c9d..96bb3c0a79b0 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -706,8 +706,6 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,
706 u64 devid; 706 u64 devid;
707 u64 transid; 707 u64 transid;
708 708
709 mutex_lock(&uuid_mutex);
710
711 flags |= FMODE_EXCL; 709 flags |= FMODE_EXCL;
712 bdev = blkdev_get_by_path(path, flags, holder); 710 bdev = blkdev_get_by_path(path, flags, holder);
713 711
@@ -716,6 +714,7 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,
716 goto error; 714 goto error;
717 } 715 }
718 716
717 mutex_lock(&uuid_mutex);
719 ret = set_blocksize(bdev, 4096); 718 ret = set_blocksize(bdev, 4096);
720 if (ret) 719 if (ret)
721 goto error_close; 720 goto error_close;
@@ -737,9 +736,9 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,
737 736
738 brelse(bh); 737 brelse(bh);
739error_close: 738error_close:
739 mutex_unlock(&uuid_mutex);
740 blkdev_put(bdev, flags); 740 blkdev_put(bdev, flags);
741error: 741error:
742 mutex_unlock(&uuid_mutex);
743 return ret; 742 return ret;
744} 743}
745 744