]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/smb: add support for new ceph vfs module 58994/head
authorJohn Mulligan <jmulligan@redhat.com>
Thu, 1 Aug 2024 20:24:28 +0000 (16:24 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Wed, 4 Sep 2024 14:42:23 +0000 (10:42 -0400)
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 <jmulligan@redhat.com>
src/pybind/mgr/smb/enums.py
src/pybind/mgr/smb/handler.py
src/pybind/mgr/smb/tests/test_smb.py

index f362219221be55a01fe5334fb9d076e15f769f0c..dea45f951f831ca5e3ae43bc7bf3411b2d58c657 100644 (file)
@@ -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):
index b2285eef5753828a2ce09ef433cb788927ba95a8..c333be1e9489042d25b94b0f5908b71e13a0e700 100644 (file)
@@ -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',
index 547e6c712bce4c4f084b0ac21b558dcf0c12e347..86a2310a4de9827ca5d81c41934faaf015f37f2b 100644 (file)
@@ -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',
                 },
             },
         },