]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: send the cap_auths to clients when openning the sessions
authorXiubo Li <xiubli@redhat.com>
Mon, 5 Dec 2022 07:49:26 +0000 (15:49 +0800)
committerXiubo Li <xiubli@redhat.com>
Wed, 27 Mar 2024 00:42:40 +0000 (08:42 +0800)
Fixes: https://tracker.ceph.com/issues/57154
Signed-off-by: Xiubo Li <xiubli@redhat.com>
(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
src/mds/Server.cc

index 16282bca9b8204c3cea1e8cc50098371a49883c4..5f3787f9afa1cd9174de0fba47ae734d9cd9cb53 100644 (file)
@@ -276,6 +276,15 @@ public:
     return false;
   }
 
+  void get_cap_auths(std::vector<MDSCapAuth> *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<MDSCapGrant> grants;
index efc6f9eaa96ca6ead28ae84adc9e9e62f138aa6a..b34634bba7103477869b83db45e8e9c11601aada 100644 (file)
@@ -623,6 +623,7 @@ void Server::handle_client_session(const cref_t<MClientSession> &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<MClientSession>(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<MClientSession>(CEPH_SESSION_FORCE_RO);
@@ -1069,6 +1071,7 @@ void Server::finish_force_open_sessions(const map<client_t,pair<Session*,uint64_
          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())
@@ -1585,6 +1588,7 @@ void Server::handle_client_reconnect(const cref_t<MClientReconnect> &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;
   }