]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mds: add ceph.dir.subvolume get vxattr
authorEdwin Rodriguez <edwin.rodriguez1@ibm.com>
Mon, 18 Aug 2025 20:17:07 +0000 (16:17 -0400)
committerJos Collin <jcollin@redhat.com>
Sat, 4 Oct 2025 02:59:12 +0000 (08:29 +0530)
This introduces handling for the "ceph.dir.subvolume" virtual xattr on directories.
- Returns ASCII "1" when the directory is a subvolume root, "0" otherwise.

QA:
- Extend CephFS subvolume tests to validate vxattr retrieval and behavior around setting/removal.

Fixes: https://tracker.ceph.com/issues/72556
Signed-off-by: Edwin Rodriguez <edwin.rodriguez1@ibm.com>
(cherry picked from commit 51fb4b6abe9daba651150055c7f768d8a6d61d48)

 Conflicts:
    qa/tasks/cephfs/test_subvolume.py
    - resolved conflicts of https://github.com/ceph/ceph/commit/3d5dd1235316775a9dbfdd225c76da09efe02e31
      not backported to tentacle yet.

qa/tasks/cephfs/test_subvolume.py
src/mds/Server.cc
src/mds/Server.h

index f67b33da9bad3b631da7cb86af6ecc2d3b73c661..571eac677d52688a8071e910fa52fd74b4db5982 100644 (file)
@@ -198,6 +198,27 @@ class TestSubvolume(CephFSTestCase):
         self.mount_a.run_shell(['rmdir', 'group/subvol2/dir/.snap/s2'])
 
 
+    def test_subvolume_vxattr_retrieval(self):
+        """
+        To verify that the ceph.dir.subvolume vxattr can be acquired using getfattr
+        """
+        # create subvolume dir
+        subvol_dir:str = 'group/subvol5'
+        self.mount_a.run_shell(['mkdir', subvol_dir])
+        mkdir_fattr = self.mount_a.getfattr(subvol_dir, 'ceph.dir.subvolume')
+        self.assertEqual('0', mkdir_fattr)
+
+        self.mount_a.setfattr(subvol_dir, 'ceph.dir.subvolume', '1')
+        new_fattr:str = self.mount_a.getfattr(subvol_dir, 'ceph.dir.subvolume')
+        self.assertEqual('1', new_fattr)
+
+        # clear subvolume flag
+        self.mount_a.removexattr(subvol_dir, 'ceph.dir.subvolume')
+
+        # cleanup
+        self.mount_a.run_shell(['rm', '-rf', subvol_dir])
+
+
 class TestSubvolumeReplicated(CephFSTestCase):
     CLIENTS_REQUIRED = 1
     MDSS_REQUIRED = 2
index 45422694c09d11971a72f498c2f21595911cba63..44df78dcc306e1d9c8789f4bee36a0bef8240435 100644 (file)
@@ -7243,6 +7243,9 @@ void Server::handle_client_getvxattr(const MDRequestRef& mdr)
       // since we only handle ceph vxattrs here
       r = -ENODATA; // no such attribute
     }
+  } else if (xattr_name == "ceph.dir.subvolume"sv) {
+    const auto* srnode = cur->get_projected_srnode();
+    *css << (srnode && srnode->is_subvolume() ? "1"sv : "0"sv);
   } else {
     // otherwise respond as invalid request
     // since we only handle ceph vxattrs here
index f994514bbce5f8170cc6254ea6e10088ad32ce9a..53fac0248db5a14fb25af6cabe74e4140c4d1b1b 100644 (file)
@@ -498,21 +498,22 @@ private:
 
   static bool is_ceph_dir_vxattr(std::string_view xattr_name) {
     return xattr_name == "ceph.dir.layout" ||
-           xattr_name == "ceph.dir.layout.json" ||
-           xattr_name == "ceph.dir.layout.object_size" ||
-           xattr_name == "ceph.dir.layout.stripe_unit" ||
-           xattr_name == "ceph.dir.layout.stripe_count" ||
-           xattr_name == "ceph.dir.layout.pool" ||
-           xattr_name == "ceph.dir.layout.pool_name" ||
-           xattr_name == "ceph.dir.layout.pool_id" ||
-           xattr_name == "ceph.dir.layout.pool_namespace" ||
-           xattr_name == "ceph.dir.pin" ||
-           xattr_name == "ceph.dir.pin.random" ||
-           xattr_name == "ceph.dir.pin.distributed" ||
-            xattr_name == "ceph.dir.charmap"sv ||
-            xattr_name == "ceph.dir.normalization"sv ||
-            xattr_name == "ceph.dir.encoding"sv ||
-            xattr_name == "ceph.dir.casesensitive"sv;
+          xattr_name == "ceph.dir.layout.json" ||
+          xattr_name == "ceph.dir.layout.object_size" ||
+          xattr_name == "ceph.dir.layout.stripe_unit" ||
+          xattr_name == "ceph.dir.layout.stripe_count" ||
+          xattr_name == "ceph.dir.layout.pool" ||
+          xattr_name == "ceph.dir.layout.pool_name" ||
+          xattr_name == "ceph.dir.layout.pool_id" ||
+          xattr_name == "ceph.dir.layout.pool_namespace" ||
+          xattr_name == "ceph.dir.pin" ||
+          xattr_name == "ceph.dir.pin.random" ||
+          xattr_name == "ceph.dir.pin.distributed" ||
+          xattr_name == "ceph.dir.charmap"sv ||
+          xattr_name == "ceph.dir.normalization"sv ||
+          xattr_name == "ceph.dir.encoding"sv ||
+          xattr_name == "ceph.dir.casesensitive"sv ||
+          xattr_name == "ceph.dir.subvolume"sv;
   }
 
   static bool is_ceph_file_vxattr(std::string_view xattr_name) {