diff --git a/src/crimson/osd/osd_operations/client_request.cc b/src/crimson/osd/osd_operations/client_request.cc index 2cc2c59d282a0..20fc7beb9e106 100644 --- a/src/crimson/osd/osd_operations/client_request.cc +++ b/src/crimson/osd/osd_operations/client_request.cc @@ -289,6 +289,8 @@ ClientRequest::do_process( return reply_op_error(pg, -ENOENT); } + SnapContext snapc = get_snapc(pg,obc); + if (!pg->is_primary()) { // primary can handle both normal ops and balanced reads if (is_misdirected(*pg)) { @@ -305,7 +307,7 @@ ClientRequest::do_process( __func__, m->get_hobj()); } } - return pg->do_osd_ops(m, obc, op_info).safe_then_unpack_interruptible( + return pg->do_osd_ops(m, obc, op_info, snapc).safe_then_unpack_interruptible( [this, pg, &ihref](auto submitted, auto all_completed) mutable { return submitted.then_interruptible([this, pg, &ihref] { return ihref.enter_stage(pp(*pg).wait_repop, *this); @@ -355,4 +357,28 @@ void ClientRequest::put_historic() const put_historic_shard_services->get_registry().put_historic(*this); } +const SnapContext ClientRequest::get_snapc( + Ref& pg, + crimson::osd::ObjectContextRef obc) const +{ + SnapContext snapc; + if (op_info.may_write() || op_info.may_cache()) { + // snap + if (pg->get_pgpool().info.is_pool_snaps_mode()) { + // use pool's snapc + snapc = pg->get_pgpool().snapc; + logger().debug("{} using pool's snapc snaps={}", + __func__, snapc.snaps); + + } else { + // client specified snapc + snapc.seq = m->get_snap_seq(); + snapc.snaps = m->get_snaps(); + logger().debug("{} client specified snapc seq={} snaps={}", + __func__, snapc.seq, snapc.snaps); + } + } + return snapc; +} + } diff --git a/src/crimson/osd/osd_operations/client_request.h b/src/crimson/osd/osd_operations/client_request.h index a44893b9230e3..a7d68fccf2836 100644 --- a/src/crimson/osd/osd_operations/client_request.h +++ b/src/crimson/osd/osd_operations/client_request.h @@ -242,6 +242,10 @@ class ClientRequest final : public PhasedOperationT, bool is_misdirected(const PG& pg) const; + const SnapContext get_snapc( + Ref& pg, + crimson::osd::ObjectContextRef obc) const; + public: friend class LttngBackend; diff --git a/src/crimson/osd/pg.cc b/src/crimson/osd/pg.cc index 9400f1a260028..82f51d3274532 100644 --- a/src/crimson/osd/pg.cc +++ b/src/crimson/osd/pg.cc @@ -952,28 +952,12 @@ PG::do_osd_ops_iertr::future>> PG::do_osd_ops( Ref m, ObjectContextRef obc, - const OpInfo &op_info) + const OpInfo &op_info, + const SnapContext& snapc) { if (__builtin_expect(stopping, false)) { throw crimson::common::system_shutdown_exception(); } - SnapContext snapc; - if (op_info.may_write() || op_info.may_cache()) { - // snap - if (get_pgpool().info.is_pool_snaps_mode()) { - // use pool's snapc - snapc = get_pgpool().snapc; - logger().debug("{} using pool's snapc snaps={}", - __func__, snapc.snaps); - - } else { - // client specified snapc - snapc.seq = m->get_snap_seq(); - snapc.snaps = m->get_snaps(); - logger().debug("{} client specified snapc seq={} snaps={}", - __func__, snapc.seq, snapc.snaps); - } - } return do_osd_ops_execute>( seastar::make_lw_shared( Ref{this}, obc, op_info, *m, snapc), diff --git a/src/crimson/osd/pg.h b/src/crimson/osd/pg.h index 6d26f58748ffc..5739799153797 100644 --- a/src/crimson/osd/pg.h +++ b/src/crimson/osd/pg.h @@ -565,7 +565,8 @@ class PG : public boost::intrusive_ref_counter< do_osd_ops_iertr::future>> do_osd_ops( Ref m, ObjectContextRef obc, - const OpInfo &op_info); + const OpInfo &op_info, + const SnapContext& snapc); using do_osd_ops_success_func_t = std::function()>; using do_osd_ops_failure_func_t =