]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/Message: add helper method is_a_client()
authordparmar18 <dparmar@redhat.com>
Mon, 1 Aug 2022 08:23:05 +0000 (13:53 +0530)
committerdparmar18 <dparmar@redhat.com>
Mon, 26 Sep 2022 12:02:08 +0000 (17:32 +0530)
Uses connection to find the client instead of using
header data used by get_source().is_client()

Signed-off-by: Dhairy Parmar <dparmar@redhat.com>
(cherry picked from commit ae5ff477d21134afe6a017db828549c8c350b806)

src/mds/Server.cc
src/msg/Message.h

index 400ff5266fb2b240f3e07c2c880cef2a69a0f763..9963e6aff6e6d012df76c68a28d9c32bf0661da3 100644 (file)
@@ -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<MClientReclaim> &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<MClientSession> &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<MClientRequest> &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<MClientRequest> &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);
index c3b47eee20b07b67be80b5c0d8f23586d5c9e87b..5ea78c22d9543f8108bc61d9ef75a64156f43def 100644 (file)
@@ -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;