#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)
{
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 {
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;
};