]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd/scrub: manage queue registration lifetime in the FSM
authorRonen Friedman <rfriedma@redhat.com>
Sat, 23 Dec 2023 16:18:41 +0000 (10:18 -0600)
committerRonen Friedman <rfriedma@redhat.com>
Fri, 5 Jan 2024 14:44:21 +0000 (08:44 -0600)
As the state of 'being registered in the OSDs scrub queue'
corresponds to the PrimaryActive FSM state.

Signed-off-by: Ronen Friedman <rfriedma@redhat.com>
src/osd/PG.cc
src/osd/PrimaryLogPG.cc
src/osd/scrubber/pg_scrubber.cc
src/osd/scrubber/pg_scrubber.h
src/osd/scrubber/scrub_machine.cc
src/osd/scrubber/scrub_machine_lstnr.h
src/osd/scrubber_common.h

index 3138b8c32f9cc77094d61a3ed52f962c45d5a49b..eb7a332f6c2fb36b0b2336dd4c2711f9efccd05a 100644 (file)
@@ -1847,7 +1847,6 @@ void PG::on_activate(interval_set<snapid_t> snaps)
   snap_trimq = snaps;
   release_pg_backoffs();
   projected_last_update = info.last_update;
-  m_scrubber->on_pg_activate(m_planned_scrub);
 }
 
 void PG::on_replica_activate()
index 8120d76e7ea879b4835b8046319a9f8d1d17bdc0..d57ab432d4ac0401bea94155add19ed1688eeb5c 100644 (file)
@@ -12879,8 +12879,7 @@ void PrimaryLogPG::on_shutdown()
     osd->clear_queued_recovery(this);
   }
 
-  m_scrubber->scrub_clear_state();
-  m_scrubber->rm_from_osd_scrubbing();
+  m_scrubber->on_new_interval();
 
   vector<ceph_tid_t> tids;
   cancel_copy_ops(false, &tids);
index dd279f720add56423de1f80e3209dbe0d20c8b21..ab9b86e5b35c7ac3875a68f4a8c8bbd60c35551b 100644 (file)
@@ -460,14 +460,12 @@ void PgScrubber::on_new_interval()
                  (is_primary() ? "Primary" : "Replica/other"),
                  is_scrub_active(), is_queued_or_active())
           << dendl;
-
   m_fsm->process_event(IntervalChanged{});
   // the following asserts were added due to a past bug, where PG flags were
   // left set in some scenarios.
   ceph_assert(!is_queued_or_active());
   ceph_assert(!state_test(PG_STATE_SCRUBBING));
   ceph_assert(!state_test(PG_STATE_DEEP_SCRUB));
-  rm_from_osd_scrubbing();
 }
 
 bool PgScrubber::is_scrub_registered() const
@@ -493,35 +491,31 @@ void PgScrubber::rm_from_osd_scrubbing()
   }
 }
 
-void PgScrubber::on_pg_activate(const requested_scrub_t& request_flags)
+/*
+ * Note: referring to m_planned_scrub here is temporary, as this set of
+ * scheduling flags will be removed in a followup PR.
+ */
+void PgScrubber::schedule_scrub_with_osd()
 {
   ceph_assert(is_primary());
-  if (!m_scrub_job) {
-    // we won't have a chance to see more logs from this function, thus:
-    dout(2) << fmt::format(
-                  "{}: flags:<{}> {}.Reg-state:{:.7}. No scrub-job", __func__,
-                  request_flags, (is_primary() ? "Primary" : "Replica/other"),
-                  registration_state())
-           << dendl;
-    return;
-  }
+  ceph_assert(m_scrub_job);
 
-  ceph_assert(!is_queued_or_active());
   auto pre_state = m_scrub_job->state_desc();
   auto pre_reg = registration_state();
 
   auto suggested = m_osds->get_scrub_services().determine_scrub_time(
-      request_flags, m_pg->info, m_pg->get_pgpool().info.opts);
+      m_planned_scrub, m_pg->info, m_pg->get_pgpool().info.opts);
   m_osds->get_scrub_services().register_with_osd(m_scrub_job, suggested);
 
   dout(10) << fmt::format(
                  "{}: <flags:{}> {} <{:.5}>&<{:.10}> --> <{:.5}>&<{:.14}>",
-                 __func__, request_flags,
+                 __func__, m_planned_scrub,
                  (is_primary() ? "Primary" : "Replica/other"), pre_reg,
                  pre_state, registration_state(), m_scrub_job->state_desc())
           << dendl;
 }
 
