]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: add types PG and OSD-hosted OSDMapGate instances.
authorRadosław Zarzyński <rzarzyns@redhat.com>
Fri, 1 Apr 2022 16:42:08 +0000 (18:42 +0200)
committerRadosław Zarzyński <rzarzyns@redhat.com>
Thu, 5 May 2022 02:06:31 +0000 (04:06 +0200)
`ClientRequest` is going to hold all tracking events as a `std::tuple`
instance and access them through the type-related variant of `std::get`.
As two instances of `OSDMapGate` are used there, a need to differentiate
at the type level arises.

Signed-off-by: Radosław Zarzyński <rzarzyns@redhat.com>
src/crimson/osd/osd.h
src/crimson/osd/osdmap_gate.cc
src/crimson/osd/osdmap_gate.h
src/crimson/osd/pg.h

index 7970d8c9fe38a2605a3d34a50dd13cf11a2a381c..aeea180e0339e169c6073c88a61baf9e2bff88c4 100644 (file)
@@ -210,7 +210,7 @@ private:
   seastar::future<> start_asok_admin();
 
 public:
-  OSDMapGate osdmap_gate;
+  OSD_OSDMapGate osdmap_gate;
 
   ShardServices &get_shard_services() {
     return shard_services;
index 4add9388d81ac621c30fece71c1fd3554c0cf72f..316596ab185df9f85e2947cc9f02cc0cd0d3a88c 100644 (file)
@@ -14,14 +14,16 @@ namespace {
 
 namespace crimson::osd {
 
-void OSDMapGate::OSDMapBlocker::dump_detail(Formatter *f) const
+template <OSDMapGateType OSDMapGateTypeV>
+void OSDMapGate<OSDMapGateTypeV>::OSDMapBlocker::dump_detail(Formatter *f) const
 {
   f->open_object_section("OSDMapGate");
   f->dump_int("epoch", epoch);
   f->close_section();
 }
 
-blocking_future<epoch_t> OSDMapGate::wait_for_map(epoch_t epoch)
+template <OSDMapGateType OSDMapGateTypeV>
+blocking_future<epoch_t> OSDMapGate<OSDMapGateTypeV>::wait_for_map(epoch_t epoch)
 {
   if (__builtin_expect(stopping, false)) {
     return make_exception_blocking_future<epoch_t>(
@@ -46,7 +48,37 @@ blocking_future<epoch_t> OSDMapGate::wait_for_map(epoch_t epoch)
   }
 }
 
-void OSDMapGate::got_map(epoch_t epoch) {
+template <OSDMapGateType OSDMapGateTypeV>
+seastar::future<epoch_t> OSDMapGate<OSDMapGateTypeV>::wait_for_map(
+  typename OSDMapBlocker::BlockingEvent::TriggerI&& trigger,
+  epoch_t epoch)
+{
+  if (__builtin_expect(stopping, false)) {
+    return seastar::make_exception_future<epoch_t>(
+       crimson::common::system_shutdown_exception());
+  }
+  if (current >= epoch) {
+    return seastar::make_ready_future<epoch_t>(current);
+  } else {
+    logger().info("evt epoch is {}, i have {}, will wait", epoch, current);
+    auto &blocker = waiting_peering.emplace(
+      epoch, std::make_pair(blocker_type, epoch)).first->second;
+    auto fut = blocker.promise.get_shared_future();
+    if (shard_services) {
+      return trigger.maybe_record_blocking(
+       (*shard_services).get().osdmap_subscribe(current, true).then(
+         [fut=std::move(fut)]() mutable {
+           return std::move(fut);
+         }),
+       blocker);
+    } else {
+      return trigger.maybe_record_blocking(std::move(fut), blocker);
+    }
+  }
+}
+
+template <OSDMapGateType OSDMapGateTypeV>
+void OSDMapGate<OSDMapGateTypeV>::got_map(epoch_t epoch) {
   current = epoch;
   auto first = waiting_peering.begin();
   auto last = waiting_peering.upper_bound(epoch);
@@ -56,7 +88,8 @@ void OSDMapGate::got_map(epoch_t epoch) {
   waiting_peering.erase(first, last);
 }
 
-seastar::future<> OSDMapGate::stop() {
+template <OSDMapGateType OSDMapGateTypeV>
+seastar::future<> OSDMapGate<OSDMapGateTypeV>::stop() {
   logger().info("osdmap::stop");
   stopping = true;
   auto first = waiting_peering.begin();
@@ -68,4 +101,7 @@ seastar::future<> OSDMapGate::stop() {
   return seastar::now();
 }
 
-}
+template class OSDMapGate<OSDMapGateType::PG>;
+template class OSDMapGate<OSDMapGateType::OSD>;
+
+} // namespace crimson::osd
index 367a7f80dcf578fc68777819c650a20726efe565..de02d296eede3e8e93a5d1a9ae260905876d9abd 100644 (file)
@@ -21,8 +21,15 @@ namespace crimson::osd {
 
 class ShardServices;
 
+enum class OSDMapGateType {
+  OSD,
+  PG,
+};
+
+template <OSDMapGateType OSDMapGateTypeV>
 class OSDMapGate {
-  struct OSDMapBlocker : public BlockerT<OSDMapBlocker> {
+public:
+  struct OSDMapBlocker : BlockerT<OSDMapBlocker> {
     const char * type_name;
     epoch_t epoch;
 
@@ -39,6 +46,7 @@ class OSDMapGate {
     void dump_detail(Formatter *f) const final;
   };
 
+private:
   // order the promises in ascending order of the waited osdmap epoch,
   // so we can access all the waiters expecting a map whose epoch is less
   // than or equal to a given epoch
@@ -56,9 +64,16 @@ public:
     : blocker_type(blocker_type), shard_services(shard_services) {}
 
   // wait for an osdmap whose epoch is greater or equal to given epoch
-  blocking_future<epoch_t> wait_for_map(epoch_t epoch);
+  blocking_future<epoch_t>
+  wait_for_map(epoch_t epoch);
+  seastar::future<epoch_t>
+  wait_for_map(typename OSDMapBlocker::BlockingEvent::TriggerI&& trigger,
+              epoch_t epoch);
   void got_map(epoch_t epoch);
   seastar::future<> stop();
 };
 
+using OSD_OSDMapGate = OSDMapGate<OSDMapGateType::OSD>;
+using PG_OSDMapGate = OSDMapGate<OSDMapGateType::PG>;
+
 }
index f8284771e76afe21d90da0832cba05404dafdfd0..af3598fc1ba08ad6533d0a6709eeb24f289abe69 100644 (file)
@@ -613,7 +613,7 @@ private:
     eversion_t& v);
 
 private:
-  OSDMapGate osdmap_gate;
+  PG_OSDMapGate osdmap_gate;
   ShardServices &shard_services;
 
   cached_map_t osdmap;