From: John Mulligan Date: Thu, 1 Aug 2024 20:24:28 +0000 (-0400) Subject: mgr/smb: add support for new ceph vfs module X-Git-Tag: v20.0.0~1094^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=190623575e8d0c912f48ca72e7788ebd900b1c3a;p=ceph.git mgr/smb: add support for new ceph vfs module Add support for using the new ceph vfs module in Samba (aka ceph_new) to the mgr module, and even default to using it for the samba-vfs provider. Add two new "sub-providers" one for forcing the old vfs module "samba-vfs/classic" and one, "samba-vfs/new", for forcing the new module regardless of what the default for "samba-vfs" is. Signed-off-by: John Mulligan --- diff --git a/src/pybind/mgr/smb/enums.py b/src/pybind/mgr/smb/enums.py index f362219221be5..dea45f951f831 100644 --- a/src/pybind/mgr/smb/enums.py +++ b/src/pybind/mgr/smb/enums.py @@ -16,6 +16,23 @@ else: # pragma: no cover class CephFSStorageProvider(_StrEnum): KERNEL_MOUNT = 'kcephfs' SAMBA_VFS = 'samba-vfs' + SAMBA_VFS_CLASSIC = 'samba-vfs/classic' + SAMBA_VFS_NEW = 'samba-vfs/new' + + def expand(self) -> 'CephFSStorageProvider': + """Expand abbreviated/default values into the full/expanded form.""" + if self == self.SAMBA_VFS: + # mypy gets confused by enums + return self.__class__(self.SAMBA_VFS_NEW) + return self + + def is_vfs(self) -> bool: + """Return true if value is a samba vfs provider.""" + return self in { + self.SAMBA_VFS, + self.SAMBA_VFS_CLASSIC, + self.SAMBA_VFS_NEW, + } class SubSystem(_StrEnum): diff --git a/src/pybind/mgr/smb/handler.py b/src/pybind/mgr/smb/handler.py index b2285eef57538..c333be1e94890 100644 --- a/src/pybind/mgr/smb/handler.py +++ b/src/pybind/mgr/smb/handler.py @@ -1025,7 +1025,7 @@ def _generate_share( share: resources.Share, resolver: PathResolver, cephx_entity: str ) -> Dict[str, Dict[str, str]]: assert share.cephfs is not None - assert share.cephfs.provider == CephFSStorageProvider.SAMBA_VFS + assert share.cephfs.provider.is_vfs(), "not a vfs provider" assert cephx_entity, "cephx entity name missing" # very annoyingly, samba's ceph module absolutely must NOT have the # "client." bit in front. JJM has been tripped up by this multiple times - @@ -1040,15 +1040,24 @@ def _generate_share( share.cephfs.subvolume, share.cephfs.path, ) + try: + ceph_vfs = { + CephFSStorageProvider.SAMBA_VFS_CLASSIC: 'ceph', + CephFSStorageProvider.SAMBA_VFS_NEW: 'ceph_new', + }[share.checked_cephfs.provider.expand()] + except KeyError: + raise ValueError( + f'unsupported provider: {share.checked_cephfs.provider}' + ) cfg = { # smb.conf options 'options': { 'path': path, - "vfs objects": "acl_xattr ceph", + "vfs objects": f"acl_xattr {ceph_vfs}", 'acl_xattr:security_acl_name': 'user.NTACL', - 'ceph:config_file': '/etc/ceph/ceph.conf', - 'ceph:filesystem': share.cephfs.volume, - 'ceph:user_id': cephx_entity, + f'{ceph_vfs}:config_file': '/etc/ceph/ceph.conf', + f'{ceph_vfs}:filesystem': share.cephfs.volume, + f'{ceph_vfs}:user_id': cephx_entity, 'read only': ynbool(share.readonly), 'browseable': ynbool(share.browseable), 'kernel share modes': 'no', diff --git a/src/pybind/mgr/smb/tests/test_smb.py b/src/pybind/mgr/smb/tests/test_smb.py index 547e6c712bce4..86a2310a4de98 100644 --- a/src/pybind/mgr/smb/tests/test_smb.py +++ b/src/pybind/mgr/smb/tests/test_smb.py @@ -431,11 +431,11 @@ def test_share_dump_config(tmodule): 'browseable': 'Yes', 'kernel share modes': 'no', 'x:ceph:id': 'foo.s1', - 'vfs objects': 'acl_xattr ceph', + 'vfs objects': 'acl_xattr ceph_new', 'acl_xattr:security_acl_name': 'user.NTACL', - 'ceph:config_file': '/etc/ceph/ceph.conf', - 'ceph:filesystem': 'cephfs', - 'ceph:user_id': 'smb.fs.cluster.foo', + 'ceph_new:config_file': '/etc/ceph/ceph.conf', + 'ceph_new:filesystem': 'cephfs', + 'ceph_new:user_id': 'smb.fs.cluster.foo', }, }, 'Ess Two': { @@ -445,11 +445,11 @@ def test_share_dump_config(tmodule): 'browseable': 'Yes', 'kernel share modes': 'no', 'x:ceph:id': 'foo.stwo', - 'vfs objects': 'acl_xattr ceph', + 'vfs objects': 'acl_xattr ceph_new', 'acl_xattr:security_acl_name': 'user.NTACL', - 'ceph:config_file': '/etc/ceph/ceph.conf', - 'ceph:filesystem': 'cephfs', - 'ceph:user_id': 'smb.fs.cluster.foo', + 'ceph_new:config_file': '/etc/ceph/ceph.conf', + 'ceph_new:filesystem': 'cephfs', + 'ceph_new:user_id': 'smb.fs.cluster.foo', }, }, },