]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: refactor out fs_name match in MDSAuthCaps
authorPatrick Donnelly <pdonnell@redhat.com>
Thu, 2 May 2024 12:55:36 +0000 (08:55 -0400)
committerPatrick Donnelly <pdonnell@redhat.com>
Tue, 21 May 2024 16:18:58 +0000 (12:18 -0400)
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
(cherry picked from commit 247b4fed28617c104473d1586b66a8735bff0411)

src/mds/MDSAuthCaps.h

index c1d410eaf76fb174dcdc4ec2c34b5316c87e5a98..9172e266aab60b356adda5390ae6814c639df619 100644 (file)
@@ -158,6 +158,10 @@ struct MDSCapMatch {
   bool match_path(std::string_view target_path) const;
   std::string to_string();
 
+  bool match_fs(std::string_view target_fs) const {
+    return fs_name == target_fs || fs_name.empty() || fs_name == "*";
+  }
+
   void encode(ceph::buffer::list& bl) const {
     ENCODE_START(1, 1, bl);
     encode(uid, bl);
@@ -275,8 +279,7 @@ public:
     }
 
     for (const MDSCapGrant &g : grants) {
-      if (g.match.fs_name == fs_name || g.match.fs_name.empty() ||
-         g.match.fs_name == "*") {
+      if (g.match.match_fs(fs_name)) {
        if (mask & MAY_READ && g.spec.allow_read()) {
          return true;
        }