Skip to content

Commit df9a84d

Browse files
athanatosMatan-B
authored andcommitted
crimson: convert cross-core operations to use RemoteOperation
Signed-off-by: Samuel Just <[email protected]> (cherry picked from commit b031373)
1 parent 064df68 commit df9a84d

15 files changed

+42
-272
lines changed

src/crimson/osd/osd_operations/client_request.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ void ClientRequest::complete_request(PG &pg)
6060
ClientRequest::ClientRequest(
6161
ShardServices &_shard_services, crimson::net::ConnectionRef conn,
6262
Ref<MOSDOp> &&m)
63-
: shard_services(&_shard_services),
64-
l_conn(std::move(conn)),
63+
: RemoteOperation(std::move(conn)),
64+
shard_services(&_shard_services),
6565
m(std::move(m)),
6666
begin_time(std::chrono::steady_clock::now()),
6767
instance_handle(new instance_handle_t)
@@ -486,7 +486,7 @@ ClientRequest::do_process(
486486
co_return;
487487
}
488488

489-
OpsExecuter ox(pg, obc, op_info, *m, r_conn, snapc);
489+
OpsExecuter ox(pg, obc, op_info, *m, get_remote_connection(), snapc);
490490
auto ret = co_await pg->run_executer(
491491
ox, obc, op_info, m->ops
492492
).si_then([]() -> std::optional<std::error_code> {

src/crimson/osd/osd_operations/client_request.h

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ class PG;
2727
class OSD;
2828
class ShardServices;
2929

30-
class ClientRequest final : public PhasedOperationT<ClientRequest> {
30+
class ClientRequest final
31+
: public PhasedOperationT<ClientRequest>,
32+
public RemoteOperation
33+
{
3134
// Initially set to primary core, updated to pg core after with_pg()
3235
ShardServices *shard_services = nullptr;
3336

34-
crimson::net::ConnectionRef l_conn;
35-
crimson::net::ConnectionXcoreRef r_conn;
36-
3737
// must be after conn due to ConnectionPipeline's life-time
3838
Ref<MOSDOp> m;
3939
OpInfo op_info;
@@ -54,14 +54,6 @@ class ClientRequest final : public PhasedOperationT<ClientRequest> {
5454
static_assert(std::is_same_v<T, MOSDOp>);
5555
return m.get();
5656
}
57-
const crimson::net::Connection &get_connection() const {
58-
if (l_conn) {
59-
return *l_conn;
60-
} else {
61-
assert(r_conn);
62-
return *r_conn;
63-
}
64-
}
6557

6658
/**
6759
* instance_handle_t
@@ -236,33 +228,6 @@ class ClientRequest final : public PhasedOperationT<ClientRequest> {
236228

237229
PerShardPipeline &get_pershard_pipeline(ShardServices &);
238230

239-
crimson::net::Connection &get_local_connection() {
240-
assert(l_conn);
241-
assert(!r_conn);
242-
return *l_conn;
243-
};
244-
245-
crimson::net::Connection &get_foreign_connection() {
246-
assert(r_conn);
247-
assert(!l_conn);
248-
return *r_conn;
249-
};
250-
251-
crimson::net::ConnectionFFRef prepare_remote_submission() {
252-
assert(l_conn);
253-
assert(!r_conn);
254-
auto ret = seastar::make_foreign(std::move(l_conn));
255-
l_conn.reset();
256-
return ret;
257-
}
258-
259-
void finish_remote_submission(crimson::net::ConnectionFFRef conn) {
260-
assert(conn);
261-
assert(!l_conn);
262-
assert(!r_conn);
263-
r_conn = make_local_shared_foreign(std::move(conn));
264-
}
265-
266231
interruptible_future<> with_pg_process_interruptible(
267232
Ref<PG> pgref, const unsigned instance_id, instance_handle_t &ihref);
268233

src/crimson/osd/osd_operations/logmissing_request.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace crimson::osd {
2222

2323
LogMissingRequest::LogMissingRequest(crimson::net::ConnectionRef&& conn,
2424
Ref<MOSDPGUpdateLogMissing> &&req)
25-
: l_conn{std::move(conn)},
25+
: RemoteOperation{std::move(conn)},
2626
req{std::move(req)}
2727
{}
2828

@@ -82,7 +82,7 @@ seastar::future<> LogMissingRequest::with_pg(
8282
std::move(trigger), req->min_epoch);
8383
});
8484
}).then_interruptible([this, pg](auto) {
85-
return pg->do_update_log_missing(req, r_conn);
85+
return pg->do_update_log_missing(req, get_remote_connection());
8686
}).then_interruptible([this] {
8787
logger().debug("{}: complete", *this);
8888
return handle.complete();

src/crimson/osd/osd_operations/logmissing_request.h

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ class ShardServices;
2222
class OSD;
2323
class PG;
2424

25-
class LogMissingRequest final : public PhasedOperationT<LogMissingRequest> {
25+
class LogMissingRequest final :
26+
public PhasedOperationT<LogMissingRequest>,
27+
public RemoteOperation {
2628
public:
2729
static constexpr OperationTypeCode type = OperationTypeCode::logmissing_request;
2830
LogMissingRequest(crimson::net::ConnectionRef&&, Ref<MOSDPGUpdateLogMissing>&&);
@@ -44,33 +46,6 @@ class LogMissingRequest final : public PhasedOperationT<LogMissingRequest> {
4446

4547
PerShardPipeline &get_pershard_pipeline(ShardServices &);
4648

47-
crimson::net::Connection &get_local_connection() {
48-
assert(l_conn);
49-
assert(!r_conn);
50-
return *l_conn;
51-
};
52-
53-
crimson::net::Connection &get_foreign_connection() {
54-
assert(r_conn);
55-
assert(!l_conn);
56-
return *r_conn;
57-
};
58-
59-
crimson::net::ConnectionFFRef prepare_remote_submission() {
60-
assert(l_conn);
61-
assert(!r_conn);
62-
auto ret = seastar::make_foreign(std::move(l_conn));
63-
l_conn.reset();
64-
return ret;
65-
}
66-
67-
void finish_remote_submission(crimson::net::ConnectionFFRef conn) {
68-
assert(conn);
69-
assert(!l_conn);
70-
assert(!r_conn);
71-
r_conn = make_local_shared_foreign(std::move(conn));
72-
}
73-
7449
seastar::future<> with_pg(
7550
ShardServices &shard_services, Ref<PG> pg);
7651

@@ -89,9 +64,6 @@ class LogMissingRequest final : public PhasedOperationT<LogMissingRequest> {
8964
private:
9065
PGRepopPipeline &repop_pipeline(PG &pg);
9166

92-
crimson::net::ConnectionRef l_conn;
93-
crimson::net::ConnectionXcoreRef r_conn;
94-
9567
// must be after `conn` to ensure the ConnectionPipeline's is alive
9668
PipelineHandle handle;
9769
Ref<MOSDPGUpdateLogMissing> req;

src/crimson/osd/osd_operations/logmissing_request_reply.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace crimson::osd {
2121
LogMissingRequestReply::LogMissingRequestReply(
2222
crimson::net::ConnectionRef&& conn,
2323
Ref<MOSDPGUpdateLogMissingReply> &&req)
24-
: l_conn{std::move(conn)},
24+
: RemoteOperation{std::move(conn)},
2525
req{std::move(req)}
2626
{}
2727

src/crimson/osd/osd_operations/logmissing_request_reply.h

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ class ShardServices;
2222
class OSD;
2323
class PG;
2424

25-
class LogMissingRequestReply final : public PhasedOperationT<LogMissingRequestReply> {
25+
class LogMissingRequestReply final :
26+
public PhasedOperationT<LogMissingRequestReply>,
27+
public RemoteOperation {
2628
public:
2729
static constexpr OperationTypeCode type = OperationTypeCode::logmissing_request_reply;
2830
LogMissingRequestReply(crimson::net::ConnectionRef&&, Ref<MOSDPGUpdateLogMissingReply>&&);
@@ -44,33 +46,6 @@ class LogMissingRequestReply final : public PhasedOperationT<LogMissingRequestRe
4446

4547
PerShardPipeline &get_pershard_pipeline(ShardServices &);
4648

47-
crimson::net::Connection &get_local_connection() {
48-
assert(l_conn);
49-
assert(!r_conn);
50-
return *l_conn;
51-
};
52-
53-
crimson::net::Connection &get_foreign_connection() {
54-
assert(r_conn);
55-
assert(!l_conn);
56-
return *r_conn;
57-
};
58-
59-
crimson::net::ConnectionFFRef prepare_remote_submission() {
60-
assert(l_conn);
61-
assert(!r_conn);
62-
auto ret = seastar::make_foreign(std::move(l_conn));
63-
l_conn.reset();
64-
return ret;
65-
}
66-
67-
void finish_remote_submission(crimson::net::ConnectionFFRef conn) {
68-
assert(conn);
69-
assert(!l_conn);
70-
assert(!r_conn);
71-
r_conn = make_local_shared_foreign(std::move(conn));
72-
}
73-
7449
seastar::future<> with_pg(
7550
ShardServices &shard_services, Ref<PG> pg);
7651

@@ -85,9 +60,6 @@ class LogMissingRequestReply final : public PhasedOperationT<LogMissingRequestRe
8560
> tracking_events;
8661

8762
private:
88-
crimson::net::ConnectionRef l_conn;
89-
crimson::net::ConnectionXcoreRef r_conn;
90-
9163
// must be after `conn` to ensure the ConnectionPipeline's is alive
9264
PipelineHandle handle;
9365
Ref<MOSDPGUpdateLogMissingReply> req;

src/crimson/osd/osd_operations/peering_event.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ PeeringEvent<T>::complete_rctx(ShardServices &shard_services, Ref<PG> pg)
138138

139139
ConnectionPipeline &RemotePeeringEvent::get_connection_pipeline()
140140
{
141-
return get_osd_priv(&get_local_connection()
142-
).peering_request_conn_pipeline;
141+
return get_osd_priv(&get_connection()
142+
).peering_request_conn_pipeline;
143143
}
144144

145145
PerShardPipeline &RemotePeeringEvent::get_pershard_pipeline(

src/crimson/osd/osd_operations/peering_event.h

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,10 @@ class PeeringEvent : public PhasedOperationT<T> {
9797
ShardServices &shard_services, Ref<PG> pg);
9898
};
9999

100-
class RemotePeeringEvent : public PeeringEvent<RemotePeeringEvent> {
100+
class RemotePeeringEvent :
101+
public PeeringEvent<RemotePeeringEvent>,
102+
public RemoteOperation {
101103
protected:
102-
crimson::net::ConnectionRef l_conn;
103-
crimson::net::ConnectionXcoreRef r_conn;
104-
105104
// must be after conn due to ConnectionPipeline's life-time
106105
PipelineHandle handle;
107106

@@ -117,7 +116,7 @@ class RemotePeeringEvent : public PeeringEvent<RemotePeeringEvent> {
117116
template <typename... Args>
118117
RemotePeeringEvent(crimson::net::ConnectionRef conn, Args&&... args) :
119118
PeeringEvent(std::forward<Args>(args)...),
120-
l_conn(conn)
119+
RemoteOperation(std::move(conn))
121120
{}
122121

123122
std::tuple<
@@ -145,33 +144,6 @@ class RemotePeeringEvent : public PeeringEvent<RemotePeeringEvent> {
145144
ConnectionPipeline &get_connection_pipeline();
146145

147146
PerShardPipeline &get_pershard_pipeline(ShardServices &);
148-
149-
crimson::net::Connection &get_local_connection() {
150-
assert(l_conn);
151-
assert(!r_conn);
152-
return *l_conn;
153-
};
154-
155-
crimson::net::Connection &get_foreign_connection() {
156-
assert(r_conn);
157-
assert(!l_conn);
158-
return *r_conn;
159-
};
160-
161-
crimson::net::ConnectionFFRef prepare_remote_submission() {
162-
assert(l_conn);
163-
assert(!r_conn);
164-
auto ret = seastar::make_foreign(std::move(l_conn));
165-
l_conn.reset();
166-
return ret;
167-
}
168-
169-
void finish_remote_submission(crimson::net::ConnectionFFRef conn) {
170-
assert(conn);
171-
assert(!l_conn);
172-
assert(!r_conn);
173-
r_conn = make_local_shared_foreign(std::move(conn));
174-
}
175147
};
176148

177149
class LocalPeeringEvent final : public PeeringEvent<LocalPeeringEvent> {

src/crimson/osd/osd_operations/pgpct_request.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace crimson::osd {
1717

1818
PGPCTRequest::PGPCTRequest(crimson::net::ConnectionRef&& conn,
1919
Ref<MOSDPGPCT> &&req)
20-
: l_conn{std::move(conn)},
20+
: RemoteOperation{std::move(conn)},
2121
req{std::move(req)}
2222
{}
2323

src/crimson/osd/osd_operations/pgpct_request.h

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ class ShardServices;
2222
class OSD;
2323
class PG;
2424

25-
class PGPCTRequest final : public PhasedOperationT<PGPCTRequest> {
25+
class PGPCTRequest final :
26+
public PhasedOperationT<PGPCTRequest>,
27+
public RemoteOperation {
2628
public:
2729
static constexpr OperationTypeCode type = OperationTypeCode::pgpct_request;
2830
PGPCTRequest(crimson::net::ConnectionRef&&, Ref<MOSDPGPCT>&&);
@@ -42,33 +44,6 @@ class PGPCTRequest final : public PhasedOperationT<PGPCTRequest> {
4244

4345
PerShardPipeline &get_pershard_pipeline(ShardServices &);
4446

45-
crimson::net::Connection &get_local_connection() {
46-
assert(l_conn);
47-
assert(!r_conn);
48-
return *l_conn;
49-
};
50-
51-
crimson::net::Connection &get_foreign_connection() {
52-
assert(r_conn);
53-
assert(!l_conn);
54-
return *r_conn;
55-
};
56-
57-
crimson::net::ConnectionFFRef prepare_remote_submission() {
58-
assert(l_conn);
59-
assert(!r_conn);
60-
auto ret = seastar::make_foreign(std::move(l_conn));
61-
l_conn.reset();
62-
return ret;
63-
}
64-
65-
void finish_remote_submission(crimson::net::ConnectionFFRef conn) {
66-
assert(conn);
67-
assert(!l_conn);
68-
assert(!r_conn);
69-
r_conn = make_local_shared_foreign(std::move(conn));
70-
}
71-
7247
seastar::future<> with_pg(
7348
ShardServices &shard_services, Ref<PG> pg);
7449

@@ -88,9 +63,6 @@ class PGPCTRequest final : public PhasedOperationT<PGPCTRequest> {
8863
> tracking_events;
8964

9065
private:
91-
crimson::net::ConnectionRef l_conn;
92-
crimson::net::ConnectionXcoreRef r_conn;
93-
9466
// must be after `conn` to ensure the ConnectionPipeline is alive
9567
PipelineHandle handle;
9668
Ref<MOSDPGPCT> req;

0 commit comments

Comments
 (0)