summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.cz>2016-04-28 11:59:34 +0200
committerDavid Sterba <dsterba@suse.com>2016-05-06 14:58:00 +0200
commit2355ac8495c1fb8ae58bdfe191489682538c697d (patch)
tree0c291e739086cc60cb486decf05219fc2e649877 /fs
parent58409edd2d5cc24716cb9ce690803696c5118503 (diff)
downloadlinux-2355ac8495c1fb8ae58bdfe191489682538c697d.tar.bz2
btrfs: ioctl: reorder exclusive op check in RM_DEV
Move the op exclusivity check before the other code (same as in ADD_DEV). Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/ioctl.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 03df0bbb445d..45a19c6b2341 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2680,32 +2680,31 @@ static long btrfs_ioctl_rm_dev(struct file *file, void __user *arg)
if (ret)
return ret;
- vol_args = memdup_user(arg, sizeof(*vol_args));
- if (IS_ERR(vol_args)) {
- ret = PTR_ERR(vol_args);
- goto err_drop;
- }
-
- vol_args->name[BTRFS_PATH_NAME_MAX] = '\0';
-
if (atomic_xchg(&root->fs_info->mutually_exclusive_operation_running,
1)) {
ret = BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS;
+ goto out_drop_write;
+ }
+
+ vol_args = memdup_user(arg, sizeof(*vol_args));
+ if (IS_ERR(vol_args)) {
+ ret = PTR_ERR(vol_args);
goto out;
}
+ vol_args->name[BTRFS_PATH_NAME_MAX] = '\0';
mutex_lock(&root->fs_info->volume_mutex);
ret = btrfs_rm_device(root, vol_args->name);
mutex_unlock(&root->fs_info->volume_mutex);
- atomic_set(&root->fs_info->mutually_exclusive_operation_running, 0);
if (!ret)
btrfs_info(root->fs_info, "disk deleted %s",vol_args->name);
-
-out:
kfree(vol_args);
-err_drop:
+out:
+ atomic_set(&root->fs_info->mutually_exclusive_operation_running, 0);
+out_drop_write:
mnt_drop_write_file(file);
+
return ret;
}