From: Radoslaw Zarzynski Date: Tue, 27 Jun 2023 11:04:31 +0000 (+0000) Subject: osd: RMWPipeline::start_rmw() takes Op as std::unique_ptr X-Git-Tag: v19.0.0~527^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=49db2d991dd7b5d55fd0d82560dfdc255a826c3d;p=ceph.git osd: RMWPipeline::start_rmw() takes Op as std::unique_ptr 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 --- diff --git a/src/osd/ECBackend.cc b/src/osd/ECBackend.cc index dd2a104a48b..3083f6e698b 100644 --- a/src/osd/ECBackend.cc +++ b/src/osd/ECBackend.cc @@ -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(); - 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(); + 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 &&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(); } diff --git a/src/osd/ECBackend.h b/src/osd/ECBackend.h index 9be6b34cc39..d879f429443 100644 --- a/src/osd/ECBackend.h +++ b/src/osd/ECBackend.h @@ -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();