From: Xavi Hernandez Date: Wed, 19 Mar 2025 11:59:59 +0000 (+0100) Subject: pybind/mgr: create normalization xattr in subvolumes X-Git-Tag: testing/wip-jcollin-testing-20260218.004834-squid^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=633ddc09623678d2e453162190cd95efc83d5538;p=ceph-ci.git pybind/mgr: create normalization xattr in subvolumes When a new subvolume is created, optionally set the ceph.dir.normalization xattr to the root directory. Signed-off-by: Xavi Hernandez (cherry picked from commit 4a414a57af385945b105209571e43abbd33b4b65) --- diff --git a/src/pybind/mgr/volumes/fs/operations/versions/subvolume_base.py b/src/pybind/mgr/volumes/fs/operations/versions/subvolume_base.py index 347ef1a62fa..305b5dca987 100644 --- a/src/pybind/mgr/volumes/fs/operations/versions/subvolume_base.py +++ b/src/pybind/mgr/volumes/fs/operations/versions/subvolume_base.py @@ -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: