Skip to content

Commit

Permalink
mds: Add new flag to MClientSession
Browse files Browse the repository at this point in the history
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 <[email protected]>
Fixes: https://tracker.ceph.com/issues/52382
  • Loading branch information
kotreshhr committed Aug 26, 2021
1 parent c045701 commit e5b6737
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/mds/Server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,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);
Expand All @@ -635,7 +635,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;
}
Expand Down
13 changes: 10 additions & 3 deletions src/messages/MClientSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string, std::string> metadata;
feature_bitset_t supported_features;
metric_spec_t metric_spec;
Expand All @@ -38,8 +40,9 @@ class MClientSession final : public SafeMessage {

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;
Expand Down Expand Up @@ -75,6 +78,9 @@ class MClientSession final : public SafeMessage {
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;
Expand All @@ -89,6 +95,7 @@ class MClientSession final : public SafeMessage {
encode(metadata, payload);
encode(supported_features, payload);
encode(metric_spec, payload);
encode(flags, payload);
}
}
private:
Expand Down

0 comments on commit e5b6737

Please sign in to comment.