diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-12-22 21:58:43 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-01-01 11:47:42 -0500 |
commit | 447c1c01051251853e851bd77f26546488cbc7b7 (patch) | |
tree | 1d43595b204ce9e6406516e5ddee97d31e47e536 /fs/bcachefs/super-io.c | |
parent | 44fd13a4c68e87953ccd827e764fa566ddcbbcf5 (diff) | |
download | linux-447c1c01051251853e851bd77f26546488cbc7b7.tar.gz linux-447c1c01051251853e851bd77f26546488cbc7b7.tar.bz2 linux-447c1c01051251853e851bd77f26546488cbc7b7.zip |
bcachefs: check for failure to downgrade
With the upcoming member seq patch, it's now critical that we don't ever
write to a superblock that hasn't been version downgraded - failure to
update member seq fields will cause split brain detection to fire
erroniously.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/super-io.c')
-rw-r--r-- | fs/bcachefs/super-io.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c index 55e560c198de..b610dfb0287a 100644 --- a/fs/bcachefs/super-io.c +++ b/fs/bcachefs/super-io.c @@ -987,6 +987,18 @@ int bch2_write_super(struct bch_fs *c) if (!BCH_SB_INITIALIZED(c->disk_sb.sb)) goto out; + if (le16_to_cpu(c->disk_sb.sb->version) > bcachefs_metadata_version_current) { + struct printbuf buf = PRINTBUF; + prt_printf(&buf, "attempting to write superblock that wasn't version downgraded ("); + bch2_version_to_text(&buf, le16_to_cpu(c->disk_sb.sb->version)); + prt_str(&buf, " > "); + bch2_version_to_text(&buf, bcachefs_metadata_version_current); + prt_str(&buf, ")"); + bch2_fs_fatal_error(c, "%s", buf.buf); + printbuf_exit(&buf); + return -BCH_ERR_sb_not_downgraded; + } + for_each_online_member(ca, c, i) { __set_bit(ca->dev_idx, sb_written.d); ca->sb_write_error = 0; |