btrfs: replace uuid_mutex by device_list_mutex in btrfs_open_devices
authorAnand Jain <anand.jain@oracle.com>
Thu, 12 Apr 2018 02:29:34 +0000 (10:29 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 28 May 2018 16:23:15 +0000 (18:23 +0200)
btrfs_open_devices() is using the uuid_mutex, but as btrfs_open_devices
is just limited to openning all the devices under for given fsid, so we
don't need uuid_mutex.

Instead it should hold the device_list_mutex as it updates the members
of the btrfs_fs_devices and btrfs_device and not the whole fs_devs list.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
[ update changelog ]
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/volumes.c

index 6eec1e3f90833c894f1cfd0b7b54f4f7adafc5d8..271d9be6e1da8b3078c06dc98ebfacf12d612ad8 100644 (file)
@@ -1146,7 +1146,7 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
 {
        int ret;
 
-       mutex_lock(&uuid_mutex);
+       mutex_lock(&fs_devices->device_list_mutex);
        if (fs_devices->opened) {
                fs_devices->opened++;
                ret = 0;
@@ -1154,7 +1154,8 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
                list_sort(NULL, &fs_devices->devices, devid_cmp);
                ret = open_fs_devices(fs_devices, flags, holder);
        }
-       mutex_unlock(&uuid_mutex);
+       mutex_unlock(&fs_devices->device_list_mutex);
+
        return ret;
 }