bcachefs: Run fsck if BCH_FEATURE_alloc_v2 isn't set
authorKent Overstreet <kent.overstreet@gmail.com>
Wed, 3 Feb 2021 20:31:17 +0000 (15:31 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:53 +0000 (17:08 -0400)
We're using BCH_FEATURE_alloc_v2 to also gate journalling updates to dev
usage - we don't have the code for reconstructing this from buckets
anymore, so we need to run fsck if it's not set.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/recovery.c

index 7ba098adcab9b20f2e70e8aeeaaf28a868828cb9..8560023b4c7ad007fae235ce0efc4f7a67069597 100644 (file)
@@ -1088,6 +1088,13 @@ int bch2_fs_recovery(struct bch_fs *c)
                bch_info(c, "recovering from clean shutdown, journal seq %llu",
                         le64_to_cpu(clean->journal_seq));
 
+       if (!(c->sb.features & (1ULL << BCH_FEATURE_alloc_v2))) {
+               bch_info(c, "alloc_v2 feature bit not set, fsck required");
+               c->opts.fsck = true;
+               c->opts.fix_errors = FSCK_OPT_YES;
+               c->disk_sb.sb->features[0] |= 1ULL << BCH_FEATURE_alloc_v2;
+       }
+
        if (!c->replicas.entries ||
            c->opts.rebuild_replicas) {
                bch_info(c, "building replicas info");