Skip to content

Commit 625c494

Browse files
author
Kent Overstreet
committed
bcachefs: Fix version checks in validate_bset()
It seems btree node scan picked up a partially overwritten btree node, and corrected the "bset version older than sb version_min" error - resulting in an invalid superblock with a bad version_min field. Don't run this check at all when we're in btree node scan, and when we do run it, do something saner if the bset version is totally crazy. Signed-off-by: Kent Overstreet <[email protected]>
1 parent e82b3a6 commit 625c494

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

fs/bcachefs/btree_io.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -741,16 +741,22 @@ static int validate_bset(struct bch_fs *c, struct bch_dev *ca,
741741
BCH_VERSION_MAJOR(version),
742742
BCH_VERSION_MINOR(version));
743743

744-
if (btree_err_on(version < c->sb.version_min,
744+
if (c->recovery.curr_pass != BCH_RECOVERY_PASS_scan_for_btree_nodes &&
745+
btree_err_on(version < c->sb.version_min,
745746
-BCH_ERR_btree_node_read_err_fixable,
746747
c, NULL, b, i, NULL,
747748
btree_node_bset_older_than_sb_min,
748749
"bset version %u older than superblock version_min %u",
749750
version, c->sb.version_min)) {
750-
mutex_lock(&c->sb_lock);
751-
c->disk_sb.sb->version_min = cpu_to_le16(version);
752-
bch2_write_super(c);
753-
mutex_unlock(&c->sb_lock);
751+
if (bch2_version_compatible(version)) {
752+
mutex_lock(&c->sb_lock);
753+
c->disk_sb.sb->version_min = cpu_to_le16(version);
754+
bch2_write_super(c);
755+
mutex_unlock(&c->sb_lock);
756+
} else {
757+
/* We have no idea what's going on: */
758+
i->version = cpu_to_le16(c->sb.version);
759+
}
754760
}
755761

756762
if (btree_err_on(BCH_VERSION_MAJOR(version) >

0 commit comments

Comments
 (0)