From 9a03029b10bf99a053063bd1631503c2a6f6fab3 Mon Sep 17 00:00:00 2001 From: Ronen Friedman Date: Mon, 5 Feb 2024 05:49:26 -0600 Subject: [PATCH] osd/scrub: improve scheduling decisions logs And, to that end, relocated determine_scrub_time(), a helper function that examines pg 'info' vs the planned scrub details to determine the initial scrub time, to the scrubber itself (where it belongs, and where the logs are more expressive). Signed-off-by: Ronen Friedman --- src/osd/scrubber/osd_scrub.cc | 8 ------ src/osd/scrubber/osd_scrub.h | 6 ---- src/osd/scrubber/osd_scrub_sched.cc | 36 ------------------------ src/osd/scrubber/osd_scrub_sched.h | 4 --- src/osd/scrubber/pg_scrubber.cc | 43 ++++++++++++++++++++++++++--- src/osd/scrubber/pg_scrubber.h | 9 ++++++ 6 files changed, 48 insertions(+), 58 deletions(-) diff --git a/src/osd/scrubber/osd_scrub.cc b/src/osd/scrubber/osd_scrub.cc index a74e1ae5c30..d2d2db3ff72 100644 --- a/src/osd/scrubber/osd_scrub.cc +++ b/src/osd/scrubber/osd_scrub.cc @@ -427,14 +427,6 @@ PerfCounters* OsdScrub::get_perf_counters(int pool_type, scrub_level_t level) // ////////////////////////////////////////////////////////////////////////// // // forwarders to the queue -Scrub::sched_params_t OsdScrub::determine_scrub_time( - const requested_scrub_t& request_flags, - const pg_info_t& pg_info, - const pool_opts_t& pool_conf) const -{ - return m_queue.determine_scrub_time(request_flags, pg_info, pool_conf); -} - void OsdScrub::update_job( Scrub::ScrubJobRef sjob, const Scrub::sched_params_t& suggested, diff --git a/src/osd/scrubber/osd_scrub.h b/src/osd/scrubber/osd_scrub.h index 64709cc7aab..cd1158d4723 100644 --- a/src/osd/scrubber/osd_scrub.h +++ b/src/osd/scrubber/osd_scrub.h @@ -76,12 +76,6 @@ class OsdScrub { void mark_pg_scrub_blocked(spg_t blocked_pg); void clear_pg_scrub_blocked(spg_t blocked_pg); - // updating scheduling information for a specific PG - Scrub::sched_params_t determine_scrub_time( - const requested_scrub_t& request_flags, - const pg_info_t& pg_info, - const pool_opts_t& pool_conf) const; - /** * modify a scrub-job's scheduled time and deadline * diff --git a/src/osd/scrubber/osd_scrub_sched.cc b/src/osd/scrubber/osd_scrub_sched.cc index 36644211ec3..1d0bf614c9b 100644 --- a/src/osd/scrubber/osd_scrub_sched.cc +++ b/src/osd/scrubber/osd_scrub_sched.cc @@ -168,42 +168,6 @@ void ScrubQueue::delay_on_failure( } -sched_params_t ScrubQueue::determine_scrub_time( - const requested_scrub_t& request_flags, - const pg_info_t& pg_info, - const pool_opts_t& pool_conf) const -{ - sched_params_t res; - - if (request_flags.must_scrub || request_flags.need_auto) { - - // Set the smallest time that isn't utime_t() - res.proposed_time = PgScrubber::scrub_must_stamp(); - res.is_must = Scrub::must_scrub_t::mandatory; - // we do not need the interval data in this case - - } else if (pg_info.stats.stats_invalid && conf()->osd_scrub_invalid_stats) { - res.proposed_time = time_now(); - res.is_must = Scrub::must_scrub_t::mandatory; - - } else { - res.proposed_time = pg_info.history.last_scrub_stamp; - res.min_interval = pool_conf.value_or(pool_opts_t::SCRUB_MIN_INTERVAL, 0.0); - res.max_interval = pool_conf.value_or(pool_opts_t::SCRUB_MAX_INTERVAL, 0.0); - } - - dout(15) << fmt::format( - "suggested: {:s} hist: {:s} v:{}/{} must:{} pool-min:{} {}", - res.proposed_time, pg_info.history.last_scrub_stamp, - (bool)pg_info.stats.stats_invalid, - conf()->osd_scrub_invalid_stats, - (res.is_must == must_scrub_t::mandatory ? "y" : "n"), - res.min_interval, request_flags) - << dendl; - return res; -} - - std::vector ScrubQueue::ready_to_scrub( OSDRestrictions restrictions, // note: 4B in size! (copy) utime_t scrub_tick) diff --git a/src/osd/scrubber/osd_scrub_sched.h b/src/osd/scrubber/osd_scrub_sched.h index 95f1680d403..140c1428889 100644 --- a/src/osd/scrubber/osd_scrub_sched.h +++ b/src/osd/scrubber/osd_scrub_sched.h @@ -233,10 +233,6 @@ class ScrubQueue { Scrub::delay_cause_t delay_cause, utime_t now_is); - sched_params_t determine_scrub_time(const requested_scrub_t& request_flags, - const pg_info_t& pg_info, - const pool_opts_t& pool_conf) const; - std::ostream& gen_prefix(std::ostream& out, std::string_view fn) const; public: diff --git a/src/osd/scrubber/pg_scrubber.cc b/src/osd/scrubber/pg_scrubber.cc index 9266a54d785..1c87c3b88a2 100644 --- a/src/osd/scrubber/pg_scrubber.cc +++ b/src/osd/scrubber/pg_scrubber.cc @@ -501,6 +501,43 @@ void PgScrubber::rm_from_osd_scrubbing() } } +sched_params_t PgScrubber::determine_scrub_time( + const pool_opts_t& pool_conf) const +{ + sched_params_t res; + + if (m_planned_scrub.must_scrub || m_planned_scrub.need_auto) { + + // Set the smallest time that isn't utime_t() + res.proposed_time = PgScrubber::scrub_must_stamp(); + res.is_must = Scrub::must_scrub_t::mandatory; + // we do not need the interval data in this case + + } else if ( + m_pg->info.stats.stats_invalid && + get_pg_cct()->_conf->osd_scrub_invalid_stats) { + res.proposed_time = ceph_clock_now(); + res.is_must = Scrub::must_scrub_t::mandatory; + + } else { + res.proposed_time = m_pg->info.history.last_scrub_stamp; + res.min_interval = pool_conf.value_or(pool_opts_t::SCRUB_MIN_INTERVAL, 0.0); + res.max_interval = pool_conf.value_or(pool_opts_t::SCRUB_MAX_INTERVAL, 0.0); + } + + dout(15) + << fmt::format( + "{}: suggested: {:s} hist: {:s} v:{}/{} must:{} pool-min:{} {}", + __func__, res.proposed_time, m_pg->info.history.last_scrub_stamp, + (bool)m_pg->info.stats.stats_invalid, + get_pg_cct()->_conf->osd_scrub_invalid_stats, + (res.is_must == must_scrub_t::mandatory ? "y" : "n"), + res.min_interval, m_planned_scrub) + << dendl; + return res; +} + + /* * Note: referring to m_planned_scrub here is temporary, as this set of * scheduling flags will be removed in a followup PR. @@ -513,8 +550,7 @@ void PgScrubber::schedule_scrub_with_osd() auto pre_state = m_scrub_job->state_desc(); auto pre_reg = registration_state(); - auto suggested = m_osds->get_scrub_services().determine_scrub_time( - m_planned_scrub, m_pg->info, m_pg->get_pgpool().info.opts); + auto suggested = determine_scrub_time(m_pg->get_pgpool().info.opts); m_osds->get_scrub_services().register_with_osd(m_scrub_job, suggested); dout(10) << fmt::format( @@ -554,8 +590,7 @@ void PgScrubber::update_scrub_job(const requested_scrub_t& request_flags) if (is_primary() && m_scrub_job) { ceph_assert(m_pg->is_locked()); - auto suggested = m_osds->get_scrub_services().determine_scrub_time( - request_flags, m_pg->info, m_pg->get_pgpool().info.opts); + auto suggested = determine_scrub_time(m_pg->get_pgpool().info.opts); m_osds->get_scrub_services().update_job(m_scrub_job, suggested, true); m_pg->publish_stats_to_osd(); } diff --git a/src/osd/scrubber/pg_scrubber.h b/src/osd/scrubber/pg_scrubber.h index bcab24cddfa..78e8ba90d44 100644 --- a/src/osd/scrubber/pg_scrubber.h +++ b/src/osd/scrubber/pg_scrubber.h @@ -784,6 +784,15 @@ class PgScrubber : public ScrubPgIF, */ Scrub::sched_conf_t populate_config_params() const; + /** + * determine the time when the next scrub should be scheduled + * + * based on the planned scrub's flags, time of last scrub, and + * the pool's scrub configuration. + */ + Scrub::sched_params_t determine_scrub_time( + const pool_opts_t& pool_conf) const; + /* * Select a range of objects to scrub. * -- 2.39.5