]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd/scrub: renaming & fmt support for restrictions structure
authorRonen Friedman <rfriedma@redhat.com>
Sun, 10 Sep 2023 18:32:53 +0000 (13:32 -0500)
committerRonen Friedman <rfriedma@redhat.com>
Wed, 20 Sep 2023 06:39:10 +0000 (01:39 -0500)
Renaming ScrubPreconds, the collection of "environmental"
restrictions on possible scrubs, to OSDRestrictions.
Also - providing fmtlib support for that structure.

Signed-off-by: Ronen Friedman <rfriedma@redhat.com>
src/osd/scrubber/osd_scrub.cc
src/osd/scrubber/osd_scrub_sched.cc
src/osd/scrubber/osd_scrub_sched.h
src/osd/scrubber_common.h

index a53e47d27456df4899ac264e34eaebf2291029c7..fe92fd63c7dbd3c9c88f7739671a05c893c639f4 100644 (file)
@@ -82,7 +82,7 @@ void OSD::sched_scrub()
     return;
   }
 
-  Scrub::ScrubPreconds env_conditions;
+  Scrub::OSDRestrictions env_conditions;
 
   if (service.is_recovery_active() && !cct->_conf->osd_scrub_during_recovery) {
     if (!cct->_conf->osd_repair_during_recovery) {
index 64b44e0dc32331344ee2e4d9101092bc905a1d9c..b07b4385a58bcf1c04781daa710a1a58273307ea 100644 (file)
@@ -321,7 +321,7 @@ std::string_view ScrubQueue::qu_state_text(qu_state_t st)
  *    - try that one. If not suitable, discard from 'to_scrub_copy'
  */
 Scrub::schedule_result_t ScrubQueue::select_pg_and_scrub(
-  Scrub::ScrubPreconds& preconds)
+  Scrub::OSDRestrictions& preconds)
 {
   dout(10) << " reg./pen. sizes: " << to_scrub.size() << " / "
           << penalized.size() << dendl;
@@ -437,7 +437,7 @@ ScrubQueue::ScrubQContainer ScrubQueue::collect_ripe_jobs(
 // not holding jobs_lock. 'group' is a copy of the actual list.
 Scrub::schedule_result_t ScrubQueue::select_from_group(
   ScrubQContainer& group,
-  const Scrub::ScrubPreconds& preconds,
+  const Scrub::OSDRestrictions& preconds,
   utime_t now_is)
 {
   dout(15) << "jobs #: " << group.size() << dendl;
index 8ad52e02949b0fb3c3f0f59650ca022e1692ac20..99b9d30a49f73d2335ee70b2781b1fae97d91281 100644 (file)
@@ -214,7 +214,7 @@ class ScrubQueue {
    *
    * locking: locks jobs_lock
    */
-  Scrub::schedule_result_t select_pg_and_scrub(Scrub::ScrubPreconds& preconds);
+  Scrub::schedule_result_t select_pg_and_scrub(Scrub::OSDRestrictions& preconds);
 
   /**
    * Translate attempt_ values into readable text
@@ -419,7 +419,7 @@ class ScrubQueue {
 
   Scrub::schedule_result_t select_from_group(
     ScrubQContainer& group,
-    const Scrub::ScrubPreconds& preconds,
+    const Scrub::OSDRestrictions& preconds,
     utime_t now_is);
 
 protected: // used by the unit-tests
index 6cfb1232e582fcc0a83e4e310de2026698034508..d5d4a8c278cf27cd2552713e24add7f86a32697f 100644 (file)
@@ -47,13 +47,36 @@ enum class scrub_prio_t : bool { low_priority = false, high_priority = true };
 using act_token_t = uint32_t;
 
 /// "environment" preconditions affecting which PGs are eligible for scrubbing
-struct ScrubPreconds {
+struct OSDRestrictions {
   bool allow_requested_repair_only{false};
   bool load_is_low{true};
   bool time_permit{true};
   bool only_deadlined{false};
 };
 
+}  // namespace Scrub
+
+namespace fmt {
+template <>
+struct formatter<Scrub::OSDRestrictions> {
+  constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
+
+  template <typename FormatContext>
+  auto format(const Scrub::OSDRestrictions& conds, FormatContext& ctx)
+  {
+    return fmt::format_to(
+      ctx.out(),
+      "overdue-only:{} load:{} time:{} repair-only:{}",
+        conds.only_deadlined,
+        conds.load_is_low ? "ok" : "high",
+        conds.time_permit ? "ok" : "no",
+        conds.allow_requested_repair_only);
+  }
+};
+}  // namespace fmt
+
+namespace Scrub {
+
 /// PG services used by the scrubber backend
 struct PgScrubBeListener {
   virtual ~PgScrubBeListener() = default;