Skip to content

Commit 0b8306e

Browse files
athanatosMatan-B
authored andcommitted
crimson/.../osd_operation.h: add RemoteOperation
Subsequent commits will switch various ops to inherit from this thereby removing some boilerplate. Signed-off-by: Samuel Just <[email protected]> (cherry picked from commit 6da6b0f)
1 parent f8fc04a commit 0b8306e

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

src/crimson/osd/osd_operation.h

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#pragma once
55

66
#include "crimson/common/operation.h"
7+
#include "crimson/net/Connection.h"
78
#include "crimson/osd/pg_interval_interrupt_condition.h"
89
#include "crimson/osd/scheduler/scheduler.h"
910
#include "osd/osd_types.h"
@@ -165,6 +166,61 @@ struct OperationT : InterruptibleOperation {
165166
virtual void dump_detail(ceph::Formatter *f) const = 0;
166167
};
167168

169+
class RemoteOperation {
170+
crimson::net::ConnectionRef l_conn;
171+
crimson::net::ConnectionXcoreRef r_conn;
172+
173+
public:
174+
RemoteOperation(crimson::net::ConnectionRef &&conn)
175+
: l_conn(std::move(conn)) {}
176+
177+
crimson::net::Connection &get_local_connection() {
178+
assert(l_conn);
179+
assert(!r_conn);
180+
return *l_conn;
181+
};
182+
183+
crimson::net::Connection &get_foreign_connection() {
184+
assert(r_conn);
185+
assert(!l_conn);
186+
return *r_conn;
187+
};
188+
189+
crimson::net::ConnectionFFRef prepare_remote_submission() {
190+
assert(l_conn);
191+
assert(!r_conn);
192+
auto ret = seastar::make_foreign(std::move(l_conn));
193+
l_conn.reset();
194+
return ret;
195+
}
196+
197+
void finish_remote_submission(crimson::net::ConnectionFFRef conn) {
198+
assert(conn);
199+
assert(!l_conn);
200+
assert(!r_conn);
201+
r_conn = make_local_shared_foreign(std::move(conn));
202+
}
203+
204+
crimson::net::Connection &get_connection() const {
205+
if (l_conn) {
206+
return *l_conn;
207+
} else {
208+
assert(r_conn);
209+
return *r_conn;
210+
}
211+
}
212+
213+
/**
214+
* get_remote_connection
215+
*
216+
* Return a reference to the remote connection to allow caller to
217+
* perform a copy only as needed.
218+
*/
219+
crimson::net::ConnectionXcoreRef &get_remote_connection() {
220+
return r_conn;
221+
}
222+
};
223+
168224
template <class T>
169225
class TrackableOperationT : public OperationT<T> {
170226
T* that() {

0 commit comments

Comments
 (0)