bcachefs: Run gc if failed to read alloc btree
authorKent Overstreet <kent.overstreet@gmail.com>
Thu, 21 Mar 2019 23:02:48 +0000 (19:02 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:18 +0000 (17:08 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/recovery.c

index 9610b488fbdf1c14b47e6783cb7420bdb3b29244..24101023a5b9ebe37d364c03363828425b7cd976 100644 (file)
@@ -187,6 +187,8 @@ int bch2_fs_recovery(struct bch_fs *c)
        LIST_HEAD(journal);
        struct jset *j = NULL;
        unsigned i;
+       bool run_gc = c->opts.fsck ||
+               !(c->sb.compat & (1ULL << BCH_COMPAT_FEAT_ALLOC_INFO));
        int ret;
 
        mutex_lock(&c->sb_lock);
@@ -282,6 +284,7 @@ int bch2_fs_recovery(struct bch_fs *c)
                                goto err;
 
                        mustfix_fsck_err(c, "error reading btree root");
+                       run_gc = true;
                }
        }
 
@@ -302,8 +305,7 @@ int bch2_fs_recovery(struct bch_fs *c)
 
        set_bit(BCH_FS_ALLOC_READ_DONE, &c->flags);
 
-       if (!(c->sb.compat & (1ULL << BCH_COMPAT_FEAT_ALLOC_INFO)) ||
-           c->opts.fsck) {
+       if (run_gc) {
                bch_verbose(c, "starting mark and sweep:");
                err = "error in recovery";
                ret = bch2_gc(c, &journal, true);