From 6a8bdb4bd1d638a428c3fbfc9b9f4ff6a2d1f39b Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Wed, 4 May 2022 23:14:44 +0000 Subject: [PATCH] crimson: refactor RepRequest to use start_pg_operation Signed-off-by: Samuel Just --- src/crimson/osd/osd.cc | 3 +- .../osd/osd_operations/replicated_request.cc | 38 ++++++------------- .../osd/osd_operations/replicated_request.h | 21 +++++++--- 3 files changed, 27 insertions(+), 35 deletions(-) diff --git a/src/crimson/osd/osd.cc b/src/crimson/osd/osd.cc index 2bd2fe8408cb3..34c894dd64fda 100644 --- a/src/crimson/osd/osd.cc +++ b/src/crimson/osd/osd.cc @@ -1235,8 +1235,7 @@ seastar::future<> OSD::handle_rep_op(crimson::net::ConnectionRef conn, Ref m) { m->finish_decode(); - (void) shard_services.start_operation( - *this, + std::ignore = start_pg_operation( std::move(conn), std::move(m)); return seastar::now(); diff --git a/src/crimson/osd/osd_operations/replicated_request.cc b/src/crimson/osd/osd_operations/replicated_request.cc index 3a8c3f9a117b9..d93e4035ed0f5 100644 --- a/src/crimson/osd/osd_operations/replicated_request.cc +++ b/src/crimson/osd/osd_operations/replicated_request.cc @@ -4,7 +4,6 @@ #include "replicated_request.h" #include "common/Formatter.h" -#include "messages/MOSDRepOp.h" #include "crimson/osd/osd.h" #include "crimson/osd/osd_connection_priv.h" @@ -19,11 +18,9 @@ namespace { namespace crimson::osd { -RepRequest::RepRequest(OSD &osd, - crimson::net::ConnectionRef&& conn, +RepRequest::RepRequest(crimson::net::ConnectionRef&& conn, Ref &&req) - : osd{osd}, - conn{std::move(conn)}, + : conn{std::move(conn)}, req{req} {} @@ -47,7 +44,7 @@ void RepRequest::dump_detail(Formatter *f) const f->close_section(); } -ConnectionPipeline &RepRequest::cp() +ConnectionPipeline &RepRequest::get_connection_pipeline() { return get_osd_priv(conn.get()).replicated_request_conn_pipeline; } @@ -57,28 +54,15 @@ RepRequest::PGPipeline &RepRequest::pp(PG &pg) return pg.replicated_request_pg_pipeline; } -seastar::future<> RepRequest::start() +seastar::future<> RepRequest::with_pg( + ShardServices &shard_services, Ref pg) { - logger().debug("{} start", *this); - IRef ref = this; + logger().debug("{}: RepRequest::with_pg", *this); - return enter_stage<>(cp().await_map).then([this] { - return with_blocking_event( - [this] (auto&& trigger) { - return osd.osdmap_gate.wait_for_map(std::move(trigger), - req->get_min_epoch()); - }); - }).then([this](epoch_t epoch) { - return enter_stage<>(cp().get_pg); - }).then([this] { - return with_blocking_event( - [this] (auto&& trigger) { - return osd.wait_for_pg(std::move(trigger), req->get_spg()); - }); - }).then([this, ref=std::move(ref)](Ref pg) { - return interruptor::with_interruption([this, ref, pg] { - return pg->handle_rep_op(std::move(req)); - }, [](std::exception_ptr) { return seastar::now(); }, pg); - }); + IRef ref = this; + return interruptor::with_interruption([this, pg] { + return pg->handle_rep_op(std::move(req)); + }, [ref](std::exception_ptr) { return seastar::now(); }, pg); } + } diff --git a/src/crimson/osd/osd_operations/replicated_request.h b/src/crimson/osd/osd_operations/replicated_request.h index 39c6d6a247375..f84b107721ac5 100644 --- a/src/crimson/osd/osd_operations/replicated_request.h +++ b/src/crimson/osd/osd_operations/replicated_request.h @@ -8,8 +8,7 @@ #include "crimson/osd/osd_operation.h" #include "crimson/osd/pg_map.h" #include "crimson/common/type_helpers.h" - -class MOSDRepOp; +#include "messages/MOSDRepOp.h" namespace ceph { class Formatter; @@ -17,6 +16,8 @@ namespace ceph { namespace crimson::osd { +class ShardServices; + class OSD; class PG; @@ -32,11 +33,21 @@ public: friend RepRequest; }; static constexpr OperationTypeCode type = OperationTypeCode::replicated_request; - RepRequest(OSD&, crimson::net::ConnectionRef&&, Ref&&); + RepRequest(crimson::net::ConnectionRef&&, Ref&&); void print(std::ostream &) const final; void dump_detail(ceph::Formatter* f) const final; - seastar::future<> start(); + + static constexpr bool can_create() { return false; } + spg_t get_pgid() const { + return req->get_spg(); + } + ConnectionPipeline &get_connection_pipeline(); + PipelineHandle &get_handle() { return handle; } + epoch_t get_epoch() const { return req->get_min_epoch(); } + + seastar::future<> with_pg( + ShardServices &shard_services, Ref pg); std::tuple< ConnectionPipeline::AwaitActive::BlockingEvent, @@ -47,10 +58,8 @@ public: > tracking_events; private: - ConnectionPipeline &cp(); PGPipeline &pp(PG &pg); - OSD &osd; crimson::net::ConnectionRef conn; Ref req; }; -- 2.39.5