From 067d228bb0c40542620398ef1d79f00f47c05cbb Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Fri, 7 Jul 2023 02:42:28 -0400 Subject: bcachefs: Enumerate recovery passes Recovery and fsck have many different passes/jobs to do, which always run in the same order - but not all of them run all the time. Some are for fsck, some for unclean shutdown, some for version upgrades. This adds some new structure: a defined list of recovery passes that we can run in a loop, as well as consolidating the log messages. The main benefit is consolidating the "should run this recovery pass" logic, as well as cleaning up the "this recovery pass has finished" state; instead of having a bunch of ad-hoc state bits in c->flags, we've now got c->curr_recovery_pass. By consolidating the "should run this recovery pass" logic, in the future on disk format upgrades will be able to say "upgrading to this version requires x passes to run", instead of forcing all of fsck to run. Signed-off-by: Kent Overstreet --- fs/bcachefs/backpointers.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'fs/bcachefs/backpointers.c') diff --git a/fs/bcachefs/backpointers.c b/fs/bcachefs/backpointers.c index 571a7d19bea7..d412bae553a0 100644 --- a/fs/bcachefs/backpointers.c +++ b/fs/bcachefs/backpointers.c @@ -104,7 +104,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 (test_bit(BCH_FS_CHECK_BACKPOINTERS_DONE, &c->flags)) { + } else if (c->curr_recovery_pass > BCH_RECOVERY_PASS_check_extents_to_backpointers) { prt_printf(&buf, "backpointer not found when deleting"); prt_newline(&buf); printbuf_indent_add(&buf, 2); @@ -125,7 +125,7 @@ static noinline int backpointer_mod_err(struct btree_trans *trans, printbuf_exit(&buf); - if (test_bit(BCH_FS_CHECK_BACKPOINTERS_DONE, &c->flags)) { + if (c->curr_recovery_pass > BCH_RECOVERY_PASS_check_extents_to_backpointers) { bch2_inconsistent_error(c); return -EIO; } else { @@ -258,7 +258,7 @@ static void backpointer_not_found(struct btree_trans *trans, bch2_backpointer_to_text(&buf, &bp); prt_printf(&buf, "\n "); bch2_bkey_val_to_text(&buf, c, k); - if (!test_bit(BCH_FS_CHECK_BACKPOINTERS_DONE, &c->flags)) + if (c->curr_recovery_pass >= BCH_RECOVERY_PASS_check_extents_to_backpointers) bch_err_ratelimited(c, "%s", buf.buf); else bch2_trans_inconsistent(trans, "%s", buf.buf); -- cgit v1.2.3