]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr: add option to set case sensitivity to a subvolume
authorXavi Hernandez <xhernandez@gmail.com>
Tue, 4 Mar 2025 16:05:44 +0000 (17:05 +0100)
committerXavi Hernandez <xhernandez@gmail.com>
Tue, 25 Mar 2025 13:45:55 +0000 (14:45 +0100)
Add an option to explicitly set the case sensitivity of a CephFS
subvolume.

Signed-off-by: Xavi Hernandez <xhernandez@gmail.com>
src/pybind/mgr/volumes/fs/operations/subvolume.py
src/pybind/mgr/volumes/fs/operations/versions/subvolume_v1.py
src/pybind/mgr/volumes/fs/operations/versions/subvolume_v2.py
src/pybind/mgr/volumes/fs/volume.py
src/pybind/mgr/volumes/module.py

index bac51a4289502bf0a2d6e95a560d356898c48379..1656d7884d1fd16fd76874d6cf79a4803403feaa 100644 (file)
@@ -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):
+def create_subvol(mgr, fs, vol_spec, group, subvolname, size, isolate_nspace, pool, mode, uid, gid, earmark, normalization, case_insensitive):
     """
     create a subvolume (create a subvolume with the max known version).
 
@@ -20,10 +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
     :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)
+    subvolume.create(size, isolate_nspace, pool, mode, uid, gid, earmark, normalization, case_insensitive)
 
 
 def create_clone(mgr, fs, vol_spec, group, subvolname, pool, source_volume, source_subvolume, snapname):
index 019c2b878a9c687952005c7e70a9d7a1bf825d9e..e04e6eb51c754f7836f1336760ac272f9ffa2432 100644 (file)
@@ -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):
+    def create(self, size, isolate_nspace, pool, mode, uid, gid, earmark, normalization, case_insensitive):
         subvolume_type = SubvolumeTypes.TYPE_NORMAL
         try:
             initial_state = SubvolumeOpSm.get_init_state(subvolume_type)
@@ -106,6 +106,7 @@ class SubvolumeV1(SubvolumeBase, SubvolumeTemplate):
                 'quota': size,
                 'earmark': earmark,
                 'normalization': normalization,
+                'case_insensitive': case_insensitive,
             }
             self.set_attrs(subvol_path, attrs)
 
index 2c4d493ec2cbfd7c694e84e09df85fb0c895cb41..85d260136aca74ac6e1b6e0e132a4e8914b062d3 100644 (file)
@@ -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):
+    def create(self, size, isolate_nspace, pool, mode, uid, gid, earmark, normalization, case_insensitive):
         subvolume_type = SubvolumeTypes.TYPE_NORMAL
         try:
             initial_state = SubvolumeOpSm.get_init_state(subvolume_type)
@@ -178,6 +178,7 @@ class SubvolumeV2(SubvolumeV1):
                 'quota': size,
                 'earmark': earmark,
                 'normalization': normalization,
+                'case_insensitive': case_insensitive,
             }
             self.set_attrs(subvol_path, attrs)
 
index 0d09333463e2e71caf059644f7f5a015be508e23..5a8a6111bb0887874cc1ff6d909adc1987416cdd 100644 (file)
@@ -233,12 +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']
 
         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)
+                self.mgr, fs_handle, self.volspec, group, subvolname, size, isolate_nspace, pool, oct_mode, uid, gid, earmark, normalization, case_insensitive)
         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.
@@ -258,6 +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']
 
         try:
             with open_volume(self, volname) as fs_handle:
@@ -274,6 +276,7 @@ class VolumeClient(CephfsClient["Module"]):
                                 'quota': size,
                                 'earmark': earmark,
                                 'normalization': normalization,
+                                'case_insensitive': case_insensitive,
                             }
                             subvolume.set_attrs(subvolume.path, attrs)
                     except VolumeException as ve:
index 9281a925b6e999a7ab5c0d189292788175a0dff1..212870b59440db2854352184cfa360daa9b7fe0c 100644 (file)
@@ -145,7 +145,8 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule):
                    'name=mode,type=CephString,req=false '
                    '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=normalization,type=CephChoices,strings=nfd|nfc|nfkd|nfkc,req=false '
+                   'name=case_insensitive,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 "
@@ -761,7 +762,8 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule):
                                         mode=cmd.get('mode', '755'),
                                         namespace_isolated=cmd.get('namespace_isolated', False),
                                         earmark=cmd.get('earmark', None),
-                                        normalization=cmd.get('normalization', None))
+                                        normalization=cmd.get('normalization', None),
+                                        case_insensitive=cmd.get('case_insensitive', False))
 
     @mgr_cmd_wrap
     def _cmd_fs_subvolume_rm(self, inbuf, cmd):