+
 void PgScrubber::on_primary_active_clean()
 {
   dout(10) << fmt::format(
@@ -2177,11 +2171,7 @@ void PgScrubber::handle_query_state(ceph::Formatter* f)
 PgScrubber::~PgScrubber()
 {
   m_fsm->process_event(IntervalChanged{});
-  if (m_scrub_job) {
-    // make sure the OSD won't try to scrub this one just now
-    rm_from_osd_scrubbing();
-    m_scrub_job.reset();
-  }
+  m_scrub_job.reset();
 }
 
 PgScrubber::PgScrubber(PG* pg)
index af667f732143c82d3968827886cb58cbe7fdd34a..8360b4c038f77b6a3ba43716e07a2302a1b11c1b 100644 (file)
@@ -252,7 +252,7 @@ class PgScrubber : public ScrubPgIF,
 
   void rm_from_osd_scrubbing() final;
 
-  void on_pg_activate(const requested_scrub_t& request_flags) final;
+  void schedule_scrub_with_osd() final;
 
   scrub_level_t scrub_requested(
       scrub_level_t scrub_level,
index 1928eed7d0cd4ea08a61129e25c5cc2505ff70be..26054bf3f7642407ed311b86c044eb9027ff71ab 100644 (file)
@@ -123,6 +123,8 @@ PrimaryActive::PrimaryActive(my_context ctx)
 {
   DECLARE_LOCALS;  // 'scrbr' & 'pg_id' aliases
   dout(10) << "-- state -->> PrimaryActive" << dendl;
+  // insert this PG into the OSD scrub queue. Calculate initial schedule
+  scrbr->schedule_scrub_with_osd();
 }
 
 PrimaryActive::~PrimaryActive()
index 8b110fe6271935bd2c371f75f71dbd6f550a9314..086802ee813e77e8ebfb081c1f810b1878db16d6 100644 (file)
@@ -107,6 +107,15 @@ struct ScrubMachineListener {
 
   [[nodiscard]] virtual bool is_primary() const = 0;
 
+  /// dequeue this PG from the OSD's scrub-queue
+  virtual void rm_from_osd_scrubbing() = 0;
+
+  /**
+   * the FSM has entered the PrimaryActive state. That happens when
+   * peered as a Primary, and achieving the 'active' state.
+   */
+  virtual void schedule_scrub_with_osd() = 0;
+
   virtual void select_range_n_notify() = 0;
 
   /// walk the log to find the latest update that affects our chunk
index fbbef578ae6930bb907490973a056b02595a6164..b41a9b4bba84fdd4b498e85aa3ca68341debcfc8 100644 (file)
@@ -409,12 +409,6 @@ struct ScrubPgIF {
    */
   virtual bool reserve_local() = 0;
 
-  /**
-   * if activated as a Primary - register the scrub job with the OSD
-   * scrub queue
-   */
-  virtual void on_pg_activate(const requested_scrub_t& request_flags) = 0;
-
   /**
    * Recalculate the required scrub time.
    *
@@ -431,8 +425,6 @@ struct ScrubPgIF {
    */
   virtual void handle_scrub_reserve_msgs(OpRequestRef op) = 0;
 
-  virtual void rm_from_osd_scrubbing() = 0;
-
   virtual scrub_level_t scrub_requested(
       scrub_level_t scrub_level,
       scrub_type_t scrub_type,