From a1cf175ee1874824b8b2152c242dee5530eebd6b Mon Sep 17 00:00:00 2001 From: Ronen Friedman Date: Mon, 12 Feb 2024 08:50:22 -0600 Subject: [PATCH] test/osd: fix test_scrub_sched following scrubber changes Replacing PgScrubber::determine_scrub_time() with a local copy, as a stop-gap measure to keep the test running. The scrub scheduling refactoring will remove the need for this function, and the test will be updated accordingly. Signed-off-by: Ronen Friedman --- src/test/osd/test_scrub_sched.cc | 46 +++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/src/test/osd/test_scrub_sched.cc b/src/test/osd/test_scrub_sched.cc index b6c069c4b5f..0fec55bf062 100644 --- a/src/test/osd/test_scrub_sched.cc +++ b/src/test/osd/test_scrub_sched.cc @@ -20,8 +20,9 @@ #include "osd/PG.h" #include "osd/osd_types.h" #include "osd/osd_types_fmt.h" -#include "osd/scrubber/osd_scrub_sched.h" #include "osd/scrubber_common.h" +#include "osd/scrubber/pg_scrubber.h" +#include "osd/scrubber/osd_scrub_sched.h" int main(int argc, char** argv) { @@ -47,6 +48,9 @@ using ScrubJobRef = Scrub::ScrubJobRef; using qu_state_t = Scrub::qu_state_t; using scrub_schedule_t = Scrub::scrub_schedule_t; using ScrubQContainer = Scrub::ScrubQContainer; +using sched_params_t = Scrub::sched_params_t; + + /// enabling access into ScrubQueue internals class ScrubSchedTestWrapper : public ScrubQueue { @@ -85,6 +89,46 @@ class ScrubSchedTestWrapper : public ScrubQueue { return m_time_for_testing.value_or(ceph_clock_now()); } + /** + * a temporary implementation of PgScrubber::determine_scrub_time(). That + * function is to be removed in the near future, and modifying the + * test to use the actual PgScrubber::determine_scrub_time() would create + * an unneeded coupling between objects that are due for separation. + */ + sched_params_t determine_scrub_time( + const requested_scrub_t& request_flags, + const pg_info_t& pg_info, + const pool_opts_t& pool_conf) + { + 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); + } + + std::cout << fmt::format( + "suggested: {:s} hist: {:s} v:{}/{} must:{} pool-min:{} {}\n", + res.proposed_time, pg_info.history.last_scrub_stamp, + (bool)pg_info.stats.stats_invalid, conf()->osd_scrub_invalid_stats, + (res.is_must == Scrub::must_scrub_t::mandatory ? "y" : "n"), + res.min_interval, request_flags); + return res; + } ~ScrubSchedTestWrapper() override = default; }; -- 2.39.5