From: Samuel Just Date: Fri, 4 Apr 2025 02:13:58 +0000 (-0700) Subject: crimson: add operation wrapper for MOSDRepOpReply X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=d4ce5404f8244925b7d3de145aa1d93a5eb465fc;p=ceph.git crimson: add operation wrapper for MOSDRepOpReply This should avoid reordering between cores. Fixes: https://tracker.ceph.com/issues/69439 Signed-off-by: Samuel Just (cherry picked from commit 0c15eb5ca59c98d776091c5602888b0895df0a72) --- diff --git a/src/crimson/osd/CMakeLists.txt b/src/crimson/osd/CMakeLists.txt index 95511f3e8a435..4fdcb4bba32ab 100644 --- a/src/crimson/osd/CMakeLists.txt +++ b/src/crimson/osd/CMakeLists.txt @@ -23,6 +23,7 @@ add_executable(crimson-osd osd_operations/peering_event.cc osd_operations/pg_advance_map.cc osd_operations/replicated_request.cc + osd_operations/replicated_request_reply.cc osd_operations/logmissing_request.cc osd_operations/logmissing_request_reply.cc osd_operations/background_recovery.cc diff --git a/src/crimson/osd/osd.cc b/src/crimson/osd/osd.cc index 0ae90919179ff..a90f00291591e 100644 --- a/src/crimson/osd/osd.cc +++ b/src/crimson/osd/osd.cc @@ -58,6 +58,7 @@ #include "crimson/osd/osd_operations/pg_advance_map.h" #include "crimson/osd/osd_operations/recovery_subrequest.h" #include "crimson/osd/osd_operations/replicated_request.h" +#include "crimson/osd/osd_operations/replicated_request_reply.h" #include "crimson/osd/osd_operations/scrub_events.h" #include "crimson/osd/osd_operation_external_tracking.h" #include "crimson/crush/CrushLocation.h" @@ -1437,19 +1438,9 @@ seastar::future<> OSD::handle_rep_op_reply( crimson::net::ConnectionRef conn, Ref m) { - LOG_PREFIX(OSD::handle_rep_op_reply); - spg_t pgid = m->get_spg(); - return pg_shard_manager.with_pg( - pgid, - [FNAME, m=std::move(m)](auto &&pg) { - if (pg) { - m->finish_decode(); - pg->handle_rep_op_reply(*m); - } else { - DEBUG("stale reply: {}", *m); - } - return seastar::now(); - }); + return pg_shard_manager.start_pg_operation_active( + std::move(conn), + std::move(m)); } seastar::future<> OSD::handle_scrub_command( diff --git a/src/crimson/osd/osd_operation.h b/src/crimson/osd/osd_operation.h index 33f3b10ee9b0a..11a32af857c28 100644 --- a/src/crimson/osd/osd_operation.h +++ b/src/crimson/osd/osd_operation.h @@ -90,6 +90,7 @@ enum class OperationTypeCode { pg_advance_map, pg_creation, replicated_request, + replicated_request_reply, background_recovery, background_recovery_sub, internal_client_request, @@ -114,6 +115,7 @@ static constexpr const char* const OP_NAMES[] = { "pg_advance_map", "pg_creation", "replicated_request", + "replicated_request_reply", "background_recovery", "background_recovery_sub", "internal_client_request", diff --git a/src/crimson/osd/osd_operations/replicated_request_reply.cc b/src/crimson/osd/osd_operations/replicated_request_reply.cc new file mode 100644 index 0000000000000..8278651fad9e3 --- /dev/null +++ b/src/crimson/osd/osd_operations/replicated_request_reply.cc @@ -0,0 +1,48 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#include "replicated_request_reply.h" + +#include "common/Formatter.h" + +#include "crimson/osd/pg.h" +#include "crimson/osd/replicated_backend.h" + +SET_SUBSYS(osd); + +namespace crimson::osd { + +ReplicatedRequestReply::ReplicatedRequestReply( + crimson::net::ConnectionRef&& conn, + Ref &&req) + : RemoteOperation{std::move(conn)}, + req{std::move(req)} +{} + +void ReplicatedRequestReply::print(std::ostream& os) const +{ + os << "ReplicatedRequestReply(" + << " req=" << *req + << ")"; +} + +void ReplicatedRequestReply::dump_detail(Formatter *f) const +{ + f->open_object_section("ReplicatedRequestReply"); + f->dump_stream("pgid") << req->get_spg(); + f->dump_unsigned("map_epoch", req->get_map_epoch()); + f->dump_unsigned("min_epoch", req->get_min_epoch()); + f->close_section(); +} + +seastar::future<> ReplicatedRequestReply::with_pg( + ShardServices &shard_services, Ref pgref) +{ + LOG_PREFIX(ReplicatedRequestReply::with_pg); + DEBUGDPP("{}", *pgref, *this); + req->finish_decode(); + pgref->handle_rep_op_reply(*req); + return seastar::now(); +} + +} diff --git a/src/crimson/osd/osd_operations/replicated_request_reply.h b/src/crimson/osd/osd_operations/replicated_request_reply.h new file mode 100644 index 0000000000000..3c33e64ac8a19 --- /dev/null +++ b/src/crimson/osd/osd_operations/replicated_request_reply.h @@ -0,0 +1,51 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#pragma once + +#include "crimson/net/Connection.h" +#include "crimson/osd/osd_operation.h" +#include "crimson/common/type_helpers.h" +#include "messages/MOSDRepOpReply.h" + +namespace ceph { + class Formatter; +} + +namespace crimson::osd { + +class ShardServices; + +class OSD; +class PG; + +class ReplicatedRequestReply final + : public OperationT, + public RemoteOperation +{ +public: + static constexpr OperationTypeCode type = + OperationTypeCode::replicated_request_reply; + ReplicatedRequestReply(crimson::net::ConnectionRef&&, Ref&&); + + void print(std::ostream &) const final; + void dump_detail(ceph::Formatter* f) const final; + + spg_t get_pgid() const { + return req->get_spg(); + } + + seastar::future<> with_pg( + ShardServices &shard_services, Ref pg); + + PipelineHandle &get_handle() { return handle; } +private: + PipelineHandle handle; + Ref req; +}; + +} + +#if FMT_VERSION >= 90000 +template <> struct fmt::formatter : fmt::ostream_formatter {}; +#endif