From: Radoslaw Zarzynski Date: Thu, 18 Mar 2021 13:17:35 +0000 (+0000) Subject: crimson/osd: erase the message type in OpsExecuter. X-Git-Tag: v17.1.0~1984^2~18 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bca91e658c1ebb4f6cf6dbe220d2b2925a9d0570;p=ceph.git crimson/osd: erase the message type in OpsExecuter. THe reason is unification of infrastructure between external client requests (everything represented by the `ClientRequest`) and internal requests. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/crimson/osd/ops_executer.cc b/src/crimson/osd/ops_executer.cc index db3078e1aac5..9ad50d3668c7 100644 --- a/src/crimson/osd/ops_executer.cc +++ b/src/crimson/osd/ops_executer.cc @@ -137,7 +137,7 @@ OpsExecuter::call_ierrorator::future<> OpsExecuter::do_op_call(OSDOp& osd_op) } static watch_info_t create_watch_info(const OSDOp& osd_op, - const MOSDOp& msg) + const OpsExecuter::ExecutableMessage& msg) { using crimson::common::local_conf; const uint32_t timeout = @@ -161,7 +161,7 @@ OpsExecuter::watch_ierrorator::future<> OpsExecuter::do_op_watch_subop_watch( crimson::net::ConnectionRef conn; watch_info_t info; - connect_ctx_t(const OSDOp& osd_op, const MOSDOp& msg) + connect_ctx_t(const OSDOp& osd_op, const ExecutableMessage& msg) : key(osd_op.op.watch.cookie, msg.get_reqid().name), conn(msg.get_connection()), info(create_watch_info(osd_op, msg)) { @@ -219,7 +219,7 @@ OpsExecuter::watch_ierrorator::future<> OpsExecuter::do_op_watch_subop_unwatch( ObjectContext::watch_key_t key; bool send_disconnect{ false }; - disconnect_ctx_t(const OSDOp& osd_op, const MOSDOp& msg) + disconnect_ctx_t(const OSDOp& osd_op, const ExecutableMessage& msg) : key(osd_op.op.watch.cookie, msg.get_reqid().name) { } }; @@ -320,7 +320,7 @@ OpsExecuter::watch_ierrorator::future<> OpsExecuter::do_op_notify( const uint64_t client_gid; const epoch_t epoch; - notify_ctx_t(const MOSDOp& msg) + notify_ctx_t(const ExecutableMessage& msg) : conn(msg.get_connection()), client_gid(msg.get_reqid().name.num()), epoch(msg.get_map_epoch()) { @@ -376,7 +376,8 @@ OpsExecuter::watch_ierrorator::future<> OpsExecuter::do_op_notify_ack( uint64_t notify_id; ceph::bufferlist reply_bl; - notifyack_ctx_t(const MOSDOp& msg) : entity(msg.get_reqid().name) { + notifyack_ctx_t(const ExecutableMessage& msg) + : entity(msg.get_reqid().name) { } }; return with_effect_on_obc(notifyack_ctx_t{ get_message() }, diff --git a/src/crimson/osd/ops_executer.h b/src/crimson/osd/ops_executer.h index a007bfd0f43d..ced84b9e8e09 100644 --- a/src/crimson/osd/ops_executer.h +++ b/src/crimson/osd/ops_executer.h @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -13,6 +14,7 @@ #include #include "common/dout.h" +#include "common/static_ptr.h" #include "messages/MOSDOp.h" #include "os/Transaction.h" #include "osd/osd_types.h" @@ -79,6 +81,40 @@ class OpsExecuter { IOInterruptCondition, T>; public: + // ExecutableMessage -- an interface class to allow using OpsExecuter + // with other message types than just the `MOSDOp`. The type erasure + // happens in the ctor of `OpsExecuter`. + struct ExecutableMessage { + virtual crimson::net::ConnectionRef get_connection() const = 0; + virtual osd_reqid_t get_reqid() const = 0; + virtual epoch_t get_map_epoch() const = 0; + virtual entity_inst_t get_orig_source_inst() const = 0; + virtual uint64_t get_features() const = 0; + }; + + template + class ExecutableMessagePimpl final : ExecutableMessage { + const ImplT* pimpl; + public: + ExecutableMessagePimpl(const ImplT* pimpl) : pimpl(pimpl) { + } + crimson::net::ConnectionRef get_connection() const final { + return pimpl->get_connection(); + } + osd_reqid_t get_reqid() const final { + return pimpl->get_reqid(); + } + epoch_t get_map_epoch() const final { + return pimpl->get_map_epoch(); + } + entity_inst_t get_orig_source_inst() const final { + return pimpl->get_orig_source_inst(); + } + uint64_t get_features() const final { + return pimpl->get_features(); + } + }; + // because OpsExecuter is pretty heavy-weight object we want to ensure // it's not copied nor even moved by accident. Performance is the sole // reason for prohibiting that. @@ -114,7 +150,8 @@ private: const OpInfo& op_info; const pg_pool_t& pool_info; // for the sake of the ObjClass API PGBackend& backend; - const MOSDOp& msg; + ceph::static_ptr)> msg; std::optional osd_op_params; bool user_modify = false; ceph::os::Transaction txn; @@ -189,16 +226,17 @@ private: } public: + template OpsExecuter(ObjectContextRef obc, const OpInfo& op_info, const pg_pool_t& pool_info, PGBackend& backend, - const MOSDOp& msg) + const MsgT& msg) : obc(std::move(obc)), op_info(op_info), pool_info(pool_info), backend(backend), - msg(msg) { + msg(std::in_place_type_t>{}, &msg) { } interruptible_errorated_future @@ -214,7 +252,7 @@ public: } const auto& get_message() const { - return msg; + return *msg; } size_t get_processed_rw_ops_num() const {