From 1fc9c44307aa1bce6ebd42e83032c92a1d6cf634 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Mon, 21 Apr 2025 13:19:59 -0400 Subject: [PATCH] pybind/mgr/volumes: make casesensitive attr uniform in interface Fixes: https://tracker.ceph.com/issues/70996 Signed-off-by: Patrick Donnelly --- doc/cephfs/fs-volumes.rst | 6 +++--- qa/tasks/cephfs/test_volumes.py | 2 +- .../mgr/volumes/fs/operations/subvolume.py | 6 +++--- .../fs/operations/versions/subvolume_base.py | 16 ++++++++-------- .../fs/operations/versions/subvolume_v1.py | 4 ++-- .../fs/operations/versions/subvolume_v2.py | 4 ++-- src/pybind/mgr/volumes/fs/volume.py | 8 ++++---- src/pybind/mgr/volumes/module.py | 4 ++-- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/doc/cephfs/fs-volumes.rst b/doc/cephfs/fs-volumes.rst index 8ef4357e84455..3747d8eb083bc 100644 --- a/doc/cephfs/fs-volumes.rst +++ b/doc/cephfs/fs-volumes.rst @@ -287,7 +287,7 @@ Use a command of the following form to create a subvolume: .. prompt:: bash # - ceph fs subvolume create [--size ] [--group_name ] [--pool_layout ] [--uid ] [--gid ] [--mode ] [--namespace-isolated] [--earmark ] [--normalization
] [--case-insensitive] + ceph fs subvolume create [--size ] [--group_name ] [--pool_layout ] [--uid ] [--gid ] [--mode ] [--namespace-isolated] [--earmark ] [--normalization ] [--casesensitive ] The command succeeds even if the subvolume already exists. @@ -344,11 +344,11 @@ The valid values for the unicode normalization form are: To learn more about unicode normalization forms see https://unicode.org/reports/tr15 It's also possible to configure a subvolume for case insensitive access when -the ``--case-insensitive`` option is used. When this option is added, file +the ``--casesensitive=0`` option is used. When this option is added, file names that only differ in the case of its characters will be mapped to the same file. The case of the file name used when the file was created is preserved. -.. note:: Setting ``--case-insensitive`` option implicitly enables +.. note:: Setting ``--casesensitive=0`` option implicitly enables unicode normalization on the subvolume. Removing a subvolume diff --git a/qa/tasks/cephfs/test_volumes.py b/qa/tasks/cephfs/test_volumes.py index 865fe9db2568d..14ef79a329b87 100644 --- a/qa/tasks/cephfs/test_volumes.py +++ b/qa/tasks/cephfs/test_volumes.py @@ -2753,7 +2753,7 @@ class TestSubvolumes(TestVolumesHelper): def test_subvolume_create_with_case_insensitive(self): # create subvolume subvolume = self._gen_subvol_name() - self._fs_cmd("subvolume", "create", self.volname, subvolume, "--case-insensitive") + self._fs_cmd("subvolume", "create", self.volname, subvolume, "--casesensitive=0") # make sure it exists subvolpath = self._get_subvolume_path(self.volname, subvolume) diff --git a/src/pybind/mgr/volumes/fs/operations/subvolume.py b/src/pybind/mgr/volumes/fs/operations/subvolume.py index 1656d7884d1fd..3c8d2241afb71 100644 --- a/src/pybind/mgr/volumes/fs/operations/subvolume.py +++ b/src/pybind/mgr/volumes/fs/operations/subvolume.py @@ -5,7 +5,7 @@ from .group import open_group from .template import SubvolumeOpType from .versions import loaded_subvolumes -def create_subvol(mgr, fs, vol_spec, group, subvolname, size, isolate_nspace, pool, mode, uid, gid, earmark, normalization, case_insensitive): +def create_subvol(mgr, fs, vol_spec, group, subvolname, size, isolate_nspace, pool, mode, uid, gid, earmark, normalization, casesensitive): """ create a subvolume (create a subvolume with the max known version). @@ -20,11 +20,11 @@ def create_subvol(mgr, fs, vol_spec, group, subvolname, size, isolate_nspace, po :param gid: the group identifier :param earmark: metadata string to identify if subvolume is associated with nfs/smb :param normalization: the unicode normalization form to use (nfd, nfc, nfkd or nfkc) - :param case_insensitive: whether to make the subvolume case insensitive or not + :param casesensitive: whether to make the subvolume case insensitive or not :return: None """ subvolume = loaded_subvolumes.get_subvolume_object_max(mgr, fs, vol_spec, group, subvolname) - subvolume.create(size, isolate_nspace, pool, mode, uid, gid, earmark, normalization, case_insensitive) + subvolume.create(size, isolate_nspace, pool, mode, uid, gid, earmark, normalization, casesensitive) def create_clone(mgr, fs, vol_spec, group, subvolname, pool, source_volume, source_subvolume, snapname): 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 4627095e960ba..47cef092aad79 100644 --- a/src/pybind/mgr/volumes/fs/operations/versions/subvolume_base.py +++ b/src/pybind/mgr/volumes/fs/operations/versions/subvolume_base.py @@ -212,9 +212,9 @@ class SubvolumeBase(object): try: casesensitive = self.fs.getxattr(pathname, 'ceph.dir.casesensitive').decode('utf-8') - attrs["case_insensitive"] = casesensitive == "0" + attrs["casesensitive"] = casesensitive == "1" except cephfs.NoData: - attrs["case_insensitive"] = False + attrs["casesensitive"] = True return attrs @@ -314,8 +314,8 @@ class SubvolumeBase(object): except cephfs.Error as e: raise VolumeException(-e.args[0], e.args[1]) - case_insensitive = attrs.get("case_insensitive") - if case_insensitive: + casesensitive = attrs.get("casesensitive") + if casesensitive is False: try: self.fs.setxattr(path, "ceph.dir.casesensitive", "0".encode('utf-8'), 0) except cephfs.Error as e: @@ -487,12 +487,12 @@ class SubvolumeBase(object): normalization = "none" try: - case_insensitive = self.fs.getxattr(subvolpath, + casesensitive = self.fs.getxattr(subvolpath, 'ceph.dir.casesensitive' ).decode('utf-8') - case_insensitive = case_insensitive == "0" + casesensitive = casesensitive == "1" except cephfs.NoData: - case_insensitive = False + casesensitive = True return {'path': subvolpath, 'type': etype.value, @@ -514,7 +514,7 @@ class SubvolumeBase(object): 'state': self.state.value, 'earmark': earmark, 'normalization': normalization, - 'case_insensitive': case_insensitive, + 'casesensitive': casesensitive, } def set_user_metadata(self, keyname, value): diff --git a/src/pybind/mgr/volumes/fs/operations/versions/subvolume_v1.py b/src/pybind/mgr/volumes/fs/operations/versions/subvolume_v1.py index e04e6eb51c754..a4aceb3a76754 100644 --- a/src/pybind/mgr/volumes/fs/operations/versions/subvolume_v1.py +++ b/src/pybind/mgr/volumes/fs/operations/versions/subvolume_v1.py @@ -85,7 +85,7 @@ class SubvolumeV1(SubvolumeBase, SubvolumeTemplate): """ Path to user data directory within a subvolume snapshot named 'snapname' """ return self.snapshot_path(snapname) - def create(self, size, isolate_nspace, pool, mode, uid, gid, earmark, normalization, case_insensitive): + def create(self, size, isolate_nspace, pool, mode, uid, gid, earmark, normalization, casesensitive): subvolume_type = SubvolumeTypes.TYPE_NORMAL try: initial_state = SubvolumeOpSm.get_init_state(subvolume_type) @@ -106,7 +106,7 @@ class SubvolumeV1(SubvolumeBase, SubvolumeTemplate): 'quota': size, 'earmark': earmark, 'normalization': normalization, - 'case_insensitive': case_insensitive, + 'casesensitive': casesensitive, } self.set_attrs(subvol_path, attrs) diff --git a/src/pybind/mgr/volumes/fs/operations/versions/subvolume_v2.py b/src/pybind/mgr/volumes/fs/operations/versions/subvolume_v2.py index bbc25d63ec3bd..a67c971b8dbf8 100644 --- a/src/pybind/mgr/volumes/fs/operations/versions/subvolume_v2.py +++ b/src/pybind/mgr/volumes/fs/operations/versions/subvolume_v2.py @@ -154,7 +154,7 @@ class SubvolumeV2(SubvolumeV1): self.metadata_mgr.update_global_section(MetadataManager.GLOBAL_META_KEY_PATH, qpath) self.metadata_mgr.update_global_section(MetadataManager.GLOBAL_META_KEY_STATE, initial_state.value) - def create(self, size, isolate_nspace, pool, mode, uid, gid, earmark, normalization, case_insensitive): + def create(self, size, isolate_nspace, pool, mode, uid, gid, earmark, normalization, casesensitive): subvolume_type = SubvolumeTypes.TYPE_NORMAL try: initial_state = SubvolumeOpSm.get_init_state(subvolume_type) @@ -178,7 +178,7 @@ class SubvolumeV2(SubvolumeV1): 'quota': size, 'earmark': earmark, 'normalization': normalization, - 'case_insensitive': case_insensitive, + 'casesensitive': casesensitive, } self.set_attrs(subvol_path, attrs) diff --git a/src/pybind/mgr/volumes/fs/volume.py b/src/pybind/mgr/volumes/fs/volume.py index 4fa62201fc58e..0079212c899f2 100644 --- a/src/pybind/mgr/volumes/fs/volume.py +++ b/src/pybind/mgr/volumes/fs/volume.py @@ -233,13 +233,13 @@ class VolumeClient(CephfsClient["Module"]): isolate_nspace = kwargs['namespace_isolated'] earmark = kwargs['earmark'] or '' # if not set, default to empty string --> no earmark normalization = kwargs['normalization'] - case_insensitive = kwargs['case_insensitive'] + casesensitive = kwargs['casesensitive'] oct_mode = octal_str_to_decimal_int(mode) try: create_subvol( - self.mgr, fs_handle, self.volspec, group, subvolname, size, isolate_nspace, pool, oct_mode, uid, gid, earmark, normalization, case_insensitive) + self.mgr, fs_handle, self.volspec, group, subvolname, size, isolate_nspace, pool, oct_mode, uid, gid, earmark, normalization, casesensitive) except VolumeException as ve: # kick the purge threads for async removal -- note that this # assumes that the subvolume is moved to trashcan for cleanup on error. @@ -259,7 +259,7 @@ class VolumeClient(CephfsClient["Module"]): isolate_nspace = kwargs['namespace_isolated'] earmark = kwargs['earmark'] or '' # if not set, default to empty string --> no earmark normalization = kwargs['normalization'] - case_insensitive = kwargs['case_insensitive'] + casesensitive = kwargs['casesensitive'] try: with open_volume(self, volname) as fs_handle: @@ -276,7 +276,7 @@ class VolumeClient(CephfsClient["Module"]): 'quota': size, 'earmark': earmark, 'normalization': normalization, - 'case_insensitive': case_insensitive, + 'casesensitive': casesensitive, } subvolume.set_attrs(subvolume.path, attrs) except VolumeException as ve: diff --git a/src/pybind/mgr/volumes/module.py b/src/pybind/mgr/volumes/module.py index a8e69b3539cf9..e91c6bb504ce5 100644 --- a/src/pybind/mgr/volumes/module.py +++ b/src/pybind/mgr/volumes/module.py @@ -146,7 +146,7 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): 'name=namespace_isolated,type=CephBool,req=false ' 'name=earmark,type=CephString,req=false ' 'name=normalization,type=CephChoices,strings=nfd|nfc|nfkd|nfkc,req=false ' - 'name=case_insensitive,type=CephBool,req=false ', + 'name=casesensitive,type=CephBool,req=false ', 'desc': "Create a CephFS subvolume in a volume, and optionally, " "with a specific size (in bytes), a specific data pool layout, " "a specific mode, in a specific subvolume group and in separate " @@ -774,7 +774,7 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): namespace_isolated=cmd.get('namespace_isolated', False), earmark=cmd.get('earmark', None), normalization=cmd.get('normalization', None), - case_insensitive=cmd.get('case_insensitive', False)) + casesensitive=cmd.get('casesensitive', None)) @mgr_cmd_wrap def _cmd_fs_subvolume_rm(self, inbuf, cmd): -- 2.39.5