From: Radoslaw Zarzynski Date: Fri, 7 Aug 2020 16:50:24 +0000 (+0200) Subject: crimson/osd: simplify PgOpsExecuter and impove const-correctness. X-Git-Tag: v16.1.0~1483^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=63b36dd8432fff76534fa0d6493ac35ffa403b9e;p=ceph.git crimson/osd: simplify PgOpsExecuter and impove const-correctness. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/crimson/osd/ops_executer.cc b/src/crimson/osd/ops_executer.cc index ce75fd25c80c..055dee60625f 100644 --- a/src/crimson/osd/ops_executer.cc +++ b/src/crimson/osd/ops_executer.cc @@ -107,8 +107,8 @@ OpsExecuter::call_errorator::future<> OpsExecuter::do_op_call(OSDOp& osd_op) // ceph-osd has this implemented in `PrimaryLogPG::execute_ctx`, // grep for `ignore_out_data`. using crimson::common::local_conf; - if (op_info->allows_returnvec() && - op_info->may_write() && + if (op_info.allows_returnvec() && + op_info.may_write() && ret >= 0 && outdata.length() > local_conf()->osd_max_write_op_reply_len) { // the justification of this limit it to not inflate the pg log. @@ -121,7 +121,7 @@ OpsExecuter::call_errorator::future<> OpsExecuter::do_op_call(OSDOp& osd_op) } // for write calls we never return data expect errors or RETURNVEC. // please refer cls/cls_hello.cc to details. - if (!op_info->may_write() || op_info->allows_returnvec() || ret < 0) { + if (!op_info.may_write() || op_info.allows_returnvec() || ret < 0) { osd_op.op.extent.length = outdata.length(); osd_op.outdata.claim_append(outdata); } @@ -952,21 +952,13 @@ PgOpsExecuter::execute_pg_op(OSDOp& osd_op) logger().warn("handling op {}", ceph_osd_op_name(osd_op.op.op)); switch (const ceph_osd_op& op = osd_op.op; op.op) { case CEPH_OSD_OP_PGLS: - return do_pg_op([&osd_op] (const auto& pg, const auto& nspace) { - return do_pgls(pg, nspace, osd_op); - }); + return do_pgls(pg, nspace, osd_op); case CEPH_OSD_OP_PGLS_FILTER: - return do_pg_op([&osd_op] (const auto& pg, const auto& nspace) { - return do_pgls_filtered(pg, nspace, osd_op); - }); + return do_pgls_filtered(pg, nspace, osd_op); case CEPH_OSD_OP_PGNLS: - return do_pg_op([&osd_op] (const auto& pg, const auto& nspace) { - return do_pgnls(pg, nspace, osd_op); - }); + return do_pgnls(pg, nspace, osd_op); case CEPH_OSD_OP_PGNLS_FILTER: - return do_pg_op([&osd_op] (const auto& pg, const auto& nspace) { - return do_pgnls_filtered(pg, nspace, osd_op); - }); + return do_pgnls_filtered(pg, nspace, osd_op); default: logger().warn("unknown op {}", ceph_osd_op_name(op.op)); throw std::runtime_error( diff --git a/src/crimson/osd/ops_executer.h b/src/crimson/osd/ops_executer.h index 1dbf5e046395..35cd007903f6 100644 --- a/src/crimson/osd/ops_executer.h +++ b/src/crimson/osd/ops_executer.h @@ -84,7 +84,7 @@ private: }; ObjectContextRef obc; - const OpInfo* op_info; + const OpInfo& op_info; PG& pg; PGBackend& backend; Ref msg; @@ -166,7 +166,7 @@ private: } public: - OpsExecuter(ObjectContextRef obc, const OpInfo* op_info, PG& pg, Ref msg) + OpsExecuter(ObjectContextRef obc, const OpInfo& op_info, PG& pg, Ref msg) : obc(std::move(obc)), op_info(op_info), pg(pg), @@ -269,22 +269,15 @@ OpsExecuter::osd_op_errorator::future<> OpsExecuter::flush_changes( // PgOpsExecuter -- a class for executing ops targeting a certain PG. class PgOpsExecuter { public: - PgOpsExecuter(PG& pg, Ref msg) - : pg(pg), msg(std::move(msg)) { + PgOpsExecuter(const PG& pg, const MOSDOp& msg) + : pg(pg), nspace(msg.get_hobj().nspace) { } seastar::future<> execute_pg_op(class OSDOp& osd_op); private: - // PG operations are being provided with pg instead of os. - template - auto do_pg_op(Func&& f) { - return std::forward(f)(std::as_const(pg), - std::as_const(msg->get_hobj().nspace)); - } - - PG& pg; - Ref msg; + const PG& pg; + const std::string& nspace; }; } // namespace crimson::osd diff --git a/src/crimson/osd/pg.cc b/src/crimson/osd/pg.cc index 783dcbf4672e..3e93ac42e4d5 100644 --- a/src/crimson/osd/pg.cc +++ b/src/crimson/osd/pg.cc @@ -591,7 +591,7 @@ seastar::future> PG::do_osd_ops( const auto oid = m->get_snapid() == CEPH_SNAPDIR ? m->get_hobj().get_head() : m->get_hobj(); auto ox = - std::make_unique(obc, &op_info, *this/* as const& */, m); + std::make_unique(obc, op_info, *this/* as const& */, m); return crimson::do_for_each( m->ops, [obc, m, ox = ox.get()](OSDOp& osd_op) { @@ -676,7 +676,8 @@ seastar::future> PG::do_pg_ops(Ref m) throw crimson::common::system_shutdown_exception(); } - auto ox = std::make_unique(*this/* as const& */, m); + auto ox = std::make_unique(std::as_const(*this), + std::as_const(*m)); return seastar::do_for_each(m->ops, [ox = ox.get()](OSDOp& osd_op) { logger().debug("will be handling pg op {}", ceph_osd_op_name(osd_op.op.op)); return ox->execute_pg_op(osd_op);