Btrfs: fix resize a readonly device
authorMiao Xie <miaox@cn.fujitsu.com>
Fri, 21 Dec 2012 09:19:51 +0000 (09:19 +0000)
committerJosef Bacik <josef@toxicpanda.com>
Mon, 14 Jan 2013 18:52:49 +0000 (13:52 -0500)
We should not resize a readonly device, fix it.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
fs/btrfs/ioctl.c

index 5a72896bd76995917fc2040cd0d8225daa6569a2..0de21213d05d2dd7edd5e0122bb639e569897155 100644 (file)
@@ -1362,6 +1362,7 @@ static noinline int btrfs_ioctl_resize(struct file *file,
                printk(KERN_INFO "btrfs: resizing devid %llu\n",
                       (unsigned long long)devid);
        }
+
        device = btrfs_find_device(root->fs_info, devid, NULL, NULL);
        if (!device) {
                printk(KERN_INFO "btrfs: resizer unable to find device %llu\n",
@@ -1369,9 +1370,10 @@ static noinline int btrfs_ioctl_resize(struct file *file,
                ret = -EINVAL;
                goto out_free;
        }
-       if (device->fs_devices && device->fs_devices->seeding) {
+
+       if (!device->writeable) {
                printk(KERN_INFO "btrfs: resizer unable to apply on "
-                      "seeding device %llu\n",
+                      "readonly device %llu\n",
                       (unsigned long long)devid);
                ret = -EINVAL;
                goto out_free;