From c873c3973a33212477fbe39ec62d8ffdd617c66e Mon Sep 17 00:00:00 2001 From: Ronen Friedman Date: Tue, 19 Sep 2023 07:16:03 -0500 Subject: [PATCH] osd/scrub: handle configuration changes in OsdScrub Signed-off-by: Ronen Friedman --- src/osd/OSD.cc | 13 ++++++++--- src/osd/scrubber/osd_scrub.cc | 41 ++++++++++------------------------- src/osd/scrubber/osd_scrub.h | 13 ++++++++--- 3 files changed, 31 insertions(+), 36 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 4b7ecfc00cbe0..d6948cf05a76f 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -9839,10 +9839,17 @@ void OSD::handle_conf_change(const ConfigProxy& conf, } if (changed.count("osd_scrub_min_interval") || - changed.count("osd_scrub_max_interval")) { - resched_all_scrubs(); - dout(0) << __func__ << ": scrub interval change" << dendl; + changed.count("osd_scrub_max_interval") || + changed.count("osd_deep_scrub_interval")) { + service.get_scrub_services().on_config_change(); + dout(0) << fmt::format( + "{}: scrub interval change (min:{} deep:{} max:{})", + __func__, cct->_conf->osd_scrub_min_interval, + cct->_conf->osd_deep_scrub_interval, + cct->_conf->osd_scrub_max_interval) + << dendl; } + check_config(); if (changed.count("osd_asio_thread_count")) { service.poolctx.stop(); diff --git a/src/osd/scrubber/osd_scrub.cc b/src/osd/scrubber/osd_scrub.cc index 6c31dce802b4b..ee82bb5f21696 100644 --- a/src/osd/scrubber/osd_scrub.cc +++ b/src/osd/scrubber/osd_scrub.cc @@ -260,43 +260,24 @@ Scrub::schedule_result_t OsdScrub::initiate_a_scrub( return locked_pg->pg()->sched_scrub(); } - -// ////////////////////////////////////////////////////////////////////////// // -// scrub initiation - OSD code temporarily moved here from OSD.cc - -// temporary dout() support for OSD members: -static ostream& _prefix(std::ostream* _dout, int whoami, epoch_t epoch) { - return *_dout << "osd." << whoami << " " << epoch << " "; -} -#undef dout_prefix -#define dout_prefix _prefix(_dout, whoami, get_osdmap_epoch()) - -void OSD::resched_all_scrubs() +void OsdScrub::on_config_change() { - dout(10) << __func__ << ": start" << dendl; - auto all_jobs = service.get_scrub_services().list_registered_jobs(); - for (auto& e : all_jobs) { - - auto& job = *e; - dout(20) << __func__ << ": examine " << job.pgid << dendl; + auto to_notify = m_queue.list_registered_jobs(); - PGRef pg = _lookup_lock_pg(job.pgid); - if (!pg) + for (const auto& p : to_notify) { + dout(30) << fmt::format("rescheduling pg[{}] scrubs", *p) << dendl; + auto locked_pg = m_osd_svc.get_locked_pg(p->pgid); + if (!locked_pg) continue; - dout(15) << __func__ << ": updating scrub schedule on " << job.pgid << dendl; - pg->on_scrub_schedule_input_change(); - - pg->unlock(); + dout(15) << fmt::format( + "updating scrub schedule on {}", + (locked_pg->pg())->get_pgid()) + << dendl; + locked_pg->pg()->on_scrub_schedule_input_change(); } - dout(10) << __func__ << ": done" << dendl; } - -// restoring local dout() settings (to be removed in a followup commit) -#undef dout_prefix -#define dout_prefix _prefix_fn(_dout, this, __func__) - void ScrubQueue::dump_scrubs(ceph::Formatter* f) const { ceph_assert(f != nullptr); diff --git a/src/osd/scrubber/osd_scrub.h b/src/osd/scrubber/osd_scrub.h index 75ad02fd60714..4bfbe1e646dfe 100644 --- a/src/osd/scrubber/osd_scrub.h +++ b/src/osd/scrubber/osd_scrub.h @@ -28,9 +28,6 @@ class OsdScrub { ~OsdScrub() = default; - // temporary friendship - only required in this transitory commit - friend class OSD; - // note: public, as accessed by the dout macros std::ostream& gen_prefix(std::ostream& out, std::string_view fn) const; @@ -53,6 +50,16 @@ class OsdScrub { void dump_scrubs(ceph::Formatter* f) const; ///< fwd to the queue + /** + * on_config_change() (the refactored "OSD::sched_all_scrubs()") + * + * for each PG registered with the OSD (i.e. - for which we are the primary): + * lock that PG, and call its on_scrub_schedule_input_change() method + * to handle a possible change in one of the configuration parameters + * that affect scrub scheduling. + */ + void on_config_change(); + // implementing the PGs interface to the scrub scheduling objects // --------------------------------------------------------------- -- 2.39.5