]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: Add new flag to MClientSession 43251/head
authorKotresh HR <khiremat@redhat.com>
Wed, 18 Aug 2021 11:53:43 +0000 (17:23 +0530)
committerKotresh HR <khiremat@redhat.com>
Wed, 22 Sep 2021 05:51:15 +0000 (11:21 +0530)
The "error_string" in the metadata of MClientSession is being
parsed by kclient to validate whether the session is blocklisted.
The "error_string" is for humans and shouldn't be relied on it.
Hence added the flag to MClientsession to indicate the session
is blocklisted.

Signed-off-by: Kotresh HR <khiremat@redhat.com>
Fixes: https://tracker.ceph.com/issues/52382
(cherry picked from commit e5b6737db1f57dda8c6f1229286136e574633765)

src/mds/Server.cc
src/messages/MClientSession.h

index 2123aace1ec1ef68c0e4be8471f1fc8547a290e1..618f1160de56982b888810482c6c89104851e82d 100644 (file)
@@ -613,8 +613,8 @@ void Server::handle_client_session(const cref_t<MClientSession> &m)
         dout(2) << css->strv() << dendl;
       };
 
-      auto send_reject_message = [this, &session, &log_session_status](std::string_view err_str) {
-       auto m = make_message<MClientSession>(CEPH_SESSION_REJECT);
+      auto send_reject_message = [this, &session, &log_session_status](std::string_view err_str, unsigned flags=0) {
+       auto m = make_message<MClientSession>(CEPH_SESSION_REJECT, 0, flags);
        if (session->info.has_feature(CEPHFS_FEATURE_MIMIC))
          m->metadata["error_string"] = err_str;
        mds->send_message_client(m, session);
@@ -633,7 +633,9 @@ void Server::handle_client_session(const cref_t<MClientSession> &m)
        // has been blocklisted.  If mounted with recover_session=clean
        // (since 5.4), it tries to automatically recover itself from
        // blocklisting.
-       send_reject_message("blocklisted (blacklisted)");
+        unsigned flags = 0;
+       flags |= MClientSession::SESSION_BLOCKLISTED;
+       send_reject_message("blocklisted (blacklisted)", flags);
        session->clear();
        break;
       }
index 19dc30f256a1445e114d744fc2799cd98643b5ca..f6927a49c6cc4458f81f47284dbdedf9c91b8bab 100644 (file)
 
 class MClientSession final : public SafeMessage {
 private:
-  static constexpr int HEAD_VERSION = 4;
+  static constexpr int HEAD_VERSION = 5;
   static constexpr int COMPAT_VERSION = 1;
 
 public:
   ceph_mds_session_head head;
+  static constexpr unsigned SESSION_BLOCKLISTED = (1<<0);
 
+  unsigned flags = 0;
   std::map<std::string, std::string> metadata;
   feature_bitset_t supported_features;
   metric_spec_t metric_spec;
@@ -38,8 +40,9 @@ public:
 
 protected:
   MClientSession() : SafeMessage{CEPH_MSG_CLIENT_SESSION, HEAD_VERSION, COMPAT_VERSION} { }
-  MClientSession(int o, version_t s=0) : 
-    SafeMessage{CEPH_MSG_CLIENT_SESSION, HEAD_VERSION, COMPAT_VERSION} {
+  MClientSession(int o, version_t s=0, unsigned msg_flags=0) :
+    SafeMessage{CEPH_MSG_CLIENT_SESSION, HEAD_VERSION, COMPAT_VERSION},
+    flags(msg_flags) {
     memset(&head, 0, sizeof(head));
     head.op = o;
     head.seq = s;
@@ -75,6 +78,9 @@ public:
     if (header.version >= 4) {
       decode(metric_spec, p);
     }
+    if (header.version >= 5) {
+      decode(flags, p);
+    }
   }
   void encode_payload(uint64_t features) override { 
     using ceph::encode;
@@ -89,6 +95,7 @@ public:
       encode(metadata, payload);
       encode(supported_features, payload);
       encode(metric_spec, payload);
+      encode(flags, payload);
     }
   }
 private: