summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/volumes.c
diff options
context:
space:
mode:
authorDavid Sterba2018-06-19 16:37:36 +0200
committerDavid Sterba2018-08-06 13:12:47 +0200
commit899f9307c33ce4758c30a076b10ed54d5c91c6e7 (patch)
treea4a20c74583fb1d5f4527977faa947670562f6de /fs/btrfs/volumes.c
parentbtrfs: use device_list_mutex when removing stale devices (diff)
downloadkernel-qcow2-linux-899f9307c33ce4758c30a076b10ed54d5c91c6e7.tar.gz
kernel-qcow2-linux-899f9307c33ce4758c30a076b10ed54d5c91c6e7.tar.xz
kernel-qcow2-linux-899f9307c33ce4758c30a076b10ed54d5c91c6e7.zip
btrfs: lift uuid_mutex to callers of btrfs_scan_one_device
Prepartory work to fix race between mount and device scan. The callers will have to manage the critical section, eg. mount wants to scan and then call btrfs_open_devices without the ioctl scan walking in and modifying the fs devices in the meantime. Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r--fs/btrfs/volumes.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 6a8f1e2c116f..df5dd6f67887 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1224,6 +1224,8 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,
int ret = 0;
u64 bytenr;
+ lockdep_assert_held(&uuid_mutex);
+
/*
* we would like to check all the supers, but that would make
* a btrfs mount succeed after a mkfs from a different FS.
@@ -1242,7 +1244,6 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,
goto error_bdev_put;
}
- mutex_lock(&uuid_mutex);
device = device_list_add(path, disk_super, &new_device_added);
if (IS_ERR(device)) {
ret = PTR_ERR(device);
@@ -1251,7 +1252,6 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,
if (new_device_added)
btrfs_free_stale_devices(path, device);
}
- mutex_unlock(&uuid_mutex);
btrfs_release_disk_super(page);