Skip to content

Commit 1fc9c44

Browse files
committed
pybind/mgr/volumes: make casesensitive attr uniform in interface
Fixes: https://tracker.ceph.com/issues/70996 Signed-off-by: Patrick Donnelly <[email protected]>
1 parent 358e6e8 commit 1fc9c44

File tree

8 files changed

+25
-25
lines changed

8 files changed

+25
-25
lines changed

doc/cephfs/fs-volumes.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ Use a command of the following form to create a subvolume:
287287

288288
.. prompt:: bash #
289289

290-
ceph fs subvolume create <vol_name> <subvol_name> [--size <size_in_bytes>] [--group_name <subvol_group_name>] [--pool_layout <data_pool_name>] [--uid <uid>] [--gid <gid>] [--mode <octal_mode>] [--namespace-isolated] [--earmark <earmark>] [--normalization <form>] [--case-insensitive]
290+
ceph fs subvolume create <vol_name> <subvol_name> [--size <size_in_bytes>] [--group_name <subvol_group_name>] [--pool_layout <data_pool_name>] [--uid <uid>] [--gid <gid>] [--mode <octal_mode>] [--namespace-isolated] [--earmark <earmark>] [--normalization <form>] [--casesensitive <bool>]
291291

292292

293293
The command succeeds even if the subvolume already exists.
@@ -344,11 +344,11 @@ The valid values for the unicode normalization form are:
344344
To learn more about unicode normalization forms see https://unicode.org/reports/tr15
345345

346346
It's also possible to configure a subvolume for case insensitive access when
347-
the ``--case-insensitive`` option is used. When this option is added, file
347+
the ``--casesensitive=0`` option is used. When this option is added, file
348348
names that only differ in the case of its characters will be mapped to the same
349349
file. The case of the file name used when the file was created is preserved.
350350

351-
.. note:: Setting ``--case-insensitive`` option implicitly enables
351+
.. note:: Setting ``--casesensitive=0`` option implicitly enables
352352
unicode normalization on the subvolume.
353353

354354
Removing a subvolume

qa/tasks/cephfs/test_volumes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2753,7 +2753,7 @@ def test_subvolume_create_without_case_sensitivity(self):
27532753
def test_subvolume_create_with_case_insensitive(self):
27542754
# create subvolume
27552755
subvolume = self._gen_subvol_name()
2756-
self._fs_cmd("subvolume", "create", self.volname, subvolume, "--case-insensitive")
2756+
self._fs_cmd("subvolume", "create", self.volname, subvolume, "--casesensitive=0")
27572757

27582758
# make sure it exists
27592759
subvolpath = self._get_subvolume_path(self.volname, subvolume)

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

Lines changed: 3 additions & 3 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, case_insensitive):
8+
def create_subvol(mgr, fs, vol_spec, group, subvolname, size, isolate_nspace, pool, mode, uid, gid, earmark, normalization, casesensitive):
99
"""
1010
create a subvolume (create a subvolume with the max known version).
1111
@@ -20,11 +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
23+
:param casesensitive: whether to make the subvolume case insensitive or not
2424
:return: None
2525
"""
2626
subvolume = loaded_subvolumes.get_subvolume_object_max(mgr, fs, vol_spec, group, subvolname)
27-
subvolume.create(size, isolate_nspace, pool, mode, uid, gid, earmark, normalization, case_insensitive)
27+
subvolume.create(size, isolate_nspace, pool, mode, uid, gid, earmark, normalization, casesensitive)
2828

2929

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

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ def get_attrs(self, pathname):
212212

213213
try:
214214
casesensitive = self.fs.getxattr(pathname, 'ceph.dir.casesensitive').decode('utf-8')
215-
attrs["case_insensitive"] = casesensitive == "0"
215+
attrs["casesensitive"] = casesensitive == "1"
216216
except cephfs.NoData:
217-
attrs["case_insensitive"] = False
217+
attrs["casesensitive"] = True
218218

219219
return attrs
220220

@@ -314,8 +314,8 @@ def set_attrs(self, path, attrs):
314314
except cephfs.Error as e:
315315
raise VolumeException(-e.args[0], e.args[1])
316316

317-
case_insensitive = attrs.get("case_insensitive")
318-
if case_insensitive:
317+
casesensitive = attrs.get("casesensitive")
318+
if casesensitive is False:
319319
try:
320320
self.fs.setxattr(path, "ceph.dir.casesensitive", "0".encode('utf-8'), 0)
321321
except cephfs.Error as e:
@@ -487,12 +487,12 @@ def info(self):
487487
normalization = "none"
488488

489489
try:
490-
case_insensitive = self.fs.getxattr(subvolpath,
490+
casesensitive = self.fs.getxattr(subvolpath,
491491
'ceph.dir.casesensitive'
492492
).decode('utf-8')
493-
case_insensitive = case_insensitive == "0"
493+
casesensitive = casesensitive == "1"
494494
except cephfs.NoData:
495-
case_insensitive = False
495+
casesensitive = True
496496

497497
return {'path': subvolpath,
498498
'type': etype.value,
@@ -514,7 +514,7 @@ def info(self):
514514
'state': self.state.value,
515515
'earmark': earmark,
516516
'normalization': normalization,
517-
'case_insensitive': case_insensitive,
517+
'casesensitive': casesensitive,
518518
}
519519

520520
def set_user_metadata(self, keyname, value):

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

Lines changed: 2 additions & 2 deletions
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, case_insensitive):
88+
def create(self, size, isolate_nspace, pool, mode, uid, gid, earmark, normalization, casesensitive):
8989
subvolume_type = SubvolumeTypes.TYPE_NORMAL
9090
try:
9191
initial_state = SubvolumeOpSm.get_init_state(subvolume_type)
@@ -106,7 +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,
109+
'casesensitive': casesensitive,
110110
}
111111
self.set_attrs(subvol_path, attrs)
112112

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

Lines changed: 2 additions & 2 deletions
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, case_insensitive):
157+
def create(self, size, isolate_nspace, pool, mode, uid, gid, earmark, normalization, casesensitive):
158158
subvolume_type = SubvolumeTypes.TYPE_NORMAL
159159
try:
160160
initial_state = SubvolumeOpSm.get_init_state(subvolume_type)
@@ -178,7 +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,
181+
'casesensitive': casesensitive,
182182
}
183183
self.set_attrs(subvol_path, attrs)
184184

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +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']
236+
casesensitive = kwargs['casesensitive']
237237

238238
oct_mode = octal_str_to_decimal_int(mode)
239239

240240
try:
241241
create_subvol(
242-
self.mgr, fs_handle, self.volspec, group, subvolname, size, isolate_nspace, pool, oct_mode, uid, gid, earmark, normalization, case_insensitive)
242+
self.mgr, fs_handle, self.volspec, group, subvolname, size, isolate_nspace, pool, oct_mode, uid, gid, earmark, normalization, casesensitive)
243243
except VolumeException as ve:
244244
# kick the purge threads for async removal -- note that this
245245
# assumes that the subvolume is moved to trashcan for cleanup on error.
@@ -259,7 +259,7 @@ def create_subvolume(self, **kwargs):
259259
isolate_nspace = kwargs['namespace_isolated']
260260
earmark = kwargs['earmark'] or '' # if not set, default to empty string --> no earmark
261261
normalization = kwargs['normalization']
262-
case_insensitive = kwargs['case_insensitive']
262+
casesensitive = kwargs['casesensitive']
263263

264264
try:
265265
with open_volume(self, volname) as fs_handle:
@@ -276,7 +276,7 @@ def create_subvolume(self, **kwargs):
276276
'quota': size,
277277
'earmark': earmark,
278278
'normalization': normalization,
279-
'case_insensitive': case_insensitive,
279+
'casesensitive': casesensitive,
280280
}
281281
subvolume.set_attrs(subvolume.path, attrs)
282282
except VolumeException as ve:

src/pybind/mgr/volumes/module.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule):
146146
'name=namespace_isolated,type=CephBool,req=false '
147147
'name=earmark,type=CephString,req=false '
148148
'name=normalization,type=CephChoices,strings=nfd|nfc|nfkd|nfkc,req=false '
149-
'name=case_insensitive,type=CephBool,req=false ',
149+
'name=casesensitive,type=CephBool,req=false ',
150150
'desc': "Create a CephFS subvolume in a volume, and optionally, "
151151
"with a specific size (in bytes), a specific data pool layout, "
152152
"a specific mode, in a specific subvolume group and in separate "
@@ -774,7 +774,7 @@ def _cmd_fs_subvolume_create(self, inbuf, cmd):
774774
namespace_isolated=cmd.get('namespace_isolated', False),
775775
earmark=cmd.get('earmark', None),
776776
normalization=cmd.get('normalization', None),
777-
case_insensitive=cmd.get('case_insensitive', False))
777+
casesensitive=cmd.get('casesensitive', None))
778778

779779
@mgr_cmd_wrap
780780
def _cmd_fs_subvolume_rm(self, inbuf, cmd):

0 commit comments

Comments
 (0)