]> git.apps.os.sepia.ceph.com Git - ceph.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)
committerXavi Hernandez <xhernandez@gmail.com>
Tue, 25 Mar 2025 13:45:54 +0000 (14:45 +0100)
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>
src/pybind/mgr/volumes/fs/operations/versions/subvolume_base.py

index bffaca156cf79ca8f1fe5b7b902c90f6f297781a..c360a28bcdf9a3551be9b3d2d5fc83b3574aba39 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)
@@ -452,6 +466,13 @@ class SubvolumeBase(object):
         except EarmarkException:
             earmark = ''
 
+        try:
+            normalization = self.fs.getxattr(subvolpath,
+                                             'ceph.dir.normalization'
+                                             ).decode('utf-8')
+        except cephfs.NoData:
+            normalization = "none"
+
         return {'path': subvolpath,
                 'type': etype.value,
                 'uid': int(st["uid"]),
@@ -470,7 +491,9 @@ class SubvolumeBase(object):
                 'pool_namespace': pool_namespace,
                 'features': self.features,
                 'state': self.state.value,
-                'earmark': earmark}
+                'earmark': earmark,
+                'normalization': normalization,
+        }
 
     def set_user_metadata(self, keyname, value):
         try: