btrfs: move volume_mutex into the btrfs_rm_device()
authorAnand Jain <anand.jain@oracle.com>
Mon, 6 Nov 2017 02:28:00 +0000 (10:28 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 22 Jan 2018 15:08:11 +0000 (16:08 +0100)
A cleanup patch no functional change, we hold volume_mutex before
calling btrfs_rm_device, so move it into the function itself.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ioctl.c
fs/btrfs/volumes.c

index 2ef8acaac68846ea1d29452a0b0f1d95d85cc6e5..64b947487ca6e3936502d2cbaabefebfbbac7900 100644 (file)
@@ -2675,14 +2675,12 @@ static long btrfs_ioctl_rm_dev_v2(struct file *file, void __user *arg)
                goto out;
        }
 
-       mutex_lock(&fs_info->volume_mutex);
        if (vol_args->flags & BTRFS_DEVICE_SPEC_BY_ID) {
                ret = btrfs_rm_device(fs_info, NULL, vol_args->devid);
        } else {
                vol_args->name[BTRFS_SUBVOL_NAME_MAX] = '\0';
                ret = btrfs_rm_device(fs_info, vol_args->name, 0);
        }
-       mutex_unlock(&fs_info->volume_mutex);
        clear_bit(BTRFS_FS_EXCL_OP, &fs_info->flags);
 
        if (!ret) {
@@ -2726,9 +2724,7 @@ static long btrfs_ioctl_rm_dev(struct file *file, void __user *arg)
        }
 
        vol_args->name[BTRFS_PATH_NAME_MAX] = '\0';
-       mutex_lock(&fs_info->volume_mutex);
        ret = btrfs_rm_device(fs_info, vol_args->name, 0);
-       mutex_unlock(&fs_info->volume_mutex);
 
        if (!ret)
                btrfs_info(fs_info, "disk deleted %s", vol_args->name);
index 7ea81e1b361f1d10851c76cc8bbdc22408453e4d..02b2c9ec6fcdaa1f50026f0ad49366b2d69f6710 100644 (file)
@@ -1842,6 +1842,7 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path,
        u64 num_devices;
        int ret = 0;
 
+       mutex_lock(&fs_info->volume_mutex);
        mutex_lock(&uuid_mutex);
 
        num_devices = fs_info->fs_devices->num_devices;
@@ -1956,6 +1957,7 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path,
 
 out:
        mutex_unlock(&uuid_mutex);
+       mutex_unlock(&fs_info->volume_mutex);
        return ret;
 
 error_undo: