Commit 39864601 authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: remove checks for arg argument in btrfs_ioctl_balance

With the removal of balance v1 ioctl the 'arg' argument is guaranteed to
be present so simply remove all conditional code which checks for its
presence.
Reviewed-by: default avatarSweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent b06660b5
...@@ -4346,10 +4346,6 @@ static long btrfs_ioctl_balance(struct file *file, void __user *arg) ...@@ -4346,10 +4346,6 @@ static long btrfs_ioctl_balance(struct file *file, void __user *arg)
bool need_unlock; /* for mut. excl. ops lock */ bool need_unlock; /* for mut. excl. ops lock */
int ret; int ret;
if (!arg)
btrfs_warn(fs_info,
"IOC_BALANCE ioctl (v1) is deprecated and will be removed in kernel 5.18");
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EPERM; return -EPERM;
...@@ -4405,7 +4401,6 @@ static long btrfs_ioctl_balance(struct file *file, void __user *arg) ...@@ -4405,7 +4401,6 @@ static long btrfs_ioctl_balance(struct file *file, void __user *arg)
locked: locked:
if (arg) {
bargs = memdup_user(arg, sizeof(*bargs)); bargs = memdup_user(arg, sizeof(*bargs));
if (IS_ERR(bargs)) { if (IS_ERR(bargs)) {
ret = PTR_ERR(bargs); ret = PTR_ERR(bargs);
...@@ -4426,9 +4421,6 @@ static long btrfs_ioctl_balance(struct file *file, void __user *arg) ...@@ -4426,9 +4421,6 @@ static long btrfs_ioctl_balance(struct file *file, void __user *arg)
goto do_balance; goto do_balance;
} }
} else {
bargs = NULL;
}
if (fs_info->balance_ctl) { if (fs_info->balance_ctl) {
ret = -EINPROGRESS; ret = -EINPROGRESS;
...@@ -4441,16 +4433,11 @@ static long btrfs_ioctl_balance(struct file *file, void __user *arg) ...@@ -4441,16 +4433,11 @@ static long btrfs_ioctl_balance(struct file *file, void __user *arg)
goto out_bargs; goto out_bargs;
} }
if (arg) {
memcpy(&bctl->data, &bargs->data, sizeof(bctl->data)); memcpy(&bctl->data, &bargs->data, sizeof(bctl->data));
memcpy(&bctl->meta, &bargs->meta, sizeof(bctl->meta)); memcpy(&bctl->meta, &bargs->meta, sizeof(bctl->meta));
memcpy(&bctl->sys, &bargs->sys, sizeof(bctl->sys)); memcpy(&bctl->sys, &bargs->sys, sizeof(bctl->sys));
bctl->flags = bargs->flags; bctl->flags = bargs->flags;
} else {
/* balance everything - no filters */
bctl->flags |= BTRFS_BALANCE_TYPE_MASK;
}
if (bctl->flags & ~(BTRFS_BALANCE_ARGS_MASK | BTRFS_BALANCE_TYPE_MASK)) { if (bctl->flags & ~(BTRFS_BALANCE_ARGS_MASK | BTRFS_BALANCE_TYPE_MASK)) {
ret = -EINVAL; ret = -EINVAL;
...@@ -4469,7 +4456,7 @@ static long btrfs_ioctl_balance(struct file *file, void __user *arg) ...@@ -4469,7 +4456,7 @@ static long btrfs_ioctl_balance(struct file *file, void __user *arg)
ret = btrfs_balance(fs_info, bctl, bargs); ret = btrfs_balance(fs_info, bctl, bargs);
bctl = NULL; bctl = NULL;
if ((ret == 0 || ret == -ECANCELED) && arg) { if (ret == 0 || ret == -ECANCELED) {
if (copy_to_user(arg, bargs, sizeof(*bargs))) if (copy_to_user(arg, bargs, sizeof(*bargs)))
ret = -EFAULT; ret = -EFAULT;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment