From 428d437b432a3ac68f5b63b921ec519d58b6cf35 Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Mon, 5 Dec 2022 15:49:26 +0800 Subject: [PATCH] mds: send the cap_auths to clients when openning the sessions Fixes: https://tracker.ceph.com/issues/57154 Signed-off-by: Xiubo Li (cherry picked from commit c1cbb9acadc311f155b176d6108975835a616a5f) Conflicts: src/mds/MDSAuthCaps.h: missed dependency commit 23f1fdbcb3d ("AuthMonitor: allow "fs authorize" to update caps") --- src/mds/MDSAuthCaps.h | 9 +++++++++ src/mds/Server.cc | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/src/mds/MDSAuthCaps.h b/src/mds/MDSAuthCaps.h index 16282bca9b8..5f3787f9afa 100644 --- a/src/mds/MDSAuthCaps.h +++ b/src/mds/MDSAuthCaps.h @@ -276,6 +276,15 @@ public: return false; } + void get_cap_auths(std::vector *cap_auths) + { + for (const auto& grant : grants) { + cap_auths->emplace_back(MDSCapAuth(grant.match, + grant.spec.allow_read(), + grant.spec.allow_write())); + } + } + friend std::ostream &operator<<(std::ostream &out, const MDSAuthCaps &cap); private: std::vector grants; diff --git a/src/mds/Server.cc b/src/mds/Server.cc index efc6f9eaa96..b34634bba71 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -623,6 +623,7 @@ void Server::handle_client_session(const cref_t &m) session->get_push_seq()); if (session->info.has_feature(CEPHFS_FEATURE_MIMIC)) reply->supported_features = supported_features; + session->auth_caps.get_cap_auths(&reply->cap_auths); mds->send_message_client(reply, session); if (mdcache->is_readonly()) { auto m = make_message(CEPH_SESSION_FORCE_RO); @@ -913,6 +914,7 @@ void Server::_session_logged(Session *session, uint64_t state_seq, bool open, ve reply->supported_features = supported_features; reply->metric_spec = supported_metric_spec; } + session->auth_caps.get_cap_auths(&reply->cap_auths); mds->send_message_client(reply, session); if (mdcache->is_readonly()) { auto m = make_message(CEPH_SESSION_FORCE_RO); @@ -1069,6 +1071,7 @@ void Server::finish_force_open_sessions(const mapsupported_features = supported_features; reply->metric_spec = supported_metric_spec; } + session->auth_caps.get_cap_auths(&reply->cap_auths); mds->send_message_client(reply, session); if (mdcache->is_readonly()) @@ -1585,6 +1588,7 @@ void Server::handle_client_reconnect(const cref_t &m) reply->supported_features = supported_features; reply->metric_spec = supported_metric_spec; } + session->auth_caps.get_cap_auths(&reply->cap_auths); mds->send_message_client(reply, session); mds->clog->debug() << "reconnect by " << session->info.inst << " after " << delay; } -- 2.39.5