From 10dbcf74e7e67514005a079972ef0cd7560130cd Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Mon, 10 Jul 2023 16:56:43 -0400 Subject: [PATCH] msg: indicate ms_handle_authentication is fast Like other fast Dispatcher methods, it must not acquire locks or do anything that might take a long time. Signed-off-by: Patrick Donnelly (cherry picked from commit 3e2075103a0ab6b7ced5800db1d44d13b1c8b7e6) --- src/mds/MDSDaemon.cc | 2 +- src/mds/MDSDaemon.h | 2 +- src/mgr/DaemonServer.cc | 2 +- src/mgr/DaemonServer.h | 2 +- src/mon/AuthMonitor.cc | 2 +- src/mon/MonClient.cc | 4 ++-- src/mon/Monitor.cc | 6 +++--- src/mon/Monitor.h | 2 +- src/msg/Dispatcher.h | 7 +++++-- src/osd/OSD.cc | 2 +- src/osd/OSD.h | 4 ++-- src/test/fio/fio_ceph_messenger.cc | 2 +- src/test/msgr/perf_msgr_client.cc | 2 +- src/test/msgr/perf_msgr_server.cc | 2 +- src/test/msgr/test_msgr.cc | 6 +++--- 15 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/mds/MDSDaemon.cc b/src/mds/MDSDaemon.cc index de8f8838f9d59..009c6c31e794a 100644 --- a/src/mds/MDSDaemon.cc +++ b/src/mds/MDSDaemon.cc @@ -1070,7 +1070,7 @@ bool MDSDaemon::parse_caps(const AuthCapsInfo& info, MDSAuthCaps& caps) } } -int MDSDaemon::ms_handle_authentication(Connection *con) +int MDSDaemon::ms_handle_fast_authentication(Connection *con) { /* N.B. without mds_lock! */ MDSAuthCaps caps; diff --git a/src/mds/MDSDaemon.h b/src/mds/MDSDaemon.h index 97162cc88559c..35a9330f1b591 100644 --- a/src/mds/MDSDaemon.h +++ b/src/mds/MDSDaemon.h @@ -146,7 +146,7 @@ class MDSDaemon : public Dispatcher { private: bool ms_dispatch2(const ref_t &m) override; - int ms_handle_authentication(Connection *con) override; + int ms_handle_fast_authentication(Connection *con) override; void ms_handle_accept(Connection *con) override; void ms_handle_connect(Connection *con) override; bool ms_handle_reset(Connection *con) override; diff --git a/src/mgr/DaemonServer.cc b/src/mgr/DaemonServer.cc index 15cd9f0e7e02e..b1c1213e03ad5 100644 --- a/src/mgr/DaemonServer.cc +++ b/src/mgr/DaemonServer.cc @@ -171,7 +171,7 @@ entity_addrvec_t DaemonServer::get_myaddrs() const return msgr->get_myaddrs(); } -int DaemonServer::ms_handle_authentication(Connection *con) +int DaemonServer::ms_handle_fast_authentication(Connection *con) { auto s = ceph::make_ref(cct); con->set_priv(s); diff --git a/src/mgr/DaemonServer.h b/src/mgr/DaemonServer.h index a4cf990bd319b..eaaac41b71cda 100644 --- a/src/mgr/DaemonServer.h +++ b/src/mgr/DaemonServer.h @@ -269,7 +269,7 @@ public: ~DaemonServer() override; bool ms_dispatch2(const ceph::ref_t& m) override; - int ms_handle_authentication(Connection *con) override; + int ms_handle_fast_authentication(Connection *con) override; bool ms_handle_reset(Connection *con) override; void ms_handle_remote_reset(Connection *con) override {} bool ms_handle_refused(Connection *con) override; diff --git a/src/mon/AuthMonitor.cc b/src/mon/AuthMonitor.cc index f08608c6133d6..9931caa580002 100644 --- a/src/mon/AuthMonitor.cc +++ b/src/mon/AuthMonitor.cc @@ -773,7 +773,7 @@ bool AuthMonitor::prep_auth(MonOpRequestRef op, bool paxos_writable) } if (ret > 0) { if (!s->authenticated && - mon.ms_handle_authentication(s->con.get()) > 0) { + mon.ms_handle_fast_authentication(s->con.get()) > 0) { finished = true; } ret = 0; diff --git a/src/mon/MonClient.cc b/src/mon/MonClient.cc index a9fba82883b9e..357a1a2764c64 100644 --- a/src/mon/MonClient.cc +++ b/src/mon/MonClient.cc @@ -1570,7 +1570,7 @@ int MonClient::handle_auth_request( // for some channels prior to nautilus (osd heartbeat), we // tolerate the lack of an authorizer. if (!con->get_messenger()->require_authorizer) { - handle_authentication_dispatcher->ms_handle_authentication(con); + handle_authentication_dispatcher->ms_handle_fast_authentication(con); return 1; } return -EACCES; @@ -1608,7 +1608,7 @@ int MonClient::handle_auth_request( &auth_meta->connection_secret, ac); if (isvalid) { - handle_authentication_dispatcher->ms_handle_authentication(con); + handle_authentication_dispatcher->ms_handle_fast_authentication(con); return 1; } if (!more && !was_challenge && auth_meta->authorizer_challenge) { diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 26ea7acd2f59a..ffc99ec24b7c0 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -6352,7 +6352,7 @@ int Monitor::handle_auth_request( &auth_meta->connection_secret, &auth_meta->authorizer_challenge); if (isvalid) { - ms_handle_authentication(con); + ms_handle_fast_authentication(con); return 1; } if (!more && !was_challenge && auth_meta->authorizer_challenge) { @@ -6473,7 +6473,7 @@ int Monitor::handle_auth_request( } if (r > 0 && !s->authenticated) { - ms_handle_authentication(con); + ms_handle_fast_authentication(con); } dout(30) << " r " << r << " reply:\n"; @@ -6511,7 +6511,7 @@ void Monitor::ms_handle_accept(Connection *con) } } -int Monitor::ms_handle_authentication(Connection *con) +int Monitor::ms_handle_fast_authentication(Connection *con) { if (con->get_peer_type() == CEPH_ENTITY_TYPE_MON) { // mon <-> mon connections need no Session, and setting one up diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index 1093649bb3df2..e52fb974d5b62 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -957,7 +957,7 @@ public: MonCap mon_caps; bool get_authorizer(int dest_type, AuthAuthorizer **authorizer); public: // for AuthMonitor msgr1: - int ms_handle_authentication(Connection *con) override; + int ms_handle_fast_authentication(Connection *con) override; private: void ms_handle_accept(Connection *con) override; bool ms_handle_reset(Connection *con) override; diff --git a/src/msg/Dispatcher.h b/src/msg/Dispatcher.h index 5e025437b5357..885f1843b31c4 100644 --- a/src/msg/Dispatcher.h +++ b/src/msg/Dispatcher.h @@ -204,13 +204,16 @@ public: /** * handle successful authentication (msgr2) * - * Authenticated result/state will be attached to the Connection. + * Authenticated result/state will be attached to the Connection. This is + * called via the MonClient. + * + * Do not acquire locks in this method! It is considered "fast" delivery. * * return 1 for success * return 0 for no action (let another Dispatcher handle it) * return <0 for failure (failure to parse caps, for instance) */ - virtual int ms_handle_authentication(Connection *con) { + virtual int ms_handle_fast_authentication(Connection *con) { return 0; } diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index c8f87a18bd5c4..e0d8d78650a1f 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -7338,7 +7338,7 @@ void OSD::ms_fast_dispatch(Message *m) OID_EVENT_TRACE_WITH_MSG(m, "MS_FAST_DISPATCH_END", false); } -int OSD::ms_handle_authentication(Connection *con) +int OSD::ms_handle_fast_authentication(Connection *con) { int ret = 0; auto s = ceph::ref_cast(con->get_priv()); diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 9efb2b62cba70..0e9bc06a3b79d 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -1572,7 +1572,7 @@ public: bool ms_handle_refused(Connection *con) override { return osd->ms_handle_refused(con); } - int ms_handle_authentication(Connection *con) override { + int ms_handle_fast_authentication(Connection *con) override { return true; } } heartbeat_dispatcher; @@ -2033,7 +2033,7 @@ private: void ms_handle_connect(Connection *con) override; void ms_handle_fast_connect(Connection *con) override; void ms_handle_fast_accept(Connection *con) override; - int ms_handle_authentication(Connection *con) override; + int ms_handle_fast_authentication(Connection *con) override; bool ms_handle_reset(Connection *con) override; void ms_handle_remote_reset(Connection *con) override {} bool ms_handle_refused(Connection *con) override; diff --git a/src/test/fio/fio_ceph_messenger.cc b/src/test/fio/fio_ceph_messenger.cc index 4a4cf4fb57512..e5e170288ffe2 100644 --- a/src/test/fio/fio_ceph_messenger.cc +++ b/src/test/fio/fio_ceph_messenger.cc @@ -268,7 +268,7 @@ public: bool ms_handle_refused(Connection *con) override { return false; } - int ms_handle_authentication(Connection *con) override { + int ms_handle_fast_authentication(Connection *con) override { return 1; } }; diff --git a/src/test/msgr/perf_msgr_client.cc b/src/test/msgr/perf_msgr_client.cc index 0e5c5ab367f29..32fa4002f5fe4 100644 --- a/src/test/msgr/perf_msgr_client.cc +++ b/src/test/msgr/perf_msgr_client.cc @@ -57,7 +57,7 @@ class MessengerClient { bool ms_handle_reset(Connection *con) override { return true; } void ms_handle_remote_reset(Connection *con) override {} bool ms_handle_refused(Connection *con) override { return false; } - int ms_handle_authentication(Connection *con) override { + int ms_handle_fast_authentication(Connection *con) override { return 1; } }; diff --git a/src/test/msgr/perf_msgr_server.cc b/src/test/msgr/perf_msgr_server.cc index f17f90f6d081a..67bb591a90318 100644 --- a/src/test/msgr/perf_msgr_server.cc +++ b/src/test/msgr/perf_msgr_server.cc @@ -100,7 +100,7 @@ class ServerDispatcher : public Dispatcher { //cerr << __func__ << " reply message=" << m << std::endl; op_wq.queue(m); } - int ms_handle_authentication(Connection *con) override { + int ms_handle_fast_authentication(Connection *con) override { return 1; } }; diff --git a/src/test/msgr/test_msgr.cc b/src/test/msgr/test_msgr.cc index 3ebe320be1191..8e4506a4ef087 100644 --- a/src/test/msgr/test_msgr.cc +++ b/src/test/msgr/test_msgr.cc @@ -215,7 +215,7 @@ class FakeDispatcher : public Dispatcher { cond.notify_all(); } - int ms_handle_authentication(Connection *con) override { + int ms_handle_fast_authentication(Connection *con) override { return 1; } @@ -1704,7 +1704,7 @@ class SyntheticDispatcher : public Dispatcher { } } - int ms_handle_authentication(Connection *con) override { + int ms_handle_fast_authentication(Connection *con) override { return 1; } @@ -2262,7 +2262,7 @@ class MarkdownDispatcher : public Dispatcher { void ms_fast_dispatch(Message *m) override { ceph_abort(); } - int ms_handle_authentication(Connection *con) override { + int ms_handle_fast_authentication(Connection *con) override { return 1; } }; -- 2.39.5