]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/scrub: make on_replica_init() idempotent again 48190/head
authorRonen Friedman <rfriedma@redhat.com>
Tue, 20 Sep 2022 07:02:51 +0000 (07:02 +0000)
committerRonen Friedman <rfriedma@redhat.com>
Tue, 20 Sep 2022 14:48:30 +0000 (14:48 +0000)
on_replica_init() might be called twice during replica scrub
initiation. Thus, it was designed to cause no issue if called
an extra time. That was broken when the scrubber-backend code
was introduced.

Fixes: https://tracker.ceph.com/issues/57616
Signed-off-by: Ronen Friedman <rfriedma@redhat.com>
src/osd/scrubber/pg_scrubber.cc

index 2a610b30a077dd0e3268a0fd9f1b3719f9eac4af..7597f4a7d27830af4267921f88be66a4d8c2cc9c 100644 (file)
@@ -1022,19 +1022,26 @@ void PgScrubber::on_init()
   m_pg->publish_stats_to_osd();
 }
 
+/*
+ * Note: as on_replica_init() is likely to be called twice (entering
+ * both ReplicaWaitUpdates & ActiveReplica), its operations should be
+ * idempotent.
+ * Now that it includes some state-changing operations, we need to check
+ * m_active against double-activation.
+ */
 void PgScrubber::on_replica_init()
 {
-  m_be = std::make_unique<ScrubBackend>(
-    *this,
-    *m_pg,
-    m_pg_whoami,
-    m_is_repair,
-    m_is_deep ? scrub_level_t::deep : scrub_level_t::shallow);
-  m_active = true;
-  ++m_sessions_counter;
+  dout(10) << __func__ << " called with 'active' "
+          << (m_active ? "set" : "cleared") << dendl;
+  if (!m_active) {
+    m_be = std::make_unique<ScrubBackend>(
+      *this, *m_pg, m_pg_whoami, m_is_repair,
+      m_is_deep ? scrub_level_t::deep : scrub_level_t::shallow);
+    m_active = true;
+    ++m_sessions_counter;
+  }
 }
 
-
 int PgScrubber::build_primary_map_chunk()
 {
   epoch_t map_building_since = m_pg->get_osdmap_epoch();