Skip to content

Commit

Permalink
Btrfs: fix trivial error in btrfs_ioctl_resize()
Browse files Browse the repository at this point in the history
This patch fixes the following problem:
- improper return value
- unnecessary read-only check

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
  • Loading branch information
Miao Xie authored and Josef Bacik committed Feb 20, 2013
1 parent 4eee4fa commit dfd7982
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions fs/btrfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1329,9 +1329,6 @@ static noinline int btrfs_ioctl_resize(struct file *file,
int ret = 0;
int mod = 0;

if (root->fs_info->sb->s_flags & MS_RDONLY)
return -EROFS;

if (!capable(CAP_SYS_ADMIN))
return -EPERM;

Expand Down Expand Up @@ -1363,6 +1360,10 @@ static noinline int btrfs_ioctl_resize(struct file *file,
*devstr = '\0';
devstr = vol_args->name;
devid = simple_strtoull(devstr, &end, 10);
if (!devid) {
ret = -EINVAL;
goto out_free;
}
printk(KERN_INFO "btrfs: resizing devid %llu\n",
(unsigned long long)devid);
}
Expand All @@ -1371,15 +1372,15 @@ static noinline int btrfs_ioctl_resize(struct file *file,
if (!device) {
printk(KERN_INFO "btrfs: resizer unable to find device %llu\n",
(unsigned long long)devid);
ret = -EINVAL;
ret = -ENODEV;
goto out_free;
}

if (!device->writeable) {
printk(KERN_INFO "btrfs: resizer unable to apply on "
"readonly device %llu\n",
(unsigned long long)devid);
ret = -EINVAL;
ret = -EPERM;
goto out_free;
}

Expand All @@ -1401,7 +1402,7 @@ static noinline int btrfs_ioctl_resize(struct file *file,
}

if (device->is_tgtdev_for_dev_replace) {
ret = -EINVAL;
ret = -EPERM;
goto out_free;
}

Expand Down

0 comments on commit dfd7982

Please sign in to comment.