From f9d92f1817ed438209dc3915d6ed09389e51b03f Mon Sep 17 00:00:00 2001 From: Ronen Friedman Date: Mon, 25 Dec 2023 12:57:26 -0600 Subject: [PATCH] osd/scrub: remove scrub_clear_state() Its functionality is now handled by the FSM when existing 'Session' or 'ActiveReplicaOp' states. For a PG that is not active - no need to do anything. Signed-off-by: Ronen Friedman --- src/osd/PrimaryLogPG.cc | 3 +-- src/osd/scrubber/pg_scrubber.cc | 22 +--------------------- src/osd/scrubber/pg_scrubber.h | 13 ++++++------- src/osd/scrubber/scrub_machine_lstnr.h | 11 +++++++++-- src/osd/scrubber_common.h | 11 +++++++---- 5 files changed, 24 insertions(+), 36 deletions(-) diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index d57ab432d4a..4ecbe58a1f3 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -13027,8 +13027,7 @@ void PrimaryLogPG::on_change(ObjectStore::Transaction &t) finish_degraded_object(p->first); } - // requeues waiting_for_scrub - m_scrubber->scrub_clear_state(); + ceph_assert(waiting_for_scrub.empty()); for (auto p = waiting_for_blocked_object.begin(); p != waiting_for_blocked_object.end(); diff --git a/src/osd/scrubber/pg_scrubber.cc b/src/osd/scrubber/pg_scrubber.cc index f7e027a84f0..2dae53273a7 100644 --- a/src/osd/scrubber/pg_scrubber.cc +++ b/src/osd/scrubber/pg_scrubber.cc @@ -2212,32 +2212,12 @@ PerfCounters& PgScrubber::get_counters_set() const void PgScrubber::cleanup_on_finish() { dout(10) << __func__ << dendl; - ceph_assert(m_pg->is_locked()); - - state_clear(PG_STATE_SCRUBBING); - state_clear(PG_STATE_DEEP_SCRUB); - - m_local_osd_resource.reset(); - requeue_waiting(); - - reset_internal_state(); - m_flags = scrub_flags_t{}; + clear_pgscrub_state(); - // type-specific state clear - _scrub_clear_state(); // PG state flags changed: m_pg->publish_stats_to_osd(); } -// uses process_event(), so must be invoked externally -void PgScrubber::scrub_clear_state() -{ - dout(10) << __func__ << dendl; - - clear_pgscrub_state(); - m_fsm->process_event(FullReset{}); -} - /* * note: does not access the state-machine */ diff --git a/src/osd/scrubber/pg_scrubber.h b/src/osd/scrubber/pg_scrubber.h index adf50f97d92..5911b67263f 100644 --- a/src/osd/scrubber/pg_scrubber.h +++ b/src/osd/scrubber/pg_scrubber.h @@ -318,8 +318,6 @@ class PgScrubber : public ScrubPgIF, void on_replica_activate() final; - void scrub_clear_state() final; - bool is_queued_or_active() const final; /** @@ -421,11 +419,8 @@ class PgScrubber : public ScrubPgIF, void on_replica_init() final; void replica_handling_done() final; - /// the version of 'scrub_clear_state()' that does not try to invoke FSM - /// services (thus can be called from FSM reactions) void clear_pgscrub_state() final; - std::chrono::milliseconds get_scrub_sleep_time() const final; void queue_for_scrub_resched(Scrub::scrub_prio_t prio) final; @@ -622,8 +617,12 @@ class PgScrubber : public ScrubPgIF, */ std::unique_ptr m_local_osd_resource; - void cleanup_on_finish(); // scrub_clear_state() as called for a Primary when - // Active->NotActive + /** + * clearing the scrubber state & the PG's scrub-related flags + * (calls clear_pgscrub_state()). + * Also - publishes the PG stats. + */ + void cleanup_on_finish(); protected: PG* const m_pg; diff --git a/src/osd/scrubber/scrub_machine_lstnr.h b/src/osd/scrubber/scrub_machine_lstnr.h index f2ddd9c8716..7849d14e4e4 100644 --- a/src/osd/scrubber/scrub_machine_lstnr.h +++ b/src/osd/scrubber/scrub_machine_lstnr.h @@ -135,8 +135,15 @@ struct ScrubMachineListener { virtual void replica_handling_done() = 0; - /// the version of 'scrub_clear_state()' that does not try to invoke FSM - /// services (thus can be called from FSM reactions) + /** + * clears both internal scrub state, and some PG-visible flags: + * - the two scrubbing PG state flags; + * - primary/replica scrub position (chunk boundaries); + * - primary/replica interaction state; + * - the backend state; + * Also runs pending callbacks, and clears the active flags. + * Does not try to invoke FSM events. + */ virtual void clear_pgscrub_state() = 0; /// Get time to sleep before next scrub diff --git a/src/osd/scrubber_common.h b/src/osd/scrubber_common.h index b41a9b4bba8..5323b14677b 100644 --- a/src/osd/scrubber_common.h +++ b/src/osd/scrubber_common.h @@ -326,8 +326,6 @@ struct ScrubPgIF { /// we are peered as a replica virtual void on_replica_activate() = 0; - virtual void scrub_clear_state() = 0; - virtual void handle_query_state(ceph::Formatter* f) = 0; virtual pg_scrubbing_status_t get_schedule() const = 0; @@ -382,8 +380,13 @@ struct ScrubPgIF { const hobject_t& soid) = 0; /** - * the version of 'scrub_clear_state()' that does not try to invoke FSM - * services (thus can be called from FSM reactions) + * clears both internal scrub state, and some PG-visible flags: + * - the two scrubbing PG state flags; + * - primary/replica scrub position (chunk boundaries); + * - primary/replica interaction state; + * - the backend state + * Also runs pending callbacks, and clears the active flags. + * Does not try to invoke FSM events. */ virtual void clear_pgscrub_state() = 0; -- 2.39.5