]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bcachefs: Reduce usage of recovery.curr_pass
authorKent Overstreet <kent.overstreet@linux.dev>
Tue, 13 May 2025 21:36:55 +0000 (17:36 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 22 May 2025 00:15:03 +0000 (20:15 -0400)
We want recovery.curr_pass to be private to the recovery passes code,
for better showing recovery pass status; also, it may rewind and is
generally not the correct member to use.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/alloc_background.c
fs/bcachefs/alloc_foreground.c
fs/bcachefs/backpointers.c
fs/bcachefs/btree_cache.c
fs/bcachefs/btree_io.c
fs/bcachefs/btree_update_interior.c
fs/bcachefs/fsck.c
fs/bcachefs/snapshot.c

index 4ae2aa6ea758a54fe0e6a23f961e75da7add5dbf..88e710ba2685198b25512506279555bd35fdc4b9 100644 (file)
@@ -309,7 +309,8 @@ int bch2_alloc_v4_validate(struct bch_fs *c, struct bkey_s_c k,
                                 "data type inconsistency");
 
                bkey_fsck_err_on(!a.io_time[READ] &&
-                                c->recovery.curr_pass > BCH_RECOVERY_PASS_check_alloc_to_lru_refs,
+                                !(c->recovery.passes_to_run &
+                                  BIT_ULL(BCH_RECOVERY_PASS_check_alloc_to_lru_refs)),
                                 c, alloc_key_cached_but_read_time_zero,
                                 "cached bucket with read_time == 0");
                break;
index 76641cc4c27dbc26f932ab3ef78b7f77df7acbe4..1a52c12c51ae60ade376dc87e639671d521a06bf 100644 (file)
@@ -154,7 +154,7 @@ static struct open_bucket *bch2_open_bucket_alloc(struct bch_fs *c)
 
 static inline bool is_superblock_bucket(struct bch_fs *c, struct bch_dev *ca, u64 b)
 {
-       if (c->recovery.curr_pass > BCH_RECOVERY_PASS_trans_mark_dev_sbs)
+       if (c->recovery.passes_complete & BIT_ULL(BCH_RECOVERY_PASS_trans_mark_dev_sbs))
                return false;
 
        return bch2_is_superblock_bucket(ca, b);
@@ -524,7 +524,7 @@ again:
 
        if (!avail) {
                if (req->watermark > BCH_WATERMARK_normal &&
-                   c->recovery.curr_pass <= BCH_RECOVERY_PASS_check_allocations)
+                   c->recovery.pass_done < BCH_RECOVERY_PASS_check_allocations)
                        goto alloc;
 
                if (cl && !waiting) {
@@ -554,7 +554,7 @@ alloc:
                goto alloc;
        }
 
-       if (!ob && freespace && c->recovery.curr_pass <= BCH_RECOVERY_PASS_check_alloc_info) {
+       if (!ob && freespace && c->recovery.pass_done < BCH_RECOVERY_PASS_check_alloc_info) {
                freespace = false;
                goto alloc;
        }
index 44da8e2657af364e29a1ff1549e97d576631bd44..d9ddfc4b5dcc763b68e85e96f4c6587bcae20269 100644 (file)
@@ -104,6 +104,8 @@ static noinline int backpointer_mod_err(struct btree_trans *trans,
 {
        struct bch_fs *c = trans->c;
        struct printbuf buf = PRINTBUF;
+       bool will_check = c->recovery.passes_to_run &
+               BIT_ULL(BCH_RECOVERY_PASS_check_extents_to_backpointers);
        int ret = 0;
 
        if (insert) {
@@ -120,7 +122,7 @@ static noinline int backpointer_mod_err(struct btree_trans *trans,
                bch2_bkey_val_to_text(&buf, c, orig_k);
 
                bch_err(c, "%s", buf.buf);
-       } else if (c->recovery.curr_pass > BCH_RECOVERY_PASS_check_extents_to_backpointers) {
+       } else if (!will_check) {
                prt_printf(&buf, "backpointer not found when deleting\n");
                printbuf_indent_add(&buf, 2);
 
@@ -136,8 +138,7 @@ static noinline int backpointer_mod_err(struct btree_trans *trans,
                bch2_bkey_val_to_text(&buf, c, orig_k);
        }
 
-       if (c->recovery.curr_pass > BCH_RECOVERY_PASS_check_extents_to_backpointers &&
-           __bch2_inconsistent_error(c, &buf))
+       if (!will_check && __bch2_inconsistent_error(c, &buf))
                ret = -BCH_ERR_erofs_unfixed_errors;
 
        bch_err(c, "%s", buf.buf);
index b1932b6a514b93d5361b616ee0c22bf502fbfd53..8557cbd3d818bb6f22e7d1b1791cacc4ecb42282 100644 (file)
@@ -1003,7 +1003,7 @@ static noinline void btree_bad_header(struct bch_fs *c, struct btree *b)
 {
        struct printbuf buf = PRINTBUF;
 
-       if (c->recovery.curr_pass <= BCH_RECOVERY_PASS_check_allocations)
+       if (c->recovery.pass_done < BCH_RECOVERY_PASS_check_allocations)
                return;
 
        prt_printf(&buf,
index e5db374f001baac7db61d9bdf0c102b991a1f657..34018296053a2ab99cb49324c6219eda6f919076 100644 (file)
@@ -1775,8 +1775,7 @@ void bch2_btree_node_read(struct btree_trans *trans, struct btree *b,
                prt_newline(&buf);
                bch2_btree_lost_data(c, &buf, b->c.btree_id);
 
-               if (c->opts.recovery_passes & BIT_ULL(BCH_RECOVERY_PASS_check_topology) &&
-                   c->recovery.curr_pass > BCH_RECOVERY_PASS_check_topology &&
+               if (c->recovery.passes_complete & BIT_ULL(BCH_RECOVERY_PASS_check_topology) &&
                    bch2_fs_emergency_read_only2(c, &buf))
                        ratelimit = false;
 
index a658c97439ed8b071ed23fbfecb064b3ae7055e4..74e65714fecdce0368d289a86c1261650792765e 100644 (file)
@@ -2363,7 +2363,7 @@ void bch2_btree_node_rewrite_async(struct bch_fs *c, struct btree *b)
        bool now = false, pending = false;
 
        spin_lock(&c->btree_node_rewrites_lock);
-       if (c->recovery.curr_pass > BCH_RECOVERY_PASS_journal_replay &&
+       if (c->recovery.passes_complete & BIT_ULL(BCH_RECOVERY_PASS_journal_replay) &&
            enumerated_ref_tryget(&c->writes, BCH_WRITE_REF_node_rewrite)) {
                list_add(&a->list, &c->btree_node_rewrites);
                now = true;
index 0e223d4ae2ec977bd8c19216a2fae1436d4ca3d9..2a7f418f3d8715efb0e10f736e2276a0e63b8c5d 100644 (file)
@@ -3177,7 +3177,6 @@ static int bch2_fsck_online_thread_fn(struct thread_with_stdio *stdio)
        c->opts.fsck = true;
        set_bit(BCH_FS_in_fsck, &c->flags);
 
-       c->recovery.curr_pass = BCH_RECOVERY_PASS_check_alloc_info;
        int ret = bch2_run_online_recovery_passes(c, ~0ULL);
 
        clear_bit(BCH_FS_in_fsck, &c->flags);
index c401d5285701cc8ca55db3a1345127f04313635a..24903e7de296c76f8215f13f5326ab0c58f59e80 100644 (file)
@@ -348,7 +348,7 @@ static int __bch2_mark_snapshot(struct btree_trans *trans,
 
                if (BCH_SNAPSHOT_WILL_DELETE(s.v)) {
                        set_bit(BCH_FS_need_delete_dead_snapshots, &c->flags);
-                       if (c->recovery.curr_pass > BCH_RECOVERY_PASS_delete_dead_snapshots)
+                       if (c->recovery.pass_done > BCH_RECOVERY_PASS_delete_dead_snapshots)
                                bch2_delete_dead_snapshots_async(c);
                }
        } else {