Skip to content

Commit

Permalink
crimson/osd/client_request: Move writer SnapContext initialization
Browse files Browse the repository at this point in the history
Move the initialization from PG::do_osd_ops() to ClientRequest::do_process()
in order to allow for ORDERSNAP error checking before do_osd_ops. (See next commit)

Signed-off-by: Matan Breizman <[email protected]>
  • Loading branch information
Matan-B committed Mar 15, 2023
1 parent 9c52fbd commit b5ef106
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 20 deletions.
28 changes: 27 additions & 1 deletion src/crimson/osd/osd_operations/client_request.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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<interruptor>(pp(*pg).wait_repop, *this);
Expand Down Expand Up @@ -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>& 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;
}

}
4 changes: 4 additions & 0 deletions src/crimson/osd/osd_operations/client_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ class ClientRequest final : public PhasedOperationT<ClientRequest>,

bool is_misdirected(const PG& pg) const;

const SnapContext get_snapc(
Ref<PG>& pg,
crimson::osd::ObjectContextRef obc) const;

public:

friend class LttngBackend;
Expand Down
20 changes: 2 additions & 18 deletions src/crimson/osd/pg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -952,28 +952,12 @@ PG::do_osd_ops_iertr::future<PG::pg_rep_op_fut_t<MURef<MOSDOpReply>>>
PG::do_osd_ops(
Ref<MOSDOp> 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<MURef<MOSDOpReply>>(
seastar::make_lw_shared<OpsExecuter>(
Ref<PG>{this}, obc, op_info, *m, snapc),
Expand Down
3 changes: 2 additions & 1 deletion src/crimson/osd/pg.h
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,8 @@ class PG : public boost::intrusive_ref_counter<
do_osd_ops_iertr::future<pg_rep_op_fut_t<MURef<MOSDOpReply>>> do_osd_ops(
Ref<MOSDOp> m,
ObjectContextRef obc,
const OpInfo &op_info);
const OpInfo &op_info,
const SnapContext& snapc);
using do_osd_ops_success_func_t =
std::function<do_osd_ops_iertr::future<>()>;
using do_osd_ops_failure_func_t =
Expand Down

0 comments on commit b5ef106

Please sign in to comment.