Skip to content

Commit 436706c

Browse files
committed
crimson/osd: avoid unnecessary foreign copy in ms_dispatch()
Foreign-copy also implies that requests may be out-of-order, which is incorrect in the data path. Signed-off-by: Yingxin Cheng <[email protected]>
1 parent d6c5f05 commit 436706c

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/crimson/osd/osd.cc

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -777,9 +777,7 @@ OSD::ms_dispatch(crimson::net::ConnectionRef conn, MessageRef m)
777777
case MSG_OSD_PG_UPDATE_LOG_MISSING:
778778
case MSG_OSD_PG_UPDATE_LOG_MISSING_REPLY:
779779
{
780-
return conn.get_foreign().then([this, m = std::move(m)](auto f_conn) {
781-
return shard_dispatchers.local().ms_dispatch(std::move(f_conn), std::move(m));
782-
});
780+
return shard_dispatchers.local().ms_dispatch(conn, std::move(m));
783781
}
784782
default:
785783
{
@@ -793,22 +791,26 @@ OSD::ms_dispatch(crimson::net::ConnectionRef conn, MessageRef m)
793791

794792
seastar::future<>
795793
OSD::ShardDispatcher::ms_dispatch(
796-
crimson::net::ConnectionFRef f_conn,
794+
crimson::net::ConnectionRef conn,
797795
MessageRef m)
798796
{
799797
if (seastar::this_shard_id() != PRIMARY_CORE) {
800798
switch (m->get_type()) {
801799
case CEPH_MSG_OSD_MAP:
802800
case MSG_COMMAND:
803801
case MSG_OSD_MARK_ME_DOWN:
804-
return container().invoke_on(PRIMARY_CORE,
805-
[f_conn = std::move(f_conn), m = std::move(m)]
806-
(auto& local_dispatcher) mutable {
807-
return local_dispatcher.ms_dispatch(std::move(f_conn), std::move(m));
802+
// FIXME: order is not guaranteed in this path
803+
return conn.get_foreign(
804+
).then([this, m=std::move(m)](auto f_conn) {
805+
return container().invoke_on(PRIMARY_CORE,
806+
[f_conn=std::move(f_conn), m=std::move(m)]
807+
(auto& local_dispatcher) mutable {
808+
auto conn = make_local_shared_foreign(std::move(f_conn));
809+
return local_dispatcher.ms_dispatch(conn, std::move(m));
810+
});
808811
});
809812
}
810813
}
811-
crimson::net::ConnectionRef conn = make_local_shared_foreign(std::move(f_conn));
812814

813815
switch (m->get_type()) {
814816
case CEPH_MSG_OSD_MAP:

src/crimson/osd/osd.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ class OSD final : public crimson::net::Dispatcher,
8080
~ShardDispatcher() = default;
8181

8282
// Dispatcher methods
83-
seastar::future<> ms_dispatch(crimson::net::ConnectionFRef,
84-
MessageRef);
83+
seastar::future<> ms_dispatch(crimson::net::ConnectionRef, MessageRef);
8584

8685
private:
8786
bool require_mon_peer(crimson::net::Connection *conn, Ref<Message> m);

0 commit comments

Comments
 (0)