mirror of
https://github.com/torvalds/linux.git
synced 2026-06-07 05:55:44 +02:00
bcachefs: bch2_require_recovery_pass()
Add a helper for requiring that a recovery pass has already run: either run it directly, if we're still in recovery, or if we're not in recovery check if it has run recently and schedule it if it hasn't. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
09b9c72bd4
commit
a2ffab0e65
|
|
@ -182,9 +182,12 @@
|
|||
x(BCH_ERR_fsck, fsck_errors_not_fixed) \
|
||||
x(BCH_ERR_fsck, fsck_repair_unimplemented) \
|
||||
x(BCH_ERR_fsck, fsck_repair_impossible) \
|
||||
x(EINVAL, restart_recovery) \
|
||||
x(EINVAL, cannot_rewind_recovery) \
|
||||
x(EINVAL, recovery_will_run) \
|
||||
x(BCH_ERR_recovery_will_run, restart_recovery) \
|
||||
x(BCH_ERR_recovery_will_run, cannot_rewind_recovery) \
|
||||
x(BCH_ERR_recovery_will_run, recovery_pass_will_run) \
|
||||
x(0, data_update_done) \
|
||||
x(0, bkey_was_deleted) \
|
||||
x(BCH_ERR_data_update_done, data_update_done_would_block) \
|
||||
x(BCH_ERR_data_update_done, data_update_done_unwritten) \
|
||||
x(BCH_ERR_data_update_done, data_update_done_no_writes_needed) \
|
||||
|
|
|
|||
|
|
@ -384,6 +384,35 @@ int bch2_run_explicit_recovery_pass(struct bch_fs *c,
|
|||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns 0 if @pass has run recently, otherwise one of
|
||||
* -BCH_ERR_restart_recovery
|
||||
* -BCH_ERR_recovery_pass_will_run
|
||||
*/
|
||||
int bch2_require_recovery_pass(struct bch_fs *c,
|
||||
struct printbuf *out,
|
||||
enum bch_recovery_pass pass)
|
||||
{
|
||||
if (test_bit(BCH_FS_in_recovery, &c->flags) &&
|
||||
c->recovery.passes_complete & BIT_ULL(pass))
|
||||
return 0;
|
||||
|
||||
guard(mutex)(&c->sb_lock);
|
||||
|
||||
if (bch2_recovery_pass_want_ratelimit(c, pass))
|
||||
return 0;
|
||||
|
||||
enum bch_run_recovery_pass_flags flags = 0;
|
||||
int ret = 0;
|
||||
|
||||
if (recovery_pass_needs_set(c, pass, &flags)) {
|
||||
ret = __bch2_run_explicit_recovery_pass(c, out, pass, flags);
|
||||
bch2_write_super(c);
|
||||
}
|
||||
|
||||
return ret ?: bch_err_throw(c, recovery_pass_will_run);
|
||||
}
|
||||
|
||||
int bch2_run_print_explicit_recovery_pass(struct bch_fs *c, enum bch_recovery_pass pass)
|
||||
{
|
||||
enum bch_run_recovery_pass_flags flags = RUN_RECOVERY_PASS_nopersistent;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@ int bch2_run_explicit_recovery_pass(struct bch_fs *, struct printbuf *,
|
|||
enum bch_recovery_pass,
|
||||
enum bch_run_recovery_pass_flags);
|
||||
|
||||
int bch2_require_recovery_pass(struct bch_fs *, struct printbuf *,
|
||||
enum bch_recovery_pass);
|
||||
|
||||
int bch2_run_online_recovery_passes(struct bch_fs *, u64);
|
||||
int bch2_run_recovery_passes(struct bch_fs *, enum bch_recovery_pass);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user