Commit 2f300f09 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: no_splitbrain_check option

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: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 88005d5d
...@@ -290,6 +290,11 @@ enum fsck_err_opts { ...@@ -290,6 +290,11 @@ enum fsck_err_opts {
OPT_BOOL(), \ OPT_BOOL(), \
BCH2_NO_SB_OPT, false, \ BCH2_NO_SB_OPT, false, \
NULL, "Allow mounting in when data will be missing") \ 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, \ x(discard, u8, \
OPT_FS|OPT_MOUNT|OPT_DEVICE, \ OPT_FS|OPT_MOUNT|OPT_DEVICE, \
OPT_BOOL(), \ OPT_BOOL(), \
......
...@@ -1061,7 +1061,8 @@ static int bch2_dev_may_add(struct bch_sb *sb, struct bch_fs *c) ...@@ -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, 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) if (fs == sb)
return 0; return 0;
...@@ -1102,10 +1103,13 @@ static int bch2_dev_in_fs(struct bch_sb_handle *fs, ...@@ -1102,10 +1103,13 @@ static int bch2_dev_in_fs(struct bch_sb_handle *fs,
bch2_prt_datetime(&buf, le64_to_cpu(sb->sb->write_time));; bch2_prt_datetime(&buf, le64_to_cpu(sb->sb->write_time));;
prt_newline(&buf); prt_newline(&buf);
if (!opts->no_splitbrain_check)
prt_printf(&buf, "Not using older sb"); prt_printf(&buf, "Not using older sb");
pr_err("%s", buf.buf); pr_err("%s", buf.buf);
printbuf_exit(&buf); printbuf_exit(&buf);
if (!opts->no_splitbrain_check)
return -BCH_ERR_device_splitbrain; return -BCH_ERR_device_splitbrain;
} }
...@@ -1129,11 +1133,16 @@ static int bch2_dev_in_fs(struct bch_sb_handle *fs, ...@@ -1129,11 +1133,16 @@ static int bch2_dev_in_fs(struct bch_sb_handle *fs,
prt_printf(&buf, " to be %llu, but ", seq_from_fs); prt_printf(&buf, " to be %llu, but ", seq_from_fs);
prt_bdevname(&buf, sb->bdev); prt_bdevname(&buf, sb->bdev);
prt_printf(&buf, " has %llu\n", seq_from_member); prt_printf(&buf, " has %llu\n", seq_from_member);
if (!opts->no_splitbrain_check) {
prt_str(&buf, "Not using "); prt_str(&buf, "Not using ");
prt_bdevname(&buf, sb->bdev); prt_bdevname(&buf, sb->bdev);
}
pr_err("%s", buf.buf); pr_err("%s", buf.buf);
printbuf_exit(&buf); printbuf_exit(&buf);
if (!opts->no_splitbrain_check)
return -BCH_ERR_device_splitbrain; return -BCH_ERR_device_splitbrain;
} }
...@@ -1835,7 +1844,7 @@ int bch2_dev_online(struct bch_fs *c, const char *path) ...@@ -1835,7 +1844,7 @@ int bch2_dev_online(struct bch_fs *c, const char *path)
dev_idx = sb.sb->dev_idx; 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); bch_err_msg(c, ret, "bringing %s online", path);
if (ret) if (ret)
goto err; goto err;
...@@ -2023,7 +2032,7 @@ struct bch_fs *bch2_fs_open(char * const *devices, unsigned nr_devices, ...@@ -2023,7 +2032,7 @@ struct bch_fs *bch2_fs_open(char * const *devices, unsigned nr_devices,
best = sb; best = sb;
darray_for_each_reverse(sbs, 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 || if (ret == -BCH_ERR_device_has_been_removed ||
ret == -BCH_ERR_device_splitbrain) { ret == -BCH_ERR_device_splitbrain) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment