Skip to content

Commit 64b6a78

Browse files
author
Kent Overstreet
committed
bcachefs: Ensure we rewind to run recovery passes
Fix a 6.16 regression from the recovery pass rework, which introduced a bug where calling bch2_run_explicit_recovery_pass() would only return the error code to rewind recovery for the first call that scheduled that recovery pass. If the error code from the first call was swallowed (because it was called by an asynchronous codepath), subsequent calls would go "ok, this pass is already marked as needing to run" and return 0. Fixing this ensures that check_topology bails out to run btree_node_scan before doing any repair. Signed-off-by: Kent Overstreet <[email protected]>
1 parent 3e72acb commit 64b6a78

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

fs/bcachefs/recovery_passes.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@ static bool recovery_pass_needs_set(struct bch_fs *c,
313313
*/
314314
bool in_recovery = test_bit(BCH_FS_in_recovery, &c->flags);
315315
bool persistent = !in_recovery || !(*flags & RUN_RECOVERY_PASS_nopersistent);
316+
bool rewind = in_recovery &&
317+
r->curr_pass > pass &&
318+
!(r->passes_complete & BIT_ULL(pass));
316319

317320
if (persistent
318321
? !(c->sb.recovery_passes_required & BIT_ULL(pass))
@@ -323,6 +326,9 @@ static bool recovery_pass_needs_set(struct bch_fs *c,
323326
(r->passes_ratelimiting & BIT_ULL(pass)))
324327
return true;
325328

329+
if (rewind)
330+
return true;
331+
326332
return false;
327333
}
328334

@@ -337,7 +343,6 @@ int __bch2_run_explicit_recovery_pass(struct bch_fs *c,
337343
struct bch_fs_recovery *r = &c->recovery;
338344
int ret = 0;
339345

340-
341346
lockdep_assert_held(&c->sb_lock);
342347

343348
bch2_printbuf_make_room(out, 1024);
@@ -408,10 +413,8 @@ int bch2_run_explicit_recovery_pass(struct bch_fs *c,
408413
{
409414
int ret = 0;
410415

411-
scoped_guard(mutex, &c->sb_lock) {
412-
if (!recovery_pass_needs_set(c, pass, &flags))
413-
return 0;
414-
416+
if (recovery_pass_needs_set(c, pass, &flags)) {
417+
guard(mutex)(&c->sb_lock);
415418
ret = __bch2_run_explicit_recovery_pass(c, out, pass, flags);
416419
bch2_write_super(c);
417420
}

0 commit comments

Comments
 (0)