]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: Add new flag to MClientSession 43252/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:59:47 +0000 (11:29 +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)

Conflicts:
 src/mds/Server.cc : The commit dfd01d765304 (blacklist -> blocklist)
is not present in octopus

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

index 46ec83570253aec7aa23f5b5ba7ddd389fc31427..4100043164036d89ed5ed2a35d8d026504a5ad90 100644 (file)
@@ -588,8 +588,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);
@@ -603,6 +603,8 @@ void Server::handle_client_session(const cref_t<MClientSession> &m)
 
       if (blacklisted) {
        dout(10) << "rejecting blacklisted client " << addr << dendl;
+        unsigned flags = 0;
+       flags |= MClientSession::SESSION_BLOCKLISTED;
        send_reject_message("blacklisted");
        session->clear();
        break;
index d129fb90bf505acc174aa2d6cc1160721c0f262e..4bfadd03b3cc29ae90660733becb9658310e54b9 100644 (file)
 
 class MClientSession : 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;
@@ -74,6 +77,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;
@@ -88,6 +94,7 @@ public:
       encode(metadata, payload);
       encode(supported_features, payload);
       encode(metric_spec, payload);
+      encode(flags, payload);
     }
   }
 private: