From: dparmar18 Date: Mon, 1 Aug 2022 08:23:05 +0000 (+0530) Subject: msg/Message: add helper method is_a_client() X-Git-Tag: v16.2.11~81^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c52a49b76b357dee9a2fda0c50c4b53400c66441;p=ceph.git msg/Message: add helper method is_a_client() Uses connection to find the client instead of using header data used by get_source().is_client() Signed-off-by: Dhairy Parmar (cherry picked from commit ae5ff477d21134afe6a017db828549c8c350b806) --- diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 400ff5266fb2..9963e6aff6e6 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -60,6 +60,8 @@ #include "common/config.h" +#include "msg/Message.h" + #define dout_context g_ceph_context #define dout_subsys ceph_subsys_mds #undef dout_prefix @@ -502,7 +504,7 @@ void Server::handle_client_reclaim(const cref_t &m) { Session *session = mds->get_session(m); dout(3) << __func__ << " " << *m << " from " << m->get_source() << dendl; - assert(m->get_source().is_client()); // should _not_ come from an mds! + ceph_assert(m->is_a_client()); // should _not_ come from an mds! if (!session) { dout(0) << " ignoring sessionless msg " << *m << dendl; @@ -533,7 +535,7 @@ void Server::handle_client_session(const cref_t &m) Session *session = mds->get_session(m); dout(3) << "handle_client_session " << *m << " from " << m->get_source() << dendl; - ceph_assert(m->get_source().is_client()); // should _not_ come from an mds! + ceph_assert(m->is_a_client()); // should _not_ come from an mds! if (!session) { dout(0) << " ignoring sessionless msg " << *m << dendl; @@ -2338,7 +2340,7 @@ void Server::handle_client_request(const cref_t &req) bool sessionclosed_isok = replay_unsafe_with_closed_session; // active session? Session *session = 0; - if (req->get_source().is_client()) { + if (req->is_a_client()) { session = mds->get_session(req); if (!session) { dout(5) << "no session for " << req->get_source() << ", dropping" << dendl; @@ -2442,7 +2444,7 @@ void Server::handle_client_request(const cref_t &req) // process embedded cap releases? // (only if NOT replay!) - if (!req->releases.empty() && req->get_source().is_client() && !req->is_replay()) { + if (!req->releases.empty() && req->is_a_client() && !req->is_replay()) { client_t client = req->get_source().num(); for (const auto &r : req->releases) { mds->locker->process_request_cap_release(mdr, client, r.item, r.dname); diff --git a/src/msg/Message.h b/src/msg/Message.h index c3b47eee20b0..5ea78c22d954 100644 --- a/src/msg/Message.h +++ b/src/msg/Message.h @@ -544,6 +544,10 @@ extern Message *decode_message(CephContext *cct, int crcflags, class SafeMessage : public Message { public: using Message::Message; + bool is_a_client() const { + return get_connection()->get_peer_type() == CEPH_ENTITY_TYPE_CLIENT; + } + private: using RefCountedObject::get; using RefCountedObject::put;