btrfs: get the device in write mode when deleting it
authorLukas Czerner <lczerner@redhat.com>
Fri, 7 Dec 2012 10:09:19 +0000 (10:09 +0000)
committerJosef Bacik <josef@toxicpanda.com>
Mon, 14 Jan 2013 18:52:31 +0000 (13:52 -0500)
When we're deleting the device we should get it in write mode since
we're going to re-write the super block magic on that device. And it
should fail if the device is read-only.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
fs/btrfs/volumes.c

index 5cce6aa7401287322c31673cf039f0e32918c6c4..86279c37de6411b72e172eefddf47db7febf346d 100644 (file)
@@ -1431,7 +1431,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
                }
        } else {
                ret = btrfs_get_bdev_and_sb(device_path,
-                                           FMODE_READ | FMODE_EXCL,
+                                           FMODE_WRITE | FMODE_EXCL,
                                            root->fs_info->bdev_holder, 0,
                                            &bdev, &bh);
                if (ret)