]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson: convert cross-core operations to use RemoteOperation
authorSamuel Just <sjust@redhat.com>
Sat, 5 Apr 2025 02:12:33 +0000 (02:12 +0000)
committerMatan Breizman <mbreizma@redhat.com>
Wed, 30 Apr 2025 08:22:09 +0000 (08:22 +0000)
Signed-off-by: Samuel Just <sjust@redhat.com>
(cherry picked from commit b031373de33894e29fa4bf4d207b480a31431c08)

15 files changed:
src/crimson/osd/osd_operations/client_request.cc
src/crimson/osd/osd_operations/client_request.h
src/crimson/osd/osd_operations/logmissing_request.cc
src/crimson/osd/osd_operations/logmissing_request.h
src/crimson/osd/osd_operations/logmissing_request_reply.cc
src/crimson/osd/osd_operations/logmissing_request_reply.h
src/crimson/osd/osd_operations/peering_event.cc
src/crimson/osd/osd_operations/peering_event.h
src/crimson/osd/osd_operations/pgpct_request.cc
src/crimson/osd/osd_operations/pgpct_request.h
src/crimson/osd/osd_operations/recovery_subrequest.cc
src/crimson/osd/osd_operations/recovery_subrequest.h
src/crimson/osd/osd_operations/replicated_request.cc
src/crimson/osd/osd_operations/replicated_request.h
src/crimson/osd/osd_operations/scrub_events.h

index 9b02b19b7f1269b141d6bec855c11a7df4741c0d..06097a8084f45d0d02c97706198230cf4d8fdd49 100644 (file)
@@ -60,8 +60,8 @@ void ClientRequest::complete_request(PG &pg)
 ClientRequest::ClientRequest(
   ShardServices &_shard_services, crimson::net::ConnectionRef conn,
   Ref<MOSDOp> &&m)
-  : shard_services(&_shard_services),
-    l_conn(std::move(conn)),
+  : RemoteOperation(std::move(conn)),
+    shard_services(&_shard_services),
     m(std::move(m)),
     begin_time(std::chrono::steady_clock::now()),
     instance_handle(new instance_handle_t)
@@ -486,7 +486,7 @@ ClientRequest::do_process(
     co_return;
   }
 
-  OpsExecuter ox(pg, obc, op_info, *m, r_conn, snapc);
+  OpsExecuter ox(pg, obc, op_info, *m, get_remote_connection(), snapc);
   auto ret = co_await pg->run_executer(
     ox, obc, op_info, m->ops
   ).si_then([]() -> std::optional<std::error_code> {
index d8865235aeae19d498c87cb852f3ba284c8d67d2..4dfb735041ba11068bb58bed842d332592fcb2c4 100644 (file)
@@ -27,13 +27,13 @@ class PG;
 class OSD;
 class ShardServices;
 
-class ClientRequest final : public PhasedOperationT<ClientRequest> {
+class ClientRequest final
+  : public PhasedOperationT<ClientRequest>,
+    public RemoteOperation
+{
   // Initially set to primary core, updated to pg core after with_pg()
   ShardServices *shard_services = nullptr;
 
-  crimson::net::ConnectionRef l_conn;
-  crimson::net::ConnectionXcoreRef r_conn;
-
   // must be after conn due to ConnectionPipeline's life-time
   Ref<MOSDOp> m;
   OpInfo op_info;
@@ -54,14 +54,6 @@ public:
     static_assert(std::is_same_v<T, MOSDOp>);
     return m.get();
   }
-  const crimson::net::Connection &get_connection() const {
-    if (l_conn) {
-      return *l_conn;
-    } else {
-      assert(r_conn);
-      return *r_conn;
-    }
-  }
 
   /**
    * instance_handle_t
@@ -236,33 +228,6 @@ public:
 
   PerShardPipeline &get_pershard_pipeline(ShardServices &);
 
-  crimson::net::Connection &get_local_connection() {
-    assert(l_conn);
-    assert(!r_conn);
-    return *l_conn;
-  };
-
-  crimson::net::Connection &get_foreign_connection() {
-    assert(r_conn);
-    assert(!l_conn);
-    return *r_conn;
-  };
-
-  crimson::net::ConnectionFFRef prepare_remote_submission() {
-    assert(l_conn);
-    assert(!r_conn);
-    auto ret = seastar::make_foreign(std::move(l_conn));
-    l_conn.reset();
-    return ret;
-  }
-
-  void finish_remote_submission(crimson::net::ConnectionFFRef conn) {
-    assert(conn);
-    assert(!l_conn);
-    assert(!r_conn);
-    r_conn = make_local_shared_foreign(std::move(conn));
-  }
-
   interruptible_future<> with_pg_process_interruptible(
     Ref<PG> pgref, const unsigned instance_id, instance_handle_t &ihref);
 
index 274744cdd92da2f2ad0122eedb2f905c972dc088..3bc6468999a1a8d7b93c49b7c034741b6d30adbb 100644 (file)
@@ -22,7 +22,7 @@ namespace crimson::osd {
 
 LogMissingRequest::LogMissingRequest(crimson::net::ConnectionRef&& conn,
                       Ref<MOSDPGUpdateLogMissing> &&req)
-  : l_conn{std::move(conn)},
+  : RemoteOperation{std::move(conn)},
     req{std::move(req)}
 {}
 
@@ -82,7 +82,7 @@ seastar::future<> LogMissingRequest::with_pg(
           std::move(trigger), req->min_epoch);
       });
     }).then_interruptible([this, pg](auto) {
-      return pg->do_update_log_missing(req, r_conn);
+      return pg->do_update_log_missing(req, get_remote_connection());
     }).then_interruptible([this] {
       logger().debug("{}: complete", *this);
       return handle.complete();
index fe4761c4ab482645ada4d64c1031ae2828a1bbdb..da4dc3245be69e8c66c3e106ebd515be2c901eb4 100644 (file)
@@ -22,7 +22,9 @@ class ShardServices;
 class OSD;
 class PG;
 
-class LogMissingRequest final : public PhasedOperationT<LogMissingRequest> {
+class LogMissingRequest final :
+    public PhasedOperationT<LogMissingRequest>,
+    public RemoteOperation {
 public:
   static constexpr OperationTypeCode type = OperationTypeCode::logmissing_request;
   LogMissingRequest(crimson::net::ConnectionRef&&, Ref<MOSDPGUpdateLogMissing>&&);
@@ -44,33 +46,6 @@ public:
 
   PerShardPipeline &get_pershard_pipeline(ShardServices &);
 
-  crimson::net::Connection &get_local_connection() {
-    assert(l_conn);
-    assert(!r_conn);
-    return *l_conn;
-  };
-
-  crimson::net::Connection &get_foreign_connection() {
-    assert(r_conn);
-    assert(!l_conn);
-    return *r_conn;
-  };
-
-  crimson::net::ConnectionFFRef prepare_remote_submission() {
-    assert(l_conn);
-    assert(!r_conn);
-    auto ret = seastar::make_foreign(std::move(l_conn));
-    l_conn.reset();
-    return ret;
-  }
-
-  void finish_remote_submission(crimson::net::ConnectionFFRef conn) {
-    assert(conn);
-    assert(!l_conn);
-    assert(!r_conn);
-    r_conn = make_local_shared_foreign(std::move(conn));
-  }
-
   seastar::future<> with_pg(
     ShardServices &shard_services, Ref<PG> pg);
 
@@ -89,9 +64,6 @@ public:
 private:
   PGRepopPipeline &repop_pipeline(PG &pg);
 
-  crimson::net::ConnectionRef l_conn;
-  crimson::net::ConnectionXcoreRef r_conn;
-
   // must be after `conn` to ensure the ConnectionPipeline's is alive
   PipelineHandle handle;
   Ref<MOSDPGUpdateLogMissing> req;
index 5640610bd01dffad46167ea3be31e46d402420fe..c9456d19b5c97b1f22fa137c344411be4cb01be2 100644 (file)
@@ -21,7 +21,7 @@ namespace crimson::osd {
 LogMissingRequestReply::LogMissingRequestReply(
   crimson::net::ConnectionRef&& conn,
   Ref<MOSDPGUpdateLogMissingReply> &&req)
-  : l_conn{std::move(conn)},
+  : RemoteOperation{std::move(conn)},
     req{std::move(req)}
 {}
 
index bdb6c2ac6acdd19289d58002fa4e628d4ba47585..7b1f1d7e041c0d52a8ed17e57e07dc9dc7663ee6 100644 (file)
@@ -22,7 +22,9 @@ class ShardServices;
 class OSD;
 class PG;
 
-class LogMissingRequestReply final : public PhasedOperationT<LogMissingRequestReply> {
+class LogMissingRequestReply final :
+    public PhasedOperationT<LogMissingRequestReply>,
+    public RemoteOperation {
 public:
   static constexpr OperationTypeCode type = OperationTypeCode::logmissing_request_reply;
   LogMissingRequestReply(crimson::net::ConnectionRef&&, Ref<MOSDPGUpdateLogMissingReply>&&);
@@ -44,33 +46,6 @@ public:
 
   PerShardPipeline &get_pershard_pipeline(ShardServices &);
 
-  crimson::net::Connection &get_local_connection() {
-    assert(l_conn);
-    assert(!r_conn);
-    return *l_conn;
-  };
-
-  crimson::net::Connection &get_foreign_connection() {
-    assert(r_conn);
-    assert(!l_conn);
-    return *r_conn;
-  };
-
-  crimson::net::ConnectionFFRef prepare_remote_submission() {
-    assert(l_conn);
-    assert(!r_conn);
-    auto ret = seastar::make_foreign(std::move(l_conn));
-    l_conn.reset();
-    return ret;
-  }
-
-  void finish_remote_submission(crimson::net::ConnectionFFRef conn) {
-    assert(conn);
-    assert(!l_conn);
-    assert(!r_conn);
-    r_conn = make_local_shared_foreign(std::move(conn));
-  }
-
   seastar::future<> with_pg(
     ShardServices &shard_services, Ref<PG> pg);
 
@@ -85,9 +60,6 @@ public:
   > tracking_events;
 
 private:
-  crimson::net::ConnectionRef l_conn;
-  crimson::net::ConnectionXcoreRef r_conn;
-
   // must be after `conn` to ensure the ConnectionPipeline's is alive
   PipelineHandle handle;
   Ref<MOSDPGUpdateLogMissingReply> req;
index fb5696b0a9e3ea7bdb9677d442229719c1a1cb8e..4396392c36361f73ffacd3cdaf8a39f5343da098 100644 (file)
@@ -138,8 +138,8 @@ PeeringEvent<T>::complete_rctx(ShardServices &shard_services, Ref<PG> pg)
 
 ConnectionPipeline &RemotePeeringEvent::get_connection_pipeline()
 {
-  return get_osd_priv(&get_local_connection()
-         ).peering_request_conn_pipeline;
+  return get_osd_priv(&get_connection()
+  ).peering_request_conn_pipeline;
 }
 
 PerShardPipeline &RemotePeeringEvent::get_pershard_pipeline(
index 9b8723b1c147adea9eebe04efe0ed73a2ff7dc4b..4b342a48e51a3c6b5fc61f72e4e661d76b1c4583 100644 (file)
@@ -97,11 +97,10 @@ public:
     ShardServices &shard_services, Ref<PG> pg);
 };
 
-class RemotePeeringEvent : public PeeringEvent<RemotePeeringEvent> {
+class RemotePeeringEvent :
+    public PeeringEvent<RemotePeeringEvent>,
+    public RemoteOperation {
 protected:
-  crimson::net::ConnectionRef l_conn;
-  crimson::net::ConnectionXcoreRef r_conn;
-
   // must be after conn due to ConnectionPipeline's life-time
   PipelineHandle handle;
 
@@ -117,7 +116,7 @@ public:
   template <typename... Args>
   RemotePeeringEvent(crimson::net::ConnectionRef conn, Args&&... args) :
     PeeringEvent(std::forward<Args>(args)...),
-    l_conn(conn)
+    RemoteOperation(std::move(conn))
   {}
 
   std::tuple<
@@ -145,33 +144,6 @@ public:
   ConnectionPipeline &get_connection_pipeline();
 
   PerShardPipeline &get_pershard_pipeline(ShardServices &);
-
-  crimson::net::Connection &get_local_connection() {
-    assert(l_conn);
-    assert(!r_conn);
-    return *l_conn;
-  };
-
-  crimson::net::Connection &get_foreign_connection() {
-    assert(r_conn);
-    assert(!l_conn);
-    return *r_conn;
-  };
-
-  crimson::net::ConnectionFFRef prepare_remote_submission() {
-    assert(l_conn);
-    assert(!r_conn);
-    auto ret = seastar::make_foreign(std::move(l_conn));
-    l_conn.reset();
-    return ret;
-  }
-
-  void finish_remote_submission(crimson::net::ConnectionFFRef conn) {
-    assert(conn);
-    assert(!l_conn);
-    assert(!r_conn);
-    r_conn = make_local_shared_foreign(std::move(conn));
-  }
 };
 
 class LocalPeeringEvent final : public PeeringEvent<LocalPeeringEvent> {
index 3a9e14446866b5be187071f9eef09cbb080e1faf..6a06cfdb53659feab7705cdade05e61a52b765ea 100644 (file)
@@ -17,7 +17,7 @@ namespace crimson::osd {
 
 PGPCTRequest::PGPCTRequest(crimson::net::ConnectionRef&& conn,
                       Ref<MOSDPGPCT> &&req)
-  : l_conn{std::move(conn)},
+  : RemoteOperation{std::move(conn)},
     req{std::move(req)}
 {}
 
index 39c1c2e2d87cc7a1aef5e51d756b9125ba55a3b1..49e37ad0cf6c04773fcbf964c3eb4ce1acb096de 100644 (file)
@@ -22,7 +22,9 @@ class ShardServices;
 class OSD;
 class PG;
 
-class PGPCTRequest final : public PhasedOperationT<PGPCTRequest> {
+class PGPCTRequest final :
+    public PhasedOperationT<PGPCTRequest>,
+    public RemoteOperation {
 public:
   static constexpr OperationTypeCode type = OperationTypeCode::pgpct_request;
   PGPCTRequest(crimson::net::ConnectionRef&&, Ref<MOSDPGPCT>&&);
@@ -42,33 +44,6 @@ public:
 
   PerShardPipeline &get_pershard_pipeline(ShardServices &);
 
-  crimson::net::Connection &get_local_connection() {
-    assert(l_conn);
-    assert(!r_conn);
-    return *l_conn;
-  };
-
-  crimson::net::Connection &get_foreign_connection() {
-    assert(r_conn);
-    assert(!l_conn);
-    return *r_conn;
-  };
-
-  crimson::net::ConnectionFFRef prepare_remote_submission() {
-    assert(l_conn);
-    assert(!r_conn);
-    auto ret = seastar::make_foreign(std::move(l_conn));
-    l_conn.reset();
-    return ret;
-  }
-
-  void finish_remote_submission(crimson::net::ConnectionFFRef conn) {
-    assert(conn);
-    assert(!l_conn);
-    assert(!r_conn);
-    r_conn = make_local_shared_foreign(std::move(conn));
-  }
-
   seastar::future<> with_pg(
     ShardServices &shard_services, Ref<PG> pg);
 
@@ -88,9 +63,6 @@ public:
   > tracking_events;
 
 private:
-  crimson::net::ConnectionRef l_conn;
-  crimson::net::ConnectionXcoreRef r_conn;
-
   // must be after `conn` to ensure the ConnectionPipeline is alive
   PipelineHandle handle;
   Ref<MOSDPGPCT> req;
index f90bf9901de54d2c8e5148afa05b2d7cea6f8082..fcdf3ff6397680a6b3c2f06199d2401bf88fc862 100644 (file)
@@ -35,7 +35,8 @@ seastar::future<> RecoverySubRequest::with_pg(
   return interruptor::with_interruption([this, pgref] {
     LOG_PREFIX(RecoverySubRequest::with_pg);
     DEBUGI("{}: {}", "RecoverySubRequest::with_pg", *this);
-    return pgref->get_recovery_backend()->handle_recovery_op(m, r_conn
+    return pgref->get_recovery_backend()->handle_recovery_op(
+      m, get_remote_connection()
     ).then_interruptible([this] {
       LOG_PREFIX(RecoverySubRequest::with_pg);
       DEBUGI("{}: complete", *this);
index 2fe8ff372b3f95021d7058ce3461022321a16a12..fe23879e6fc163386f96b66fa1d009976277f3ce 100644 (file)
@@ -14,7 +14,9 @@ namespace crimson::osd {
 
 class PG;
 
-class RecoverySubRequest final : public PhasedOperationT<RecoverySubRequest> {
+class RecoverySubRequest final :
+    public PhasedOperationT<RecoverySubRequest>,
+    public RemoteOperation {
 public:
   static constexpr OperationTypeCode type =
     OperationTypeCode::background_recovery_sub;
@@ -22,7 +24,7 @@ public:
   RecoverySubRequest(
     crimson::net::ConnectionRef conn,
     Ref<MOSDFastDispatchOp>&& m)
-    : l_conn(conn), m(m) {}
+    : RemoteOperation(std::move(conn)), m(m) {}
 
   void print(std::ostream& out) const final
   {
@@ -47,33 +49,6 @@ public:
 
   PerShardPipeline &get_pershard_pipeline(ShardServices &);
 
-  crimson::net::Connection &get_local_connection() {
-    assert(l_conn);
-    assert(!r_conn);
-    return *l_conn;
-  };
-
-  crimson::net::Connection &get_foreign_connection() {
-    assert(r_conn);
-    assert(!l_conn);
-    return *r_conn;
-  };
-
-  crimson::net::ConnectionFFRef prepare_remote_submission() {
-    assert(l_conn);
-    assert(!r_conn);
-    auto ret = seastar::make_foreign(std::move(l_conn));
-    l_conn.reset();
-    return ret;
-  }
-
-  void finish_remote_submission(crimson::net::ConnectionFFRef conn) {
-    assert(conn);
-    assert(!l_conn);
-    assert(!r_conn);
-    r_conn = make_local_shared_foreign(std::move(conn));
-  }
-
   seastar::future<> with_pg(
     ShardServices &shard_services, Ref<PG> pg);
 
@@ -89,9 +64,6 @@ public:
   > tracking_events;
 
 private:
-  crimson::net::ConnectionRef l_conn;
-  crimson::net::ConnectionXcoreRef r_conn;
-
   // must be after `conn` to ensure the ConnectionPipeline's is alive
   PipelineHandle handle;
   Ref<MOSDFastDispatchOp> m;
index 7eea4ca45f5550bf50da3c4529b6b3ddb9bdf44d..4f6110bcde567bce22fedae137432610ce1055df 100644 (file)
@@ -23,7 +23,7 @@ namespace crimson::osd {
 
 RepRequest::RepRequest(crimson::net::ConnectionRef&& conn,
                       Ref<MOSDRepOp> &&req)
-  : l_conn{std::move(conn)},
+  : RemoteOperation{std::move(conn)},
     req{std::move(req)}
 {}
 
@@ -49,8 +49,8 @@ void RepRequest::dump_detail(Formatter *f) const
 
 ConnectionPipeline &RepRequest::get_connection_pipeline()
 {
-  return get_osd_priv(&get_local_connection()
-         ).replicated_request_conn_pipeline;
+  return get_osd_priv(&get_connection()
+  ).replicated_request_conn_pipeline;
 }
 
 PerShardPipeline &RepRequest::get_pershard_pipeline(
index c2494b3715f181a801121bf450660c360d7ee6ed..ce8cf72e9f81aa3f980befbb4f784c7315ac4efb 100644 (file)
@@ -22,7 +22,9 @@ class ShardServices;
 class OSD;
 class PG;
 
-class RepRequest final : public PhasedOperationT<RepRequest> {
+class RepRequest final :
+    public PhasedOperationT<RepRequest>,
+    public RemoteOperation {
 public:
   static constexpr OperationTypeCode type = OperationTypeCode::replicated_request;
   RepRequest(crimson::net::ConnectionRef&&, Ref<MOSDRepOp>&&);
@@ -44,33 +46,6 @@ public:
 
   PerShardPipeline &get_pershard_pipeline(ShardServices &);
 
-  crimson::net::Connection &get_local_connection() {
-    assert(l_conn);
-    assert(!r_conn);
-    return *l_conn;
-  };
-
-  crimson::net::Connection &get_foreign_connection() {
-    assert(r_conn);
-    assert(!l_conn);
-    return *r_conn;
-  };
-
-  crimson::net::ConnectionFFRef prepare_remote_submission() {
-    assert(l_conn);
-    assert(!r_conn);
-    auto ret = seastar::make_foreign(std::move(l_conn));
-    l_conn.reset();
-    return ret;
-  }
-
-  void finish_remote_submission(crimson::net::ConnectionFFRef conn) {
-    assert(conn);
-    assert(!l_conn);
-    assert(!r_conn);
-    r_conn = make_local_shared_foreign(std::move(conn));
-  }
-
   interruptible_future<> with_pg_interruptible(
     Ref<PG> pg);
 
@@ -94,9 +69,6 @@ public:
 private:
   PGRepopPipeline &repop_pipeline(PG &pg);
 
-  crimson::net::ConnectionRef l_conn;
-  crimson::net::ConnectionXcoreRef r_conn;
-
   PipelineHandle handle;
   Ref<MOSDRepOp> req;
 };
index 8bed90e4c14fb56c6df7666e8d5c3b670019c36d..73d18151a3fa4ca72c16a2ba8a34f04ee897d91b 100644 (file)
@@ -14,7 +14,9 @@ namespace crimson::osd {
 class PG;
 
 template <typename T>
-class RemoteScrubEventBaseT : public PhasedOperationT<T> {
+class RemoteScrubEventBaseT :
+    public PhasedOperationT<T>,
+    public RemoteOperation {
   T* that() {
     return static_cast<T*>(this);
   }
@@ -24,9 +26,6 @@ class RemoteScrubEventBaseT : public PhasedOperationT<T> {
 
   PipelineHandle handle;
 
-  crimson::net::ConnectionRef l_conn;
-  crimson::net::ConnectionXcoreRef r_conn;
-
   spg_t pgid;
 
 protected:
@@ -40,7 +39,7 @@ protected:
 public:
   RemoteScrubEventBaseT(
     crimson::net::ConnectionRef conn, epoch_t epoch, spg_t pgid)
-    : l_conn(std::move(conn)), pgid(pgid), epoch(epoch) {}
+    : RemoteOperation(std::move(conn)), pgid(pgid), epoch(epoch) {}
 
   PGPeeringPipeline &get_peering_pipeline(PG &pg);
 
@@ -48,33 +47,6 @@ public:
 
   PerShardPipeline &get_pershard_pipeline(ShardServices &);
 
-  crimson::net::Connection &get_local_connection() {
-    assert(l_conn);
-    assert(!r_conn);
-    return *l_conn;
-  };
-
-  crimson::net::Connection &get_foreign_connection() {
-    assert(r_conn);
-    assert(!l_conn);
-    return *r_conn;
-  };
-
-  crimson::net::ConnectionFFRef prepare_remote_submission() {
-    assert(l_conn);
-    assert(!r_conn);
-    auto ret = seastar::make_foreign(std::move(l_conn));
-    l_conn.reset();
-    return ret;
-  }
-
-  void finish_remote_submission(crimson::net::ConnectionFFRef conn) {
-    assert(conn);
-    assert(!l_conn);
-    assert(!r_conn);
-    r_conn = make_local_shared_foreign(std::move(conn));
-  }
-
   static constexpr bool can_create() { return false; }
 
   spg_t get_pgid() const {