From e5b6737db1f57dda8c6f1229286136e574633765 Mon Sep 17 00:00:00 2001 From: Kotresh HR Date: Wed, 18 Aug 2021 17:23:43 +0530 Subject: [PATCH] mds: Add new flag to MClientSession 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 Fixes: https://tracker.ceph.com/issues/52382 --- src/mds/Server.cc | 8 +++++--- src/messages/MClientSession.h | 13 ++++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/mds/Server.cc b/src/mds/Server.cc index d40831cd52f..e68ba9f2af7 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -615,8 +615,8 @@ void Server::handle_client_session(const cref_t &m) dout(2) << css->strv() << dendl; }; - auto send_reject_message = [this, &session, &log_session_status](std::string_view err_str) { - auto m = make_message(CEPH_SESSION_REJECT); + auto send_reject_message = [this, &session, &log_session_status](std::string_view err_str, unsigned flags=0) { + auto m = make_message(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); @@ -635,7 +635,9 @@ void Server::handle_client_session(const cref_t &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; } diff --git a/src/messages/MClientSession.h b/src/messages/MClientSession.h index d5200cf8273..7ce165870c3 100644 --- a/src/messages/MClientSession.h +++ b/src/messages/MClientSession.h @@ -20,12 +20,14 @@ 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 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: -- 2.39.5