From 0b9dbb7d6ed5f4db579ac5881cebdc1da1086af7 Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Tue, 13 Jul 2021 12:39:02 +0000 Subject: [PATCH] crimson/osd: move the wait-for-active logic into OSDState. Signed-off-by: Radoslaw Zarzynski --- src/crimson/osd/osd.cc | 6 +----- src/crimson/osd/osd.h | 1 - src/crimson/osd/osd_operations/peering_event.cc | 6 +----- src/crimson/osd/state.h | 11 +++++++++++ 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/crimson/osd/osd.cc b/src/crimson/osd/osd.cc index 297b3f65e47e9..17924a9428332 100644 --- a/src/crimson/osd/osd.cc +++ b/src/crimson/osd/osd.cc @@ -94,8 +94,7 @@ OSD::OSD(int id, uint32_t nonce, update_stats(); }}, asok{seastar::make_lw_shared()}, - osdmap_gate("OSD::osdmap_gate", std::make_optional(std::ref(shard_services))), - wait_for_active(std::in_place_t{}) + osdmap_gate("OSD::osdmap_gate", std::make_optional(std::ref(shard_services))) { osdmaps[0] = boost::make_local_shared(); for (auto msgr : {std::ref(cluster_msgr), std::ref(public_msgr), @@ -1068,9 +1067,6 @@ seastar::future<> OSD::committed_osd_maps(version_t first, if (state.is_booting()) { logger().info("osd.{}: activating...", whoami); state.set_active(); - assert(wait_for_active); - wait_for_active->set_value(); - wait_for_active = std::nullopt; beacon_timer.arm_periodic( std::chrono::seconds(local_conf()->osd_beacon_report_interval)); tick_timer.arm_periodic( diff --git a/src/crimson/osd/osd.h b/src/crimson/osd/osd.h index ee4f8cd23073e..600c953dcca69 100644 --- a/src/crimson/osd/osd.h +++ b/src/crimson/osd/osd.h @@ -231,7 +231,6 @@ private: friend class PGAdvanceMap; RemotePeeringEvent::OSDPipeline peering_request_osd_pipeline; - std::optional> wait_for_active; friend class RemotePeeringEvent; public: diff --git a/src/crimson/osd/osd_operations/peering_event.cc b/src/crimson/osd/osd_operations/peering_event.cc index 7e3f46808d4c1..7fe095086dac2 100644 --- a/src/crimson/osd/osd_operations/peering_event.cc +++ b/src/crimson/osd/osd_operations/peering_event.cc @@ -156,11 +156,7 @@ seastar::future> RemotePeeringEvent::get_pg() return with_blocking_future( handle.enter(op().await_active) ).then([this] { - if (osd.wait_for_active) { - return osd.wait_for_active->get_shared_future(); - } else { - return seastar::now(); - } + return osd.state.when_active(); }).then([this] { return with_blocking_future(handle.enter(cp().await_map)); }).then([this] { diff --git a/src/crimson/osd/state.h b/src/crimson/osd/state.h index ba48cd36f12c8..7413e58fa405a 100644 --- a/src/crimson/osd/state.h +++ b/src/crimson/osd/state.h @@ -6,6 +6,8 @@ #include #include +#include + class OSDMap; class OSDState { @@ -21,6 +23,7 @@ class OSDState { }; State state = State::INITIALIZING; + mutable seastar::shared_promise<> wait_for_active; public: bool is_initializing() const { @@ -35,6 +38,10 @@ public: bool is_active() const { return state == State::ACTIVE; } + seastar::future<> when_active() const { + return is_active() ? seastar::now() + : wait_for_active.get_shared_future(); + }; bool is_prestop() const { return state == State::PRESTOP; } @@ -52,12 +59,16 @@ public: } void set_active() { state = State::ACTIVE; + wait_for_active.set_value(); + wait_for_active = {}; } void set_prestop() { state = State::PRESTOP; } void set_stopping() { state = State::STOPPING; + wait_for_active.set_exception(crimson::common::system_shutdown_exception{}); + wait_for_active = {}; } std::string_view to_string() const { switch (state) { -- 2.39.5