From: Samuel Just Date: Sat, 5 Apr 2025 02:12:33 +0000 (+0000) Subject: crimson: convert cross-core operations to use RemoteOperation X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=b031373de33894e29fa4bf4d207b480a31431c08;p=ceph.git crimson: convert cross-core operations to use RemoteOperation Signed-off-by: Samuel Just --- diff --git a/src/crimson/osd/osd_operations/client_request.cc b/src/crimson/osd/osd_operations/client_request.cc index b29cf29c5ed42..ac59d2173637d 100644 --- a/src/crimson/osd/osd_operations/client_request.cc +++ b/src/crimson/osd/osd_operations/client_request.cc @@ -60,8 +60,8 @@ void ClientRequest::complete_request(PG &pg) ClientRequest::ClientRequest( ShardServices &_shard_services, crimson::net::ConnectionRef conn, Ref &&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 { diff --git a/src/crimson/osd/osd_operations/client_request.h b/src/crimson/osd/osd_operations/client_request.h index d8865235aeae1..4dfb735041ba1 100644 --- a/src/crimson/osd/osd_operations/client_request.h +++ b/src/crimson/osd/osd_operations/client_request.h @@ -27,13 +27,13 @@ class PG; class OSD; class ShardServices; -class ClientRequest final : public PhasedOperationT { +class ClientRequest final + : public PhasedOperationT, + 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 m; OpInfo op_info; @@ -54,14 +54,6 @@ public: static_assert(std::is_same_v); 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 pgref, const unsigned instance_id, instance_handle_t &ihref); diff --git a/src/crimson/osd/osd_operations/logmissing_request.cc b/src/crimson/osd/osd_operations/logmissing_request.cc index 274744cdd92da..3bc6468999a1a 100644 --- a/src/crimson/osd/osd_operations/logmissing_request.cc +++ b/src/crimson/osd/osd_operations/logmissing_request.cc @@ -22,7 +22,7 @@ namespace crimson::osd { LogMissingRequest::LogMissingRequest(crimson::net::ConnectionRef&& conn, Ref &&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(); diff --git a/src/crimson/osd/osd_operations/logmissing_request.h b/src/crimson/osd/osd_operations/logmissing_request.h index fe4761c4ab482..da4dc3245be69 100644 --- a/src/crimson/osd/osd_operations/logmissing_request.h +++ b/src/crimson/osd/osd_operations/logmissing_request.h @@ -22,7 +22,9 @@ class ShardServices; class OSD; class PG; -class LogMissingRequest final : public PhasedOperationT { +class LogMissingRequest final : + public PhasedOperationT, + public RemoteOperation { public: static constexpr OperationTypeCode type = OperationTypeCode::logmissing_request; LogMissingRequest(crimson::net::ConnectionRef&&, Ref&&); @@ -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); @@ -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 req; diff --git a/src/crimson/osd/osd_operations/logmissing_request_reply.cc b/src/crimson/osd/osd_operations/logmissing_request_reply.cc index 5640610bd01df..c9456d19b5c97 100644 --- a/src/crimson/osd/osd_operations/logmissing_request_reply.cc +++ b/src/crimson/osd/osd_operations/logmissing_request_reply.cc @@ -21,7 +21,7 @@ namespace crimson::osd { LogMissingRequestReply::LogMissingRequestReply( crimson::net::ConnectionRef&& conn, Ref &&req) - : l_conn{std::move(conn)}, + : RemoteOperation{std::move(conn)}, req{std::move(req)} {} diff --git a/src/crimson/osd/osd_operations/logmissing_request_reply.h b/src/crimson/osd/osd_operations/logmissing_request_reply.h index bdb6c2ac6acdd..7b1f1d7e041c0 100644 --- a/src/crimson/osd/osd_operations/logmissing_request_reply.h +++ b/src/crimson/osd/osd_operations/logmissing_request_reply.h @@ -22,7 +22,9 @@ class ShardServices; class OSD; class PG; -class LogMissingRequestReply final : public PhasedOperationT { +class LogMissingRequestReply final : + public PhasedOperationT, + public RemoteOperation { public: static constexpr OperationTypeCode type = OperationTypeCode::logmissing_request_reply; LogMissingRequestReply(crimson::net::ConnectionRef&&, Ref&&); @@ -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); @@ -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 req; diff --git a/src/crimson/osd/osd_operations/peering_event.cc b/src/crimson/osd/osd_operations/peering_event.cc index fb5696b0a9e3e..4396392c36361 100644 --- a/src/crimson/osd/osd_operations/peering_event.cc +++ b/src/crimson/osd/osd_operations/peering_event.cc @@ -138,8 +138,8 @@ PeeringEvent::complete_rctx(ShardServices &shard_services, Ref 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( diff --git a/src/crimson/osd/osd_operations/peering_event.h b/src/crimson/osd/osd_operations/peering_event.h index 9b8723b1c147a..4b342a48e51a3 100644 --- a/src/crimson/osd/osd_operations/peering_event.h +++ b/src/crimson/osd/osd_operations/peering_event.h @@ -97,11 +97,10 @@ public: ShardServices &shard_services, Ref pg); }; -class RemotePeeringEvent : public PeeringEvent { +class RemotePeeringEvent : + public PeeringEvent, + 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 RemotePeeringEvent(crimson::net::ConnectionRef conn, Args&&... args) : PeeringEvent(std::forward(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 { diff --git a/src/crimson/osd/osd_operations/pgpct_request.cc b/src/crimson/osd/osd_operations/pgpct_request.cc index 3a9e14446866b..6a06cfdb53659 100644 --- a/src/crimson/osd/osd_operations/pgpct_request.cc +++ b/src/crimson/osd/osd_operations/pgpct_request.cc @@ -17,7 +17,7 @@ namespace crimson::osd { PGPCTRequest::PGPCTRequest(crimson::net::ConnectionRef&& conn, Ref &&req) - : l_conn{std::move(conn)}, + : RemoteOperation{std::move(conn)}, req{std::move(req)} {} diff --git a/src/crimson/osd/osd_operations/pgpct_request.h b/src/crimson/osd/osd_operations/pgpct_request.h index 39c1c2e2d87cc..49e37ad0cf6c0 100644 --- a/src/crimson/osd/osd_operations/pgpct_request.h +++ b/src/crimson/osd/osd_operations/pgpct_request.h @@ -22,7 +22,9 @@ class ShardServices; class OSD; class PG; -class PGPCTRequest final : public PhasedOperationT { +class PGPCTRequest final : + public PhasedOperationT, + public RemoteOperation { public: static constexpr OperationTypeCode type = OperationTypeCode::pgpct_request; PGPCTRequest(crimson::net::ConnectionRef&&, Ref&&); @@ -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); @@ -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 req; diff --git a/src/crimson/osd/osd_operations/recovery_subrequest.cc b/src/crimson/osd/osd_operations/recovery_subrequest.cc index f90bf9901de54..fcdf3ff639768 100644 --- a/src/crimson/osd/osd_operations/recovery_subrequest.cc +++ b/src/crimson/osd/osd_operations/recovery_subrequest.cc @@ -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); diff --git a/src/crimson/osd/osd_operations/recovery_subrequest.h b/src/crimson/osd/osd_operations/recovery_subrequest.h index 2fe8ff372b3f9..fe23879e6fc16 100644 --- a/src/crimson/osd/osd_operations/recovery_subrequest.h +++ b/src/crimson/osd/osd_operations/recovery_subrequest.h @@ -14,7 +14,9 @@ namespace crimson::osd { class PG; -class RecoverySubRequest final : public PhasedOperationT { +class RecoverySubRequest final : + public PhasedOperationT, + public RemoteOperation { public: static constexpr OperationTypeCode type = OperationTypeCode::background_recovery_sub; @@ -22,7 +24,7 @@ public: RecoverySubRequest( crimson::net::ConnectionRef conn, Ref&& 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); @@ -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 m; diff --git a/src/crimson/osd/osd_operations/replicated_request.cc b/src/crimson/osd/osd_operations/replicated_request.cc index 7eea4ca45f555..4f6110bcde567 100644 --- a/src/crimson/osd/osd_operations/replicated_request.cc +++ b/src/crimson/osd/osd_operations/replicated_request.cc @@ -23,7 +23,7 @@ namespace crimson::osd { RepRequest::RepRequest(crimson::net::ConnectionRef&& conn, Ref &&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( diff --git a/src/crimson/osd/osd_operations/replicated_request.h b/src/crimson/osd/osd_operations/replicated_request.h index c2494b3715f18..ce8cf72e9f81a 100644 --- a/src/crimson/osd/osd_operations/replicated_request.h +++ b/src/crimson/osd/osd_operations/replicated_request.h @@ -22,7 +22,9 @@ class ShardServices; class OSD; class PG; -class RepRequest final : public PhasedOperationT { +class RepRequest final : + public PhasedOperationT, + public RemoteOperation { public: static constexpr OperationTypeCode type = OperationTypeCode::replicated_request; RepRequest(crimson::net::ConnectionRef&&, Ref&&); @@ -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); @@ -94,9 +69,6 @@ public: private: PGRepopPipeline &repop_pipeline(PG &pg); - crimson::net::ConnectionRef l_conn; - crimson::net::ConnectionXcoreRef r_conn; - PipelineHandle handle; Ref req; }; diff --git a/src/crimson/osd/osd_operations/scrub_events.h b/src/crimson/osd/osd_operations/scrub_events.h index 8bed90e4c14fb..73d18151a3fa4 100644 --- a/src/crimson/osd/osd_operations/scrub_events.h +++ b/src/crimson/osd/osd_operations/scrub_events.h @@ -14,7 +14,9 @@ namespace crimson::osd { class PG; template -class RemoteScrubEventBaseT : public PhasedOperationT { +class RemoteScrubEventBaseT : + public PhasedOperationT, + public RemoteOperation { T* that() { return static_cast(this); } @@ -24,9 +26,6 @@ class RemoteScrubEventBaseT : public PhasedOperationT { 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 {