|
@@ -1457,7 +1457,6 @@ static noinline int btrfs_ioctl_resize(struct file *file,
|
|
|
return BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS;
|
|
|
}
|
|
|
|
|
|
- mutex_lock(&fs_info->volume_mutex);
|
|
|
vol_args = memdup_user(arg, sizeof(*vol_args));
|
|
|
if (IS_ERR(vol_args)) {
|
|
|
ret = PTR_ERR(vol_args);
|
|
@@ -1565,7 +1564,6 @@ static noinline int btrfs_ioctl_resize(struct file *file,
|
|
|
out_free:
|
|
|
kfree(vol_args);
|
|
|
out:
|
|
|
- mutex_unlock(&fs_info->volume_mutex);
|
|
|
clear_bit(BTRFS_FS_EXCL_OP, &fs_info->flags);
|
|
|
mnt_drop_write_file(file);
|
|
|
return ret;
|
|
@@ -2432,7 +2430,6 @@ static long btrfs_ioctl_add_dev(struct btrfs_fs_info *fs_info, void __user *arg)
|
|
|
if (test_and_set_bit(BTRFS_FS_EXCL_OP, &fs_info->flags))
|
|
|
return BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS;
|
|
|
|
|
|
- mutex_lock(&fs_info->volume_mutex);
|
|
|
vol_args = memdup_user(arg, sizeof(*vol_args));
|
|
|
if (IS_ERR(vol_args)) {
|
|
|
ret = PTR_ERR(vol_args);
|
|
@@ -2447,7 +2444,6 @@ static long btrfs_ioctl_add_dev(struct btrfs_fs_info *fs_info, void __user *arg)
|
|
|
|
|
|
kfree(vol_args);
|
|
|
out:
|
|
|
- mutex_unlock(&fs_info->volume_mutex);
|
|
|
clear_bit(BTRFS_FS_EXCL_OP, &fs_info->flags);
|
|
|
return ret;
|
|
|
}
|
|
@@ -2480,7 +2476,6 @@ static long btrfs_ioctl_rm_dev_v2(struct file *file, void __user *arg)
|
|
|
ret = BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS;
|
|
|
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);
|
|
@@ -2488,7 +2483,6 @@ static long btrfs_ioctl_rm_dev_v2(struct file *file, void __user *arg)
|
|
|
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) {
|
|
@@ -2524,7 +2518,6 @@ static long btrfs_ioctl_rm_dev(struct file *file, void __user *arg)
|
|
|
ret = BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS;
|
|
|
goto out_drop_write;
|
|
|
}
|
|
|
- mutex_lock(&fs_info->volume_mutex);
|
|
|
|
|
|
vol_args = memdup_user(arg, sizeof(*vol_args));
|
|
|
if (IS_ERR(vol_args)) {
|
|
@@ -2539,7 +2532,6 @@ static long btrfs_ioctl_rm_dev(struct file *file, void __user *arg)
|
|
|
btrfs_info(fs_info, "disk deleted %s", vol_args->name);
|
|
|
kfree(vol_args);
|
|
|
out:
|
|
|
- mutex_unlock(&fs_info->volume_mutex);
|
|
|
clear_bit(BTRFS_FS_EXCL_OP, &fs_info->flags);
|
|
|
out_drop_write:
|
|
|
mnt_drop_write_file(file);
|
|
@@ -4358,7 +4350,6 @@ static long btrfs_ioctl_balance(struct file *file, void __user *arg)
|
|
|
|
|
|
again:
|
|
|
if (!test_and_set_bit(BTRFS_FS_EXCL_OP, &fs_info->flags)) {
|
|
|
- mutex_lock(&fs_info->volume_mutex);
|
|
|
mutex_lock(&fs_info->balance_mutex);
|
|
|
need_unlock = true;
|
|
|
goto locked;
|
|
@@ -4375,8 +4366,10 @@ again:
|
|
|
/* this is either (2) or (3) */
|
|
|
if (!atomic_read(&fs_info->balance_running)) {
|
|
|
mutex_unlock(&fs_info->balance_mutex);
|
|
|
- if (!mutex_trylock(&fs_info->volume_mutex))
|
|
|
- goto again;
|
|
|
+ /*
|
|
|
+ * Lock released to allow other waiters to continue,
|
|
|
+ * we'll reexamine the status again.
|
|
|
+ */
|
|
|
mutex_lock(&fs_info->balance_mutex);
|
|
|
|
|
|
if (fs_info->balance_ctl &&
|
|
@@ -4387,7 +4380,6 @@ again:
|
|
|
}
|
|
|
|
|
|
mutex_unlock(&fs_info->balance_mutex);
|
|
|
- mutex_unlock(&fs_info->volume_mutex);
|
|
|
goto again;
|
|
|
} else {
|
|
|
/* this is (2) */
|
|
@@ -4480,7 +4472,6 @@ out_bargs:
|
|
|
kfree(bargs);
|
|
|
out_unlock:
|
|
|
mutex_unlock(&fs_info->balance_mutex);
|
|
|
- mutex_unlock(&fs_info->volume_mutex);
|
|
|
if (need_unlock)
|
|
|
clear_bit(BTRFS_FS_EXCL_OP, &fs_info->flags);
|
|
|
out:
|