Skip to content

Commit 87bb089

Browse files
committed
pybind/mgr: add option to set case sensitivity to a subvolume
Add an option to explicitly set the case sensitivity of a CephFS subvolume. Signed-off-by: Xavi Hernandez <[email protected]>
1 parent 66caf74 commit 87bb089

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

src/pybind/mgr/volumes/fs/operations/subvolume.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from .template import SubvolumeOpType
66
from .versions import loaded_subvolumes
77

8-
def create_subvol(mgr, fs, vol_spec, group, subvolname, size, isolate_nspace, pool, mode, uid, gid, earmark, normalization):
8+
def create_subvol(mgr, fs, vol_spec, group, subvolname, size, isolate_nspace, pool, mode, uid, gid, earmark, normalization, case_insensitive):
99
"""
1010
create a subvolume (create a subvolume with the max known version).
1111
@@ -20,10 +20,11 @@ def create_subvol(mgr, fs, vol_spec, group, subvolname, size, isolate_nspace, po
2020
:param gid: the group identifier
2121
:param earmark: metadata string to identify if subvolume is associated with nfs/smb
2222
:param normalization: the unicode normalization form to use (nfd, nfc, nfkd or nfkc)
23+
:param case_insensitive: whether to make the subvolume case insensitive or not
2324
:return: None
2425
"""
2526
subvolume = loaded_subvolumes.get_subvolume_object_max(mgr, fs, vol_spec, group, subvolname)
26-
subvolume.create(size, isolate_nspace, pool, mode, uid, gid, earmark, normalization)
27+
subvolume.create(size, isolate_nspace, pool, mode, uid, gid, earmark, normalization, case_insensitive)
2728

2829

2930
def create_clone(mgr, fs, vol_spec, group, subvolname, pool, source_volume, source_subvolume, snapname):

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def snapshot_data_path(self, snapname):
8585
""" Path to user data directory within a subvolume snapshot named 'snapname' """
8686
return self.snapshot_path(snapname)
8787

88-
def create(self, size, isolate_nspace, pool, mode, uid, gid, earmark, normalization):
88+
def create(self, size, isolate_nspace, pool, mode, uid, gid, earmark, normalization, case_insensitive):
8989
subvolume_type = SubvolumeTypes.TYPE_NORMAL
9090
try:
9191
initial_state = SubvolumeOpSm.get_init_state(subvolume_type)
@@ -106,6 +106,7 @@ def create(self, size, isolate_nspace, pool, mode, uid, gid, earmark, normalizat
106106
'quota': size,
107107
'earmark': earmark,
108108
'normalization': normalization,
109+
'case_insensitive': case_insensitive,
109110
}
110111
self.set_attrs(subvol_path, attrs)
111112

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def _set_incarnation_metadata(self, subvolume_type, qpath, initial_state):
154154
self.metadata_mgr.update_global_section(MetadataManager.GLOBAL_META_KEY_PATH, qpath)
155155
self.metadata_mgr.update_global_section(MetadataManager.GLOBAL_META_KEY_STATE, initial_state.value)
156156

157-
def create(self, size, isolate_nspace, pool, mode, uid, gid, earmark, normalization):
157+
def create(self, size, isolate_nspace, pool, mode, uid, gid, earmark, normalization, case_insensitive):
158158
subvolume_type = SubvolumeTypes.TYPE_NORMAL
159159
try:
160160
initial_state = SubvolumeOpSm.get_init_state(subvolume_type)
@@ -178,6 +178,7 @@ def create(self, size, isolate_nspace, pool, mode, uid, gid, earmark, normalizat
178178
'quota': size,
179179
'earmark': earmark,
180180
'normalization': normalization,
181+
'case_insensitive': case_insensitive,
181182
}
182183
self.set_attrs(subvol_path, attrs)
183184

src/pybind/mgr/volumes/fs/volume.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,13 @@ def _create_subvolume(self, fs_handle, volname, group, subvolname, **kwargs):
233233
isolate_nspace = kwargs['namespace_isolated']
234234
earmark = kwargs['earmark'] or '' # if not set, default to empty string --> no earmark
235235
normalization = kwargs['normalization']
236+
case_insensitive = kwargs['case_insensitive']
236237

237238
oct_mode = octal_str_to_decimal_int(mode)
238239

239240
try:
240241
create_subvol(
241-
self.mgr, fs_handle, self.volspec, group, subvolname, size, isolate_nspace, pool, oct_mode, uid, gid, earmark, normalization)
242+
self.mgr, fs_handle, self.volspec, group, subvolname, size, isolate_nspace, pool, oct_mode, uid, gid, earmark, normalization, case_insensitive)
242243
except VolumeException as ve:
243244
# kick the purge threads for async removal -- note that this
244245
# assumes that the subvolume is moved to trashcan for cleanup on error.
@@ -258,6 +259,7 @@ def create_subvolume(self, **kwargs):
258259
isolate_nspace = kwargs['namespace_isolated']
259260
earmark = kwargs['earmark'] or '' # if not set, default to empty string --> no earmark
260261
normalization = kwargs['normalization']
262+
case_insensitive = kwargs['case_insensitive']
261263

262264
try:
263265
with open_volume(self, volname) as fs_handle:
@@ -274,6 +276,7 @@ def create_subvolume(self, **kwargs):
274276
'quota': size,
275277
'earmark': earmark,
276278
'normalization': normalization,
279+
'case_insensitive': case_insensitive,
277280
}
278281
subvolume.set_attrs(subvolume.path, attrs)
279282
except VolumeException as ve:

src/pybind/mgr/volumes/module.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule):
145145
'name=mode,type=CephString,req=false '
146146
'name=namespace_isolated,type=CephBool,req=false '
147147
'name=earmark,type=CephString,req=false '
148-
'name=normalization,type=CephChoices,strings=nfd|nfc|nfkd|nfkc,req=false ',
148+
'name=normalization,type=CephChoices,strings=nfd|nfc|nfkd|nfkc,req=false '
149+
'name=case_insensitive,type=CephBool,req=false ',
149150
'desc': "Create a CephFS subvolume in a volume, and optionally, "
150151
"with a specific size (in bytes), a specific data pool layout, "
151152
"a specific mode, in a specific subvolume group and in separate "
@@ -761,7 +762,8 @@ def _cmd_fs_subvolume_create(self, inbuf, cmd):
761762
mode=cmd.get('mode', '755'),
762763
namespace_isolated=cmd.get('namespace_isolated', False),
763764
earmark=cmd.get('earmark', None),
764-
normalization=cmd.get('normalization', None))
765+
normalization=cmd.get('normalization', None),
766+
case_insensitive=cmd.get('case_insensitive', False))
765767

766768
@mgr_cmd_wrap
767769
def _cmd_fs_subvolume_rm(self, inbuf, cmd):

0 commit comments

Comments
 (0)