Skip to content

Commit

Permalink
fixup: MonClient can live in sharded environment.
Browse files Browse the repository at this point in the history
Signed-off-by: Radoslaw Zarzynski <[email protected]>
  • Loading branch information
rzarzynski authored and cyx1231st committed Jan 3, 2019
1 parent 3dae0ff commit e083fe6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
12 changes: 9 additions & 3 deletions src/crimson/mon/MonClient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ AuthMethodList create_auth_methods(uint32_t entity_type)

Client::Client(const EntityName& name,
ceph::net::Messenger& messenger)
: entity_name{name},
: ForeignDispatcher(seastar::engine().cpu_id()),
entity_name{name},
auth_methods{create_auth_methods(entity_name.get_type())},
want_keys{CEPH_ENTITY_TYPE_MON |
CEPH_ENTITY_TYPE_OSD |
Expand Down Expand Up @@ -296,9 +297,11 @@ bool Client::is_hunting() const {
}

seastar::future<>
Client::ms_dispatch(ceph::net::ConnectionRef conn, MessageRef m)
Client::fms_dispatch(ceph::net::ConnectionFRef conn, Client::MessageFRef m)
{
logger().info("ms_dispatch {}", *m);
#if 0
// TODO: need move to MessageFRef or MessengerXRef.
// we only care about these message types
switch (m->get_type()) {
case CEPH_MSG_MON_MAP:
Expand All @@ -324,9 +327,12 @@ Client::ms_dispatch(ceph::net::ConnectionRef conn, MessageRef m)
default:
return seastar::now();
}
#else
return seastar::now();
#endif
}

seastar::future<> Client::ms_handle_reset(ceph::net::ConnectionRef conn)
seastar::future<> Client::fms_handle_reset(ceph::net::ConnectionFRef conn)
{
auto found = std::find_if(pending_conns.begin(), pending_conns.end(),
[peer_addr = conn->get_peer_addr()](auto& mc) {
Expand Down
12 changes: 8 additions & 4 deletions src/crimson/mon/MonClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ namespace ceph::mon {

class Connection;

class Client : public ceph::net::Dispatcher {
// Suppose we don't want to shard MonClient to save resources -- one
// instance is fine. Let's see how much effort is necessary to interact
// with sharded world.
class Client : public ceph::net::ForeignDispatcher<Client> {
friend ceph::net::ForeignDispatcher<Client>;
const EntityName entity_name;
KeyRing keyring;
AuthMethodList auth_methods;
Expand Down Expand Up @@ -80,9 +84,9 @@ class Client : public ceph::net::Dispatcher {
private:
void tick();

seastar::future<> ms_dispatch(ceph::net::ConnectionRef conn,
MessageRef m) override;
seastar::future<> ms_handle_reset(ceph::net::ConnectionRef conn) override;
seastar::future<> fms_dispatch(ceph::net::ConnectionFRef conn,
MessageFRef m) override;
seastar::future<> fms_handle_reset(ceph::net::ConnectionFRef conn) override;

seastar::future<> handle_monmap(ceph::net::ConnectionRef conn,
Ref<MMonMap> m);
Expand Down
3 changes: 2 additions & 1 deletion src/crimson/net/Fwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ using msgr_tag_t = uint8_t;

class Connection;
using ConnectionRef = seastar::shared_ptr<Connection>;
using ConnectionFRef = seastar::foreign_ptr<ConnectionRef>;
// NOTE: ConnectionXRef should only be used in seastar world, because
// lw_shared_ptr<> is not safe to be accessed by unpinned alien threads.
using ConnectionXRef = seastar::lw_shared_ptr<seastar::foreign_ptr<ConnectionRef>>;
using ConnectionXRef = seastar::lw_shared_ptr<ConnectionFRef>;

class Dispatcher;

Expand Down

0 comments on commit e083fe6

Please sign in to comment.