bcachefs: no_splitbrain_check option
authorKent Overstreet <kent.overstreet@linux.dev>
Fri, 8 Mar 2024 21:03:19 +0000 (16:03 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 10 Mar 2024 19:12:54 +0000 (15:12 -0400)
This adds an option to disable kicking out devices when splitbrain is
detected - it seems there's some issues with splitbrain detection and
we're kicking out devices erronously.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/opts.h
fs/bcachefs/super.c

index 9a4b7faa376503993f1c2da8f8d1e5963ef6ca5a..9a83aca31b4b2a994767d1afd16e58baead0be58 100644 (file)
@@ -290,6 +290,11 @@ enum fsck_err_opts {
          OPT_BOOL(),                                                   \
          BCH2_NO_SB_OPT,               false,                          \
          NULL,         "Allow mounting in when data will be missing")  \
+       x(no_splitbrain_check,          u8,                             \
+         OPT_FS|OPT_MOUNT,                                             \
+         OPT_BOOL(),                                                   \
+         BCH2_NO_SB_OPT,               false,                          \
+         NULL,         "Don't kick drives out when splitbrain detected")\
        x(discard,                      u8,                             \
          OPT_FS|OPT_MOUNT|OPT_DEVICE,                                  \
          OPT_BOOL(),                                                   \
index 24fa41bbe7e36c3dcd024dcb56b7815e05d7a9d6..73173f63f486bb0206167ebe28417c4fc2fddac7 100644 (file)
@@ -1061,7 +1061,8 @@ static int bch2_dev_may_add(struct bch_sb *sb, struct bch_fs *c)
 }
 
 static int bch2_dev_in_fs(struct bch_sb_handle *fs,
-                         struct bch_sb_handle *sb)
+                         struct bch_sb_handle *sb,
+                         struct bch_opts *opts)
 {
        if (fs == sb)
                return 0;
@@ -1102,11 +1103,14 @@ static int bch2_dev_in_fs(struct bch_sb_handle *fs,
                bch2_prt_datetime(&buf, le64_to_cpu(sb->sb->write_time));;
                prt_newline(&buf);
 
-               prt_printf(&buf, "Not using older sb");
+               if (!opts->no_splitbrain_check)
+                       prt_printf(&buf, "Not using older sb");
 
                pr_err("%s", buf.buf);
                printbuf_exit(&buf);
-               return -BCH_ERR_device_splitbrain;
+
+               if (!opts->no_splitbrain_check)
+                       return -BCH_ERR_device_splitbrain;
        }
 
        struct bch_member m = bch2_sb_member_get(fs->sb, sb->sb->dev_idx);
@@ -1129,12 +1133,17 @@ static int bch2_dev_in_fs(struct bch_sb_handle *fs,
                prt_printf(&buf, " to be %llu, but ", seq_from_fs);
                prt_bdevname(&buf, sb->bdev);
                prt_printf(&buf, " has %llu\n", seq_from_member);
-               prt_str(&buf, "Not using ");
-               prt_bdevname(&buf, sb->bdev);
+
+               if (!opts->no_splitbrain_check) {
+                       prt_str(&buf, "Not using ");
+                       prt_bdevname(&buf, sb->bdev);
+               }
 
                pr_err("%s", buf.buf);
                printbuf_exit(&buf);
-               return -BCH_ERR_device_splitbrain;
+
+               if (!opts->no_splitbrain_check)
+                       return -BCH_ERR_device_splitbrain;
        }
 
        return 0;
@@ -1835,7 +1844,7 @@ int bch2_dev_online(struct bch_fs *c, const char *path)
 
        dev_idx = sb.sb->dev_idx;
 
-       ret = bch2_dev_in_fs(&c->disk_sb, &sb);
+       ret = bch2_dev_in_fs(&c->disk_sb, &sb, &c->opts);
        bch_err_msg(c, ret, "bringing %s online", path);
        if (ret)
                goto err;
@@ -2023,7 +2032,7 @@ struct bch_fs *bch2_fs_open(char * const *devices, unsigned nr_devices,
                        best = sb;
 
        darray_for_each_reverse(sbs, sb) {
-               ret = bch2_dev_in_fs(best, sb);
+               ret = bch2_dev_in_fs(best, sb, &opts);
 
                if (ret == -BCH_ERR_device_has_been_removed ||
                    ret == -BCH_ERR_device_splitbrain) {