From: Ronen Friedman Date: Sun, 10 Sep 2023 18:32:53 +0000 (-0500) Subject: osd/scrub: renaming & fmt support for restrictions structure X-Git-Tag: v19.0.0~438^2~16 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5e4956cbaec6f6263fb0b48f2859fc1ed5e65aa7;p=ceph.git osd/scrub: renaming & fmt support for restrictions structure Renaming ScrubPreconds, the collection of "environmental" restrictions on possible scrubs, to OSDRestrictions. Also - providing fmtlib support for that structure. Signed-off-by: Ronen Friedman --- diff --git a/src/osd/scrubber/osd_scrub.cc b/src/osd/scrubber/osd_scrub.cc index a53e47d27456..fe92fd63c7db 100644 --- a/src/osd/scrubber/osd_scrub.cc +++ b/src/osd/scrubber/osd_scrub.cc @@ -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) { diff --git a/src/osd/scrubber/osd_scrub_sched.cc b/src/osd/scrubber/osd_scrub_sched.cc index 64b44e0dc323..b07b4385a58b 100644 --- a/src/osd/scrubber/osd_scrub_sched.cc +++ b/src/osd/scrubber/osd_scrub_sched.cc @@ -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; diff --git a/src/osd/scrubber/osd_scrub_sched.h b/src/osd/scrubber/osd_scrub_sched.h index 8ad52e02949b..99b9d30a49f7 100644 --- a/src/osd/scrubber/osd_scrub_sched.h +++ b/src/osd/scrubber/osd_scrub_sched.h @@ -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 diff --git a/src/osd/scrubber_common.h b/src/osd/scrubber_common.h index 6cfb1232e582..d5d4a8c278cf 100644 --- a/src/osd/scrubber_common.h +++ b/src/osd/scrubber_common.h @@ -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 { + constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); } + + template + 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;