]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd/scrub: allow auto-repair on operator-initiated scrubs
authorRonen Friedman <rfriedma@redhat.com>
Wed, 22 Nov 2023 09:56:44 +0000 (11:56 +0200)
committerRonen Friedman <rfriedma@redhat.com>
Wed, 22 Nov 2023 09:56:44 +0000 (11:56 +0200)
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 <rfriedma@redhat.com>
src/osd/PG.cc
src/osd/scrubber_common.h

index d2f97a129a241336ea91d2d3f35fa450607b7c62..bda1d206b9dd3ed75c6e39db5c3d4b331f2449a3 100644 (file)
@@ -1490,7 +1490,7 @@ std::optional<requested_scrub_t> 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<requested_scrub_t> 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;
 }
 
index 16810bba15c651b720edd7ae78a103fb1dbfdf90..b9426b9c64f03777cbc35282b28e12f0643be746 100644 (file)
@@ -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};