]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: move the wait-for-active logic into OSDState. 42310/head
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 13 Jul 2021 12:39:02 +0000 (12:39 +0000)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Wed, 14 Jul 2021 07:24:13 +0000 (07:24 +0000)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/crimson/osd/osd.cc
src/crimson/osd/osd.h
src/crimson/osd/osd_operations/peering_event.cc
src/crimson/osd/state.h

index 297b3f65e47e92f618037e36216c5253383ab554..17924a9428332550e8eaa2fd878e2fe36618d114 100644 (file)
@@ -94,8 +94,7 @@ OSD::OSD(int id, uint32_t nonce,
       update_stats();
     }},
     asok{seastar::make_lw_shared<crimson::admin::AdminSocket>()},
-    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<OSDMap>();
   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(
index ee4f8cd23073e463eea25da80241802954a81960..600c953dcca694742dde0338412aabb5ca83ec51 100644 (file)
@@ -231,7 +231,6 @@ private:
   friend class PGAdvanceMap;
 
   RemotePeeringEvent::OSDPipeline peering_request_osd_pipeline;
-  std::optional<seastar::shared_promise<>> wait_for_active;
   friend class RemotePeeringEvent;
 
 public:
index 7e3f46808d4c13c1701956b2ea38e26c014064e3..7fe095086dac2a4868879f13710e39630d9c6c77 100644 (file)
@@ -156,11 +156,7 @@ seastar::future<Ref<PG>> 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] {
index ba48cd36f12c86f1d7b038db5f94f20eb8b87f87..7413e58fa405a717a8433712b4c41fb886ea8ffd 100644 (file)
@@ -6,6 +6,8 @@
 #include <string_view>
 #include <ostream>
 
+#include <seastar/core/shared_future.hh>
+
 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) {