]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: RMWPipeline::start_rmw() takes Op as std::unique_ptr<Op> 52211/head
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 27 Jun 2023 11:04:31 +0000 (11:04 +0000)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Fri, 7 Jul 2023 11:26:16 +0000 (11:26 +0000)
The intention behind this refactor is to emphasize that:
  1. callers of `start_rmw()` are supposed to create any
     concrete type of `RMWPipeline::Op`.
  2. `RMWPipeline` operates solely on the abstract `Op`
     and control its life-time.

Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/osd/ECBackend.cc
src/osd/ECBackend.h

index dd2a104a48b011fec98357b31a771e8d85c44ad5..3083f6e698bc8bea76a8f391ee429146d49262a7 100644 (file)
@@ -1605,11 +1605,8 @@ void ECBackend::submit_transaction(
   OpRequestRef client_op
   )
 {
-  ceph_assert(!rmw_pipeline.tid_to_op_map.count(tid));
-  auto concrete_op = std::make_unique<ECClassicalOp>();
-  concrete_op->t = std::move(t);
-  rmw_pipeline.tid_to_op_map[tid] = std::move(concrete_op);
-  RMWPipeline::Op *op = rmw_pipeline.tid_to_op_map[tid].get();
+  auto op = std::make_unique<ECClassicalOp>();
+  op->t = std::move(t);
   op->hoid = hoid;
   op->delta_stats = delta_stats;
   op->version = at_version;
@@ -1626,7 +1623,7 @@ void ECBackend::submit_transaction(
   }
   op->plan = op->get_write_plan(
     sinfo,
-    *(concrete_op->t),
+    *(op->t),
     [&](const hobject_t &i) {
       ECUtil::HashInfoRef ref = get_hash_info(i, true);
       if (!ref) {
@@ -1640,7 +1637,7 @@ void ECBackend::submit_transaction(
     },
     get_parent()->get_dpp());
   dout(10) << __func__ << ": op " << *op << " starting" << dendl;
-  rmw_pipeline.start_rmw(op);
+  rmw_pipeline.start_rmw(std::move(op));
 }
 
 void ECBackend::RMWPipeline::call_write_ordered(std::function<void(void)> &&cb) {
@@ -1967,12 +1964,14 @@ ECUtil::HashInfoRef ECBackend::get_hash_info(
   return ref;
 }
 
-void ECBackend::RMWPipeline::start_rmw(Op *op)
+void ECBackend::RMWPipeline::start_rmw(OpRef op)
 {
   ceph_assert(op);
   dout(10) << __func__ << ": " << *op << dendl;
 
+  ceph_assert(!tid_to_op_map.count(op->tid));
   waiting_state.push_back(*op);
+  tid_to_op_map[op->tid] = std::move(op);
   check_ops();
 }
 
index 9be6b34cc399b7a78ce09e6159b387bfce98ea20..d879f429443572b7db079325972f28c09c112621 100644 (file)
@@ -554,7 +554,7 @@ public:
     op_list waiting_commit;       /// writes waiting on initial commit
     eversion_t completed_to;
     eversion_t committed_to;
-    void start_rmw(Op *op);
+    void start_rmw(OpRef op);
     bool try_state_to_reads();
     bool try_reads_to_commit();
     bool try_finish_rmw();