]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: pipeline stage classes can be bases for CRTP now
authorRadosław Zarzyński <rzarzyns@redhat.com>
Sat, 2 Apr 2022 12:42:35 +0000 (14:42 +0200)
committerRadosław Zarzyński <rzarzyns@redhat.com>
Thu, 5 May 2022 02:06:31 +0000 (04:06 +0200)
Signed-off-by: Radosław Zarzyński <rzarzyns@redhat.com>
src/crimson/common/operation.cc
src/crimson/common/operation.h

index fc49046963fa695f4cd1bb2d1cb056bbec7a9ebb..85575a74a0efa05cd7b2d8414385fe74600383d3 100644 (file)
@@ -67,12 +67,4 @@ void AggregateBlocker::dump_detail(ceph::Formatter *f) const
   f->close_section();
 }
 
-void OrderedExclusivePhase::dump_detail(ceph::Formatter* f) const
-{
-}
-
-void OrderedConcurrentPhase::dump_detail(ceph::Formatter* f) const
-{
-}
-
 }
index 2bc5f5d1e9da2d4319876e8d527528c284574f74..4fcfcbd8127636e2c6b80ad15435241a96336ad6 100644 (file)
@@ -558,13 +558,14 @@ public:
  * resolve) a new phase prior to exiting the previous one will ensure that
  * the op ordering is preserved.
  */
-class OrderedExclusivePhase : public PipelineStageIT<OrderedExclusivePhase> {
-  void dump_detail(ceph::Formatter *f) const final;
+template <class T>
+class OrderedExclusivePhaseT : public PipelineStageIT<T> {
+  void dump_detail(ceph::Formatter *f) const final {}
 
   class ExitBarrier final : public PipelineExitBarrierI {
-    OrderedExclusivePhase *phase;
+    OrderedExclusivePhaseT *phase;
   public:
-    ExitBarrier(OrderedExclusivePhase *phase) : phase(phase) {}
+    ExitBarrier(OrderedExclusivePhaseT *phase) : phase(phase) {}
 
     seastar::future<> wait() final {
       return seastar::now();
@@ -597,28 +598,31 @@ public:
     });
   }
 
-  OrderedExclusivePhase(const char *type_name) : type_name(type_name) {}
-
-  const char * type_name;
-
 private:
   seastar::shared_mutex mutex;
 };
 
+// TODO: drop this after migrating to the new event tracking infrastructure.
+struct OrderedExclusivePhase : OrderedExclusivePhaseT<OrderedExclusivePhase> {
+  OrderedExclusivePhase(const char *type_name) : type_name(type_name) {}
+  const char * type_name;
+};
+
 /**
  * Permits multiple ops to inhabit the stage concurrently, but ensures that
  * they will proceed to the next stage in the order in which they called
  * enter.
  */
-class OrderedConcurrentPhase : public PipelineStageIT<OrderedConcurrentPhase> {
-  void dump_detail(ceph::Formatter *f) const final;
+template <class T>
+class OrderedConcurrentPhaseT : public PipelineStageIT<T> {
+  void dump_detail(ceph::Formatter *f) const final {}
 
   class ExitBarrier final : public PipelineExitBarrierI {
-    OrderedConcurrentPhase *phase;
+    OrderedConcurrentPhaseT *phase;
     std::optional<seastar::future<>> barrier;
   public:
     ExitBarrier(
-      OrderedConcurrentPhase *phase,
+      OrderedConcurrentPhaseT *phase,
       seastar::future<> &&barrier) : phase(phase), barrier(std::move(barrier)) {}
 
     seastar::future<> wait() final {
@@ -657,20 +661,22 @@ public:
       new ExitBarrier{this, mutex.lock()});
   }
 
-  OrderedConcurrentPhase(const char *type_name) : type_name(type_name) {}
-
-  const char * type_name;
-
 private:
   seastar::shared_mutex mutex;
 };
 
+struct OrderedConcurrentPhase : OrderedConcurrentPhaseT<OrderedConcurrentPhase> {
+  OrderedConcurrentPhase(const char *type_name) : type_name(type_name) {}
+  const char * type_name;
+};
+
 /**
  * Imposes no ordering or exclusivity at all.  Ops enter without constraint and
  * may exit in any order.  Useful mainly for informational purposes between
  * stages with constraints.
  */
-class UnorderedStage : public PipelineStageIT<UnorderedStage> {
+template <class T>
+class UnorderedStageT : public PipelineStageIT<T> {
   void dump_detail(ceph::Formatter *f) const final {}
 
   class ExitBarrier final : public PipelineExitBarrierI {
@@ -693,11 +699,11 @@ public:
     return seastar::make_ready_future<PipelineExitBarrierI::Ref>(
       new ExitBarrier);
   }
+};
 
+struct UnorderedStage : UnorderedStageT<UnorderedStage> {
   UnorderedStage(const char *type_name) : type_name(type_name) {}
-
   const char * type_name;
 };
 
-
 }