From 3904b6754e7defb7e819b4854920896dd0496152 Mon Sep 17 00:00:00 2001 From: Ronen Friedman Date: Wed, 22 Nov 2023 11:56:44 +0200 Subject: [PATCH] osd/scrub: allow auto-repair on operator-initiated scrubs Previously, operator-initiated scrubs would not auto-repair, regardless of the value of the 'osd_scrub_auto_repair' config option. This was less confusing to the operator than it could have been, as most operator commands would in fact cause a regular periodic scrub to be initiated. However, that quirk is now fixed: operator commands now trigger 'op-initiated' scrubs. Thus the need for this patch. Signed-off-by: Ronen Friedman --- src/osd/PG.cc | 21 ++++++++++++++++++++- src/osd/scrubber_common.h | 3 +-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index d2f97a129a2..bda1d206b9d 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -1490,7 +1490,7 @@ std::optional PG::validate_initiated_scrub( upd_flags.time_for_deep = time_for_deep; upd_flags.deep_scrub_on_error = false; - upd_flags.auto_repair = false; // will only be considered for periodic scrubs + upd_flags.auto_repair = false; if (upd_flags.must_deep_scrub) { upd_flags.calculated_to_deep = true; @@ -1506,6 +1506,25 @@ std::optional PG::validate_initiated_scrub( } } + if (try_to_auto_repair) { + // for shallow scrubs: rescrub if errors found + // for deep: turn 'auto-repair' on + if (upd_flags.calculated_to_deep) { + dout(10) << fmt::format( + "{}: performing an auto-repair deep scrub", + __func__) + << dendl; + upd_flags.auto_repair = true; + } else { + dout(10) << fmt::format( + "{}: will perform an auto-repair deep scrub if errors " + "are found", + __func__) + << dendl; + upd_flags.deep_scrub_on_error = true; + } + } + return upd_flags; } diff --git a/src/osd/scrubber_common.h b/src/osd/scrubber_common.h index 16810bba15c..b9426b9c64f 100644 --- a/src/osd/scrubber_common.h +++ b/src/osd/scrubber_common.h @@ -169,8 +169,7 @@ struct requested_scrub_t { * the value of auto_repair is determined in sched_scrub() (once per scrub. * previous value is not remembered). Set if * - allowed by configuration and backend, and - * - must_scrub is not set (i.e. - this is a periodic scrub), - * - time_for_deep was just set + * - for periodic scrubs: time_for_deep was just set */ bool auto_repair{false}; -- 2.39.5