Adds an ability to change the read_mirror_policy at remount.

Signed-off-by: Anand Jain <anand.j...@oracle.com>
---
 fs/btrfs/super.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 7ddecf4178a6..e70592036b95 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -856,6 +856,12 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char 
*options,
                        intarg = 0;
                        if (match_int(&args[0], &intarg) == 0) {
                                struct btrfs_device *device;
+                               int clear = 0;
+
+                               if (intarg < 0) {
+                                       clear = 1;
+                                       intarg = -intarg;
+                               }
 
                                device = btrfs_find_device(info, intarg,
                                                           NULL, NULL);
@@ -866,10 +872,17 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char 
*options,
                                        ret = -EINVAL;
                                        goto out;
                                }
-                               info->read_mirror_policy =
+
+                               if (clear) {
+                                       info->read_mirror_policy = 0;
+                                       clear_bit(BTRFS_DEV_STATE_READ_MIRROR,
+                                               &device->dev_state);
+                               } else {
+                                       info->read_mirror_policy =
                                                BTRFS_READ_MIRROR_BY_DEV;
-                               set_bit(BTRFS_DEV_STATE_READ_MIRROR,
-                                       &device->dev_state);
+                                       set_bit(BTRFS_DEV_STATE_READ_MIRROR,
+                                                 &device->dev_state);
+                               }
                                break;
                        }
 
-- 
2.7.0

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to