[RFC PATCH RESEND] vfs_ceph: allow mounting a named filesystem

Jeff Layton jlayton at samba.org
Fri Mar 27 16:29:50 UTC 2020


Signed-off-by: Jeff Layton <jlayton at samba.org>
---
 docs-xml/manpages/vfs_ceph.8.xml | 16 ++++++++++++++++
 source3/modules/vfs_ceph.c       | 16 ++++++++++++++++
 source3/wscript                  |  6 ++++++
 3 files changed, 38 insertions(+)

I had a few spare cycles today and went ahead and plumbed in this
support since Marco had asked about it on the ceph-users list.

This builds but is otherwise untested. If it looks reasonable, I can
clean it up and test it out in the near future.

Thanks,
Jeff

diff --git a/docs-xml/manpages/vfs_ceph.8.xml b/docs-xml/manpages/vfs_ceph.8.xml
index 5b32122113a8..6f0001c8f52c 100644
--- a/docs-xml/manpages/vfs_ceph.8.xml
+++ b/docs-xml/manpages/vfs_ceph.8.xml
@@ -127,6 +127,22 @@
 		</listitem>
 		</varlistentry>
 
+		<varlistentry>
+		<term>ceph:fsname = name</term>
+		<listitem>
+		<para>
+			Allows one to explicitly set the filesystem name that
+			should be mounted for export via SMB. This is only
+			supported on Ceph v14 (Mimic) or later. Empty by default
+			which makes samba mount the "default" filesystem in the
+			cluster.
+		</para>
+		<para>
+			Example: ceph:fsname = home
+		</para>
+		</listitem>
+		</varlistentry>
+
 	</variablelist>
 
 </refsect1>
diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c
index 7f4d65d48718..5c0a939390f6 100644
--- a/source3/modules/vfs_ceph.c
+++ b/source3/modules/vfs_ceph.c
@@ -90,6 +90,7 @@ static int cephwrap_connect(struct vfs_handle_struct *handle,  const char *servi
 	int snum = SNUM(handle->conn);
 	const char *conf_file;
 	const char *user_id;
+	const char *fsname;
 
 	if (cmount) {
 		handle->data = cmount; /* We have been here before */
@@ -100,6 +101,7 @@ static int cephwrap_connect(struct vfs_handle_struct *handle,  const char *servi
 	/* if config_file and/or user_id are NULL, ceph will use defaults */
 	conf_file = lp_parm_const_string(snum, "ceph", "config_file", NULL);
 	user_id = lp_parm_const_string(snum, "ceph", "user_id", NULL);
+	fsname = lp_parm_const_string(snum, "ceph", "fsname", NULL);
 
 	DBG_DEBUG("[CEPH] calling: ceph_create\n");
 	ret = ceph_create(&cmount, user_id);
@@ -131,6 +133,20 @@ static int cephwrap_connect(struct vfs_handle_struct *handle,  const char *servi
 		goto err_cm_release;
 	}
 
+#ifdef HAVE_CEPH_SELECT_FILESYSTEM
+	if (fsname) {
+		ret = ceph_select_filesystem(cmount, fsname);
+		if (ret < 0)
+			goto err_cm_release;
+	}
+#else /* HAVE_CEPH_SELECT_FILESYSTEM */
+	if (fsname) {
+		DBG_DEBUG("[CEPH] fsname setting only supported on Ceph Mimic and later\n");
+		ret = -EINVAL;
+		goto err_cm_release;
+	}
+#endif /* HAVE_CEPH_SELECT_FILESYSTEM */
+
 	DBG_DEBUG("[CEPH] calling: ceph_mount\n");
 	ret = ceph_mount(cmount, NULL);
 	if (ret < 0) {
diff --git a/source3/wscript b/source3/wscript
index 48194f261a48..608f4ef4b237 100644
--- a/source3/wscript
+++ b/source3/wscript
@@ -1724,6 +1724,12 @@ main() {
                       or lack of ceph_statx support''')
             conf.undefine('HAVE_CEPH')
 
+        if (conf.CHECK_FUNCS_IN('ceph_select_filesystem', 'cephfs',
+                                headers='cephfs/libcephfs.h')):
+            conf.DEFINE('HAVE_CEPH_SELECT_FILESYSTEM', '1')
+        else:
+            conf.undefine('HAVE_CEPH_SELECT_FILESYSTEM')
+
     if Options.options.with_glusterfs:
         conf.CHECK_CFG(package='glusterfs-api', args='"glusterfs-api >= 4" --cflags --libs',
                        msg='Checking for glusterfs-api >= 4', uselib_store="GFAPI")
-- 
2.25.1




More information about the samba-technical mailing list