]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: simplify PgOpsExecuter and impove const-correctness.
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Fri, 7 Aug 2020 16:50:24 +0000 (18:50 +0200)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Sun, 9 Aug 2020 22:49:22 +0000 (00:49 +0200)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/crimson/osd/ops_executer.cc
src/crimson/osd/ops_executer.h
src/crimson/osd/pg.cc

index ce75fd25c80c94bed9e67a68ac93eed77fbb024d..055dee60625fd31ec927ca6c2da02cde856554aa 100644 (file)
@@ -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(
index 1dbf5e04639547c72f5ffdb97957761ec6e74a1f..35cd007903f65708825893d6f212dec35b896524 100644 (file)
@@ -84,7 +84,7 @@ private:
   };
 
   ObjectContextRef obc;
-  const OpInfo* op_info;
+  const OpInfo& op_info;
   PG& pg;
   PGBackend& backend;
   Ref<MOSDOp> msg;
@@ -166,7 +166,7 @@ private:
   }
 
 public:
-  OpsExecuter(ObjectContextRef obc, const OpInfo* op_info, PG& pg, Ref<MOSDOp> msg)
+  OpsExecuter(ObjectContextRef obc, const OpInfo& op_info, PG& pg, Ref<MOSDOp> 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<MOSDOp> 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 <class Func>
-  auto do_pg_op(Func&& f) {
-    return std::forward<Func>(f)(std::as_const(pg),
-                                 std::as_const(msg->get_hobj().nspace));
-  }
-
-  PG& pg;
-  Ref<MOSDOp> msg;
+  const PG& pg;
+  const std::string& nspace;
 };
 
 } // namespace crimson::osd
index 783dcbf4672e058f67babc21061a63c02763044b..3e93ac42e4d5b7820b41e9ace408c44e0f1e3518 100644 (file)
@@ -591,7 +591,7 @@ seastar::future<Ref<MOSDOpReply>> 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<OpsExecuter>(obc, &op_info, *this/* as const& */, m);
+    std::make_unique<OpsExecuter>(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<Ref<MOSDOpReply>> PG::do_pg_ops(Ref<MOSDOp> m)
     throw crimson::common::system_shutdown_exception();
   }
 
-  auto ox = std::make_unique<PgOpsExecuter>(*this/* as const& */, m);
+  auto ox = std::make_unique<PgOpsExecuter>(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);