]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/scrub: improve scheduling decisions logs
authorRonen Friedman <rfriedma@redhat.com>
Mon, 5 Feb 2024 11:49:26 +0000 (05:49 -0600)
committerRonen Friedman <rfriedma@redhat.com>
Mon, 5 Feb 2024 11:49:26 +0000 (05:49 -0600)
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 <rfriedma@redhat.com>
src/osd/scrubber/osd_scrub.cc
src/osd/scrubber/osd_scrub.h
src/osd/scrubber/osd_scrub_sched.cc
src/osd/scrubber/osd_scrub_sched.h
src/osd/scrubber/pg_scrubber.cc
src/osd/scrubber/pg_scrubber.h

index a74e1ae5c30d7e753ebca440f8a7b80f8b94b180..d2d2db3ff7255ba32d81abaf57fe4da52b2bc5eb 100644 (file)
@@ -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,
index 64709cc7aab84e7a461963869c41e972e0320600..cd1158d4723661139efe488883d7769607a8c1b9 100644 (file)
@@ -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
    *
index 36644211ec39b6caf8b8b996d34abb20314a71c1..1d0bf614c9b926d1d4b9278da9f377f61dbdd0d8 100644 (file)
@@ -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<ScrubTargetId> ScrubQueue::ready_to_scrub(
     OSDRestrictions restrictions,  // note: 4B in size! (copy)
     utime_t scrub_tick)
index 95f1680d403df6d7c9d457d3dad0c0892c79d950..140c1428889cedc3a8f52b36d03cbcb6e3ba4c27 100644 (file)
@@ -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:
index 9266a54d78585e4c7f2faab7019ab77d3fcb48b3..1c87c3b88a2587ed6cb3824b37e6058763ba087d 100644 (file)
@@ -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();
   }
index bcab24cddfa3396ff28e71f3b8ca370a7eadf780..78e8ba90d449ee385161e6dce159383accbe4246 100644 (file)
@@ -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.
    *