Skip to content

Commit d4ce540

Browse files
athanatosMatan-B
authored andcommitted
crimson: add operation wrapper for MOSDRepOpReply
This should avoid reordering between cores. Fixes: https://tracker.ceph.com/issues/69439 Signed-off-by: Samuel Just <[email protected]> (cherry picked from commit 0c15eb5)
1 parent df9a84d commit d4ce540

File tree

5 files changed

+106
-13
lines changed

5 files changed

+106
-13
lines changed

src/crimson/osd/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ add_executable(crimson-osd
2323
osd_operations/peering_event.cc
2424
osd_operations/pg_advance_map.cc
2525
osd_operations/replicated_request.cc
26+
osd_operations/replicated_request_reply.cc
2627
osd_operations/logmissing_request.cc
2728
osd_operations/logmissing_request_reply.cc
2829
osd_operations/background_recovery.cc

src/crimson/osd/osd.cc

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
#include "crimson/osd/osd_operations/pg_advance_map.h"
5959
#include "crimson/osd/osd_operations/recovery_subrequest.h"
6060
#include "crimson/osd/osd_operations/replicated_request.h"
61+
#include "crimson/osd/osd_operations/replicated_request_reply.h"
6162
#include "crimson/osd/osd_operations/scrub_events.h"
6263
#include "crimson/osd/osd_operation_external_tracking.h"
6364
#include "crimson/crush/CrushLocation.h"
@@ -1437,19 +1438,9 @@ seastar::future<> OSD::handle_rep_op_reply(
14371438
crimson::net::ConnectionRef conn,
14381439
Ref<MOSDRepOpReply> m)
14391440
{
1440-
LOG_PREFIX(OSD::handle_rep_op_reply);
1441-
spg_t pgid = m->get_spg();
1442-
return pg_shard_manager.with_pg(
1443-
pgid,
1444-
[FNAME, m=std::move(m)](auto &&pg) {
1445-
if (pg) {
1446-
m->finish_decode();
1447-
pg->handle_rep_op_reply(*m);
1448-
} else {
1449-
DEBUG("stale reply: {}", *m);
1450-
}
1451-
return seastar::now();
1452-
});
1441+
return pg_shard_manager.start_pg_operation_active<ReplicatedRequestReply>(
1442+
std::move(conn),
1443+
std::move(m));
14531444
}
14541445

14551446
seastar::future<> OSD::handle_scrub_command(

src/crimson/osd/osd_operation.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ enum class OperationTypeCode {
9090
pg_advance_map,
9191
pg_creation,
9292
replicated_request,
93+
replicated_request_reply,
9394
background_recovery,
9495
background_recovery_sub,
9596
internal_client_request,
@@ -114,6 +115,7 @@ static constexpr const char* const OP_NAMES[] = {
114115
"pg_advance_map",
115116
"pg_creation",
116117
"replicated_request",
118+
"replicated_request_reply",
117119
"background_recovery",
118120
"background_recovery_sub",
119121
"internal_client_request",
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2+
// vim: ts=8 sw=2 smarttab
3+
4+
#include "replicated_request_reply.h"
5+
6+
#include "common/Formatter.h"
7+
8+
#include "crimson/osd/pg.h"
9+
#include "crimson/osd/replicated_backend.h"
10+
11+
SET_SUBSYS(osd);
12+
13+
namespace crimson::osd {
14+
15+
ReplicatedRequestReply::ReplicatedRequestReply(
16+
crimson::net::ConnectionRef&& conn,
17+
Ref<MOSDRepOpReply> &&req)
18+
: RemoteOperation{std::move(conn)},
19+
req{std::move(req)}
20+
{}
21+
22+
void ReplicatedRequestReply::print(std::ostream& os) const
23+
{
24+
os << "ReplicatedRequestReply("
25+
<< " req=" << *req
26+
<< ")";
27+
}
28+
29+
void ReplicatedRequestReply::dump_detail(Formatter *f) const
30+
{
31+
f->open_object_section("ReplicatedRequestReply");
32+
f->dump_stream("pgid") << req->get_spg();
33+
f->dump_unsigned("map_epoch", req->get_map_epoch());
34+
f->dump_unsigned("min_epoch", req->get_min_epoch());
35+
f->close_section();
36+
}
37+
38+
seastar::future<> ReplicatedRequestReply::with_pg(
39+
ShardServices &shard_services, Ref<PG> pgref)
40+
{
41+
LOG_PREFIX(ReplicatedRequestReply::with_pg);
42+
DEBUGDPP("{}", *pgref, *this);
43+
req->finish_decode();
44+
pgref->handle_rep_op_reply(*req);
45+
return seastar::now();
46+
}
47+
48+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2+
// vim: ts=8 sw=2 smarttab
3+
4+
#pragma once
5+
6+
#include "crimson/net/Connection.h"
7+
#include "crimson/osd/osd_operation.h"
8+
#include "crimson/common/type_helpers.h"
9+
#include "messages/MOSDRepOpReply.h"
10+
11+
namespace ceph {
12+
class Formatter;
13+
}
14+
15+
namespace crimson::osd {
16+
17+
class ShardServices;
18+
19+
class OSD;
20+
class PG;
21+
22+
class ReplicatedRequestReply final
23+
: public OperationT<ReplicatedRequestReply>,
24+
public RemoteOperation
25+
{
26+
public:
27+
static constexpr OperationTypeCode type =
28+
OperationTypeCode::replicated_request_reply;
29+
ReplicatedRequestReply(crimson::net::ConnectionRef&&, Ref<MOSDRepOpReply>&&);
30+
31+
void print(std::ostream &) const final;
32+
void dump_detail(ceph::Formatter* f) const final;
33+
34+
spg_t get_pgid() const {
35+
return req->get_spg();
36+
}
37+
38+
seastar::future<> with_pg(
39+
ShardServices &shard_services, Ref<PG> pg);
40+
41+
PipelineHandle &get_handle() { return handle; }
42+
private:
43+
PipelineHandle handle;
44+
Ref<MOSDRepOpReply> req;
45+
};
46+
47+
}
48+
49+
#if FMT_VERSION >= 90000
50+
template <> struct fmt::formatter<crimson::osd::ReplicatedRequestReply> : fmt::ostream_formatter {};
51+
#endif

0 commit comments

Comments
 (0)