Skip to content

Commit

Permalink
Merge pull request ceph#51318 from Matan-B/wip-matanb-c-avoid-msg-con
Browse files Browse the repository at this point in the history
crimson: Avoid any Message's connection usage

Reviewed-by: Samuel Just <[email protected]>
Reviewed-by: Radoslaw Zarzynski <[email protected]>
Reviewed-by: Liu-Chunmei <[email protected]>
Reviewed-by: Yingxin Cheng <[email protected]>
  • Loading branch information
yuriw committed May 19, 2023
2 parents 7859709 + 503a1a8 commit ced2466
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/crimson/admin/admin_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "messages/MCommandReply.h"
#include "crimson/common/log.h"
#include "crimson/net/Socket.h"
#include "crimson/net/Connection.h"

using namespace crimson::common;
using namespace std::literals;
Expand Down
1 change: 1 addition & 0 deletions src/crimson/osd/shard_services.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "crimson/osd/pg_map.h"
#include "crimson/osd/state.h"
#include "common/AsyncReserver.h"
#include "crimson/net/Connection.h"

namespace crimson::net {
class Messenger;
Expand Down
4 changes: 4 additions & 0 deletions src/messages/MForward.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ class MForward final : public Message {
tid(t), client_caps(caps), msg(NULL) {
client_type = m->get_source().type();
client_addrs = m->get_source_addrs();
#ifdef WITH_SEASTAR
ceph_abort("In crimson, conn is independently maintained outside Message");
#else
if (auto &con = m->get_connection()) {
client_socket_addr = con->get_peer_socket_addr();
}
#endif
con_features = feat;
msg = (PaxosServiceMessage*)m->get();
}
Expand Down
6 changes: 3 additions & 3 deletions src/messages/MOSDOp.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ class MOSDOp final : public MOSDFastDispatchOp {
if (features)
return features;
#ifdef WITH_SEASTAR
// In crimson, conn is independently maintained outside Message.
ceph_abort();
#endif
ceph_abort("In crimson, conn is independently maintained outside Message");
#else
return get_connection()->get_features();
#endif
}

MOSDOp()
Expand Down
15 changes: 12 additions & 3 deletions src/msg/Message.cc
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,10 @@ Message *decode_message(CephContext *cct,
if (front_crc != footer.front_crc) {
if (cct) {
ldout(cct, 0) << "bad crc in front " << front_crc << " != exp " << footer.front_crc
<< " from " << conn->get_peer_addr() << dendl;
#ifndef WITH_SEASTAR
<< " from " << conn->get_peer_addr()
#endif
<< dendl;
ldout(cct, 20) << " ";
front.hexdump(*_dout);
*_dout << dendl;
Expand All @@ -336,7 +339,10 @@ Message *decode_message(CephContext *cct,
if (middle_crc != footer.middle_crc) {
if (cct) {
ldout(cct, 0) << "bad crc in middle " << middle_crc << " != exp " << footer.middle_crc
<< " from " << conn->get_peer_addr() << dendl;
#ifndef WITH_SEASTAR
<< " from " << conn->get_peer_addr()
#endif
<< dendl;
ldout(cct, 20) << " ";
middle.hexdump(*_dout);
*_dout << dendl;
Expand All @@ -350,7 +356,10 @@ Message *decode_message(CephContext *cct,
if (data_crc != footer.data_crc) {
if (cct) {
ldout(cct, 0) << "bad crc in data " << data_crc << " != exp " << footer.data_crc
<< " from " << conn->get_peer_addr() << dendl;
#ifndef WITH_SEASTAR
<< " from " << conn->get_peer_addr()
#endif
<< dendl;
ldout(cct, 20) << " ";
data.hexdump(*_dout);
*_dout << dendl;
Expand Down
24 changes: 16 additions & 8 deletions src/msg/Message.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@
#include "msg/MessageRef.h"
#include "msg_types.h"

#ifdef WITH_SEASTAR
# include "crimson/net/SocketConnection.h"
#endif // WITH_SEASTAR

// monitor internal
#define MSG_MON_SCRUB 64
#define MSG_MON_ELECTION 65
Expand Down Expand Up @@ -251,10 +247,11 @@
class Message : public RefCountedObject {
public:
#ifdef WITH_SEASTAR
using ConnectionRef = crimson::net::ConnectionRef;
// In crimson, conn is independently maintained outside Message.
using ConnectionRef = void*;
#else
using ConnectionRef = ::ConnectionRef;
#endif // WITH_SEASTAR
#endif

protected:
ceph_msg_header header; // headerelope
Expand Down Expand Up @@ -351,8 +348,7 @@ class Message : public RefCountedObject {
public:
const ConnectionRef& get_connection() const {
#ifdef WITH_SEASTAR
// In crimson, conn is independently maintained outside Message.
ceph_abort();
ceph_abort("In crimson, conn is independently maintained outside Message");
#endif
return connection;
}
Expand Down Expand Up @@ -497,13 +493,21 @@ class Message : public RefCountedObject {
return entity_name_t(header.src);
}
entity_addr_t get_source_addr() const {
#ifdef WITH_SEASTAR
ceph_abort("In crimson, conn is independently maintained outside Message");
#else
if (connection)
return connection->get_peer_addr();
#endif
return entity_addr_t();
}
entity_addrvec_t get_source_addrs() const {
#ifdef WITH_SEASTAR
ceph_abort("In crimson, conn is independently maintained outside Message");
#else
if (connection)
return connection->get_peer_addrs();
#endif
return entity_addrvec_t();
}

Expand Down Expand Up @@ -561,7 +565,11 @@ class SafeMessage : public Message {
public:
using Message::Message;
bool is_a_client() const {
#ifdef WITH_SEASTAR
ceph_abort("In crimson, conn is independently maintained outside Message");
#else
return get_connection()->get_peer_type() == CEPH_ENTITY_TYPE_CLIENT;
#endif
}

private:
Expand Down
4 changes: 4 additions & 0 deletions src/osd/OpRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ struct OpRequest : public TrackedOp {
void _dump(ceph::Formatter *f) const override;

bool has_feature(uint64_t f) const {
#ifdef WITH_SEASTAR
ceph_abort("In crimson, conn is independently maintained outside Message");
#else
return request->get_connection()->has_feature(f);
#endif
}

private:
Expand Down

0 comments on commit ced2466

Please sign in to comment.