]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
pybind/mgr: create normalization xattr in subvolumes
authorXavi Hernandez <xhernandez@gmail.com>
Wed, 19 Mar 2025 11:59:59 +0000 (12:59 +0100)
committerPatrick Donnelly <pdonnell@ibm.com>
Tue, 23 Sep 2025 14:43:50 +0000 (10:43 -0400)
When a new subvolume is created, optionally set the
ceph.dir.normalization xattr to the root directory.

Signed-off-by: Xavi Hernandez <xhernandez@gmail.com>
(cherry picked from commit 4a414a57af385945b105209571e43abbd33b4b65)

src/pybind/mgr/volumes/fs/operations/versions/subvolume_base.py

index 347ef1a62fa7adb2d9004fd52862d495e5b5039a..305b5dca987db8345850f6ff40df1da584eb7a49 100644 (file)
@@ -203,6 +203,13 @@ class SubvolumeBase(object):
         except EarmarkException:
             attrs["earmark"] = ''
 
+        try:
+            attrs["normalization"] = self.fs.getxattr(pathname,
+                                                      'ceph.dir.normalization'
+                                                      ).decode('utf-8')
+        except cephfs.NoData:
+            attrs["normalization"] = None
+
         return attrs
 
     def set_attrs(self, path, attrs):
@@ -294,6 +301,13 @@ class SubvolumeBase(object):
             fs_earmark = CephFSVolumeEarmarking(self.fs, path)
             fs_earmark.set_earmark(earmark)
 
+        normalization = attrs.get("normalization")
+        if normalization is not None:
+            try:
+                self.fs.setxattr(path, "ceph.dir.normalization", normalization.encode('utf-8'), 0)
+            except cephfs.Error as e:
+                raise VolumeException(-e.args[0], e.args[1])
+
     def _resize(self, path, newsize, noshrink):
         try:
             newsize = int(newsize)
@@ -480,6 +494,13 @@ class SubvolumeBase(object):
         except EarmarkException:
             earmark = ''
 
+        try:
+            normalization = self.fs.getxattr(subvolpath,
+                                             'ceph.dir.normalization'
+                                             ).decode('utf-8')
+        except cephfs.NoData:
+            normalization = "none"
+
         subvol_info = {
                 'path': subvolpath,
                 'type': etype.value,
@@ -499,7 +520,9 @@ class SubvolumeBase(object):
                 'pool_namespace': pool_namespace,
                 'features': self.features,
                 'state': self.state.value,
-                'earmark': earmark}
+                'earmark': earmark,
+                'normalization': normalization,
+        }
 
         subvol_src_info = self._get_clone_source()
         if subvol_src_info: