From: Ronen Friedman Date: Mon, 1 Jul 2024 14:06:54 +0000 (-0500) Subject: osd/scrub: improve update_scrub_job() X-Git-Tag: v20.0.0~1493^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=75b8ecbc2a2a30dea78f8e6fd009e9d18d305a81;p=ceph.git osd/scrub: improve update_scrub_job() ...and on_scrub_schedule_input_change() by accepting a parameter to control whether the scheduled time for periodic scrubs that are already due should be updated. Signed-off-by: Ronen Friedman --- diff --git a/src/osd/PG.cc b/src/osd/PG.cc index a8b9d41e1dab..6392a184bd32 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -1361,14 +1361,18 @@ double PG::next_deepscrub_interval() const return info.history.last_deep_scrub_stamp + deep_scrub_interval; } -void PG::on_scrub_schedule_input_change() +void PG::on_scrub_schedule_input_change(Scrub::delay_ready_t delay_ready) { if (is_active() && is_primary()) { - dout(20) << __func__ << ": active/primary" << dendl; + dout(10) << fmt::format( + "{}: active/primary. delay_ready={:c}", __func__, + (delay_ready == Scrub::delay_ready_t::delay_ready) ? 't' + : 'f') + << dendl; ceph_assert(m_scrubber); - m_scrubber->update_scrub_job(m_planned_scrub); + m_scrubber->update_scrub_job(delay_ready); } else { - dout(20) << __func__ << ": inactive or non-primary" << dendl; + dout(10) << fmt::format("{}: inactive or non-primary", __func__) << dendl; } } @@ -2261,7 +2265,7 @@ void PG::handle_activate_map(PeeringCtx &rctx, epoch_t range_starts_at) // on_scrub_schedule_input_change() as pool.info contains scrub scheduling // parameters. if (pool.info.last_change >= range_starts_at) { - on_scrub_schedule_input_change(); + on_scrub_schedule_input_change(Scrub::delay_ready_t::delay_ready); } } diff --git a/src/osd/PG.h b/src/osd/PG.h index 444f59254866..b18e3e163896 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -269,7 +269,7 @@ public: set_last_scrub_stamp(t, history, stats); return true; }); - on_scrub_schedule_input_change(); + on_scrub_schedule_input_change(Scrub::delay_ready_t::delay_ready); } static void set_last_deep_scrub_stamp( @@ -285,7 +285,7 @@ public: set_last_scrub_stamp(t, history, stats); return true; }); - on_scrub_schedule_input_change(); + on_scrub_schedule_input_change(Scrub::delay_ready_t::delay_ready); } static void add_objects_scrubbed_count( @@ -531,7 +531,7 @@ public: * - pg stat scrub timestamps * - etc */ - void on_scrub_schedule_input_change(); + void on_scrub_schedule_input_change(Scrub::delay_ready_t delay_ready); void scrub_requested(scrub_level_t scrub_level, scrub_type_t scrub_type) override; diff --git a/src/osd/scrubber/osd_scrub.cc b/src/osd/scrubber/osd_scrub.cc index a11777a040a3..76e590a0930d 100644 --- a/src/osd/scrubber/osd_scrub.cc +++ b/src/osd/scrubber/osd_scrub.cc @@ -236,7 +236,8 @@ void OsdScrub::on_config_change() "updating scrub schedule on {}", (locked_pg->pg())->get_pgid()) << dendl; - locked_pg->pg()->on_scrub_schedule_input_change(); + locked_pg->pg()->on_scrub_schedule_input_change( + Scrub::delay_ready_t::no_delay); } } diff --git a/src/osd/scrubber/pg_scrubber.cc b/src/osd/scrubber/pg_scrubber.cc index e0bc082f7af6..8984d00f45da 100644 --- a/src/osd/scrubber/pg_scrubber.cc +++ b/src/osd/scrubber/pg_scrubber.cc @@ -579,12 +579,12 @@ void PgScrubber::on_primary_active_clean() * guarantees that the PG is locked and the interval is still the same. * - in the 2nd case - we know the PG state and we know we are only called * for a Primary. -*/ -void PgScrubber::update_scrub_job(const requested_scrub_t& request_flags) + */ +void PgScrubber::update_scrub_job(Scrub::delay_ready_t delay_ready) { if (!is_primary() || !m_scrub_job) { dout(10) << fmt::format( - "{}: pg[{}]: not Primary or no scrub-job", __func__, + "{}: PG[{}]: not Primary or no scrub-job", __func__, m_pg_id) << dendl; return; @@ -599,7 +599,7 @@ void PgScrubber::update_scrub_job(const requested_scrub_t& request_flags) } dout(15) << fmt::format( - "{}: flags:<{}> job on entry:{}", __func__, request_flags, + "{}: flags:<{}> job on entry:{}", __func__, m_planned_scrub, *m_scrub_job) << dendl; if (m_scrub_job->target_queued) { @@ -610,7 +610,6 @@ void PgScrubber::update_scrub_job(const requested_scrub_t& request_flags) << dendl; } - ceph_assert(m_pg->is_locked()); const auto applicable_conf = populate_config_params(); const auto scrub_clock_now = ceph_clock_now(); @@ -620,10 +619,10 @@ void PgScrubber::update_scrub_job(const requested_scrub_t& request_flags) m_scrub_job->target_queued = true; m_pg->publish_stats_to_osd(); - dout(15) << fmt::format( - "{}: flags:<{}> job on exit:{}", __func__, request_flags, - *m_scrub_job) - << dendl; + dout(10) << fmt::format( + "{}: flags:<{}> job on exit:{}", __func__, m_planned_scrub, + *m_scrub_job) + << dendl; } scrub_level_t PgScrubber::scrub_requested( @@ -651,7 +650,7 @@ scrub_level_t PgScrubber::scrub_requested( req_flags.req_scrub = true; dout(20) << fmt::format("{}: planned scrub:{}", __func__, req_flags) << dendl; - update_scrub_job(req_flags); + update_scrub_job(delay_ready_t::no_delay); return deep_requested ? scrub_level_t::deep : scrub_level_t::shallow; } @@ -661,7 +660,7 @@ void PgScrubber::request_rescrubbing(requested_scrub_t& request_flags) dout(10) << __func__ << " flags: " << request_flags << dendl; request_flags.need_auto = true; - update_scrub_job(request_flags); + update_scrub_job(delay_ready_t::no_delay); } bool PgScrubber::reserve_local() @@ -726,7 +725,7 @@ Scrub::sched_conf_t PgScrubber::populate_config_params() const configs.deep_randomize_ratio = conf->osd_deep_scrub_randomize_ratio; configs.mandatory_on_invalid = conf->osd_scrub_invalid_stats; - dout(15) << fmt::format("updated config:{}", configs) << dendl; + dout(15) << fmt::format("{}: updated config:{}", __func__, configs) << dendl; return configs; } @@ -2035,7 +2034,9 @@ void PgScrubber::scrub_finish() int tr = m_osds->store->queue_transaction(m_pg->ch, std::move(t), nullptr); ceph_assert(tr == 0); } - update_scrub_job(m_planned_scrub); + + // determine the next scrub time + update_scrub_job(delay_ready_t::delay_ready); if (has_error) { m_pg->queue_peering_event(PGPeeringEventRef( diff --git a/src/osd/scrubber/pg_scrubber.h b/src/osd/scrubber/pg_scrubber.h index 2255ad8ce0ec..0106edae54ae 100644 --- a/src/osd/scrubber/pg_scrubber.h +++ b/src/osd/scrubber/pg_scrubber.h @@ -256,7 +256,7 @@ class PgScrubber : public ScrubPgIF, // managing scrub op registration - void update_scrub_job(const requested_scrub_t& request_flags) final; + void update_scrub_job(Scrub::delay_ready_t delay_ready) final; void rm_from_osd_scrubbing() final; diff --git a/src/osd/scrubber_common.h b/src/osd/scrubber_common.h index f7ac9a867fe7..832811fbad76 100644 --- a/src/osd/scrubber_common.h +++ b/src/osd/scrubber_common.h @@ -107,6 +107,10 @@ enum class schedule_result_t { target_specific_failure, // failed to scrub this specific target osd_wide_failure // failed to scrub any target }; + +/// rescheduling param: should we delay jobs already ready to execute? +enum class delay_ready_t : bool { delay_ready = true, no_delay = false }; + } // namespace Scrub namespace fmt { @@ -547,7 +551,7 @@ struct ScrubPgIF { * This function assumes that the queue registration status is up-to-date, * i.e. the OSD "knows our name" if-f we are the Primary. */ - virtual void update_scrub_job(const requested_scrub_t& request_flags) = 0; + virtual void update_scrub_job(Scrub::delay_ready_t delay_ready) = 0; /** * route incoming replica-reservations requests/responses to the