From: Anand Jain <Anand.Jain@xxxxxxxxxx>
First set the usual case that is writeable, then check
for any special case like a seed device or a rdonly device
and set the state appropriately.
Signed-off-by: Anand Jain <anand.jain@xxxxxxxxxx>
---
v1->v2:
Add comment and commit log to explain its safe to set writeable
first and then reset to the special case such as seed or readonly
device. (no code change).
fs/btrfs/volumes.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 5750cd9df417..001894782d84 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -689,14 +689,18 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices,
device->generation = btrfs_super_generation(disk_super);
+ /*
+ * Set the device as writeable and then check if its
+ * seed or readonly device. Both SUPER_FLAG_SEEDING and
+ * bdev_read_only(bdev) can be set by the user when device
+ * is unmounted. And this fn is called at the time of mount.
+ */
+ set_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state);
if (btrfs_super_flags(disk_super) & BTRFS_SUPER_FLAG_SEEDING) {
clear_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state);
fs_devices->seeding = 1;
- } else {
- if (bdev_read_only(bdev))
- clear_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state);
- else
- set_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state);
+ } else if (bdev_read_only(bdev)) {
+ clear_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state);
}
q = bdev_get_queue(bdev);
--
2.15.0
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html