]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
bcachefs: bch2_run_explicit_recovery_pass() returns different error when not in recovery
authorKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Sep 2024 00:21:18 +0000 (20:21 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sat, 21 Dec 2024 06:36:14 +0000 (01:36 -0500)
if we're not in recovery then there's no way to rewind recovery - give
this a different errcode so that any error messages will give us a
better idea of what happened.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/errcode.h
fs/bcachefs/recovery_passes.c

index e3b0ec7a0f7346bf948f2ad5232c9c3e0a4195e2..40bf1e5775a91ea9e4978b5f21aff0dd094ba230 100644 (file)
        x(BCH_ERR_fsck,                 fsck_errors_not_fixed)                  \
        x(BCH_ERR_fsck,                 fsck_repair_unimplemented)              \
        x(BCH_ERR_fsck,                 fsck_repair_impossible)                 \
-       x(0,                            restart_recovery)                       \
+       x(EINVAL,                       restart_recovery)                       \
+       x(EINVAL,                       not_in_recovery)                        \
+       x(EINVAL,                       cannot_rewind_recovery)                 \
        x(0,                            data_update_done)                       \
        x(EINVAL,                       device_state_not_allowed)               \
        x(EINVAL,                       member_info_missing)                    \
index dff589ddc984d34b99ae430af15e3cad17a11f62..1cc010bf1695555082ed660a0a6378ebe793d032 100644 (file)
@@ -106,6 +106,9 @@ int bch2_run_explicit_recovery_pass(struct bch_fs *c,
        if (c->opts.recovery_passes & BIT_ULL(pass))
                return 0;
 
+       if (c->curr_recovery_pass == ARRAY_SIZE(recovery_pass_fns))
+               return -BCH_ERR_not_in_recovery;
+
        bch_info(c, "running explicit recovery pass %s (%u), currently at %s (%u)",
                 bch2_recovery_passes[pass], pass,
                 bch2_recovery_passes[c->curr_recovery_pass], c->curr_recovery_pass);