summaryrefslogtreecommitdiff
path: root/libbcachefs
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-12-23 19:55:43 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-12-24 08:48:31 -0500
commitd101ad4a61ce48c498936b28eedcf0e01a568d49 (patch)
treec17afc92fb6a545731dea86e15ef4fb7d7ec5a76 /libbcachefs
parentd01f3f590ca50e9c5c32324a31a4af1158afe8e3 (diff)
Update bcachefs sources to 44ac32df8e0c bcachefs: Split brain detection
Diffstat (limited to 'libbcachefs')
-rw-r--r--libbcachefs/opts.h2
-rw-r--r--libbcachefs/recovery.c6
-rw-r--r--libbcachefs/super.c23
3 files changed, 17 insertions, 14 deletions
diff --git a/libbcachefs/opts.h b/libbcachefs/opts.h
index cf69b92c..42cad83e 100644
--- a/libbcachefs/opts.h
+++ b/libbcachefs/opts.h
@@ -389,7 +389,7 @@ enum fsck_err_opts {
BCH2_NO_SB_OPT, BCH_SB_SECTOR, \
"offset", "Sector offset of superblock") \
x(read_only, u8, \
- OPT_FS, \
+ OPT_FS|OPT_MOUNT, \
OPT_BOOL(), \
BCH2_NO_SB_OPT, false, \
NULL, NULL) \
diff --git a/libbcachefs/recovery.c b/libbcachefs/recovery.c
index 69eec4eb..ec206139 100644
--- a/libbcachefs/recovery.c
+++ b/libbcachefs/recovery.c
@@ -737,7 +737,7 @@ int bch2_fs_recovery(struct bch_fs *c)
goto err;
}
- if (c->opts.fsck || !(c->opts.nochanges && c->opts.norecovery))
+ if (!(c->opts.nochanges && c->opts.norecovery))
check_version_upgrade(c);
if (c->opts.fsck && c->opts.norecovery) {
@@ -979,7 +979,9 @@ out:
bch2_journal_keys_put_initial(c);
kfree(clean);
- if (!ret && test_bit(BCH_FS_need_delete_dead_snapshots, &c->flags)) {
+ if (!ret &&
+ test_bit(BCH_FS_need_delete_dead_snapshots, &c->flags) &&
+ !c->opts.nochanges) {
bch2_fs_read_write_early(c);
bch2_delete_dead_snapshots_async(c);
}
diff --git a/libbcachefs/super.c b/libbcachefs/super.c
index e7b81dbd..0f189c9d 100644
--- a/libbcachefs/super.c
+++ b/libbcachefs/super.c
@@ -433,16 +433,6 @@ static int __bch2_fs_read_write(struct bch_fs *c, bool early)
if (test_bit(BCH_FS_rw, &c->flags))
return 0;
- if (c->opts.norecovery)
- return -BCH_ERR_erofs_norecovery;
-
- /*
- * nochanges is used for fsck -n mode - we have to allow going rw
- * during recovery for that to work:
- */
- if (c->opts.nochanges && (!early || c->opts.read_only))
- return -BCH_ERR_erofs_nochanges;
-
bch_info(c, "going read-write");
ret = bch2_sb_members_v2_init(c);
@@ -510,6 +500,12 @@ err:
int bch2_fs_read_write(struct bch_fs *c)
{
+ if (c->opts.norecovery)
+ return -BCH_ERR_erofs_norecovery;
+
+ if (c->opts.nochanges)
+ return -BCH_ERR_erofs_nochanges;
+
return __bch2_fs_read_write(c, false);
}
@@ -1033,7 +1029,7 @@ int bch2_fs_start(struct bch_fs *c)
set_bit(BCH_FS_started, &c->flags);
- if (c->opts.read_only || c->opts.nochanges) {
+ if (c->opts.read_only) {
bch2_fs_read_only(c);
} else {
ret = !test_bit(BCH_FS_rw, &c->flags)
@@ -1996,6 +1992,11 @@ struct bch_fs *bch2_fs_open(char * const *devices, unsigned nr_devices,
BUG_ON(darray_push(&sbs, sb));
}
+ if (opts.nochanges && !opts.read_only) {
+ ret = -BCH_ERR_erofs_nochanges;
+ goto err_print;
+ }
+
darray_for_each(sbs, sb)
if (!best || sb_cmp(sb->sb, best->sb) > 0)
best = sb;