From c93daa6e5b0a42846bd41f37e1dff7c39c97009f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Deschner?= Date: Thu, 17 Jan 2019 15:21:07 +0100 Subject: [PATCH 1/2] s3-vfs: add glusterfs_fuse vfs module. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This module only implements the get_real_filename function by accessing a distinct extended attribute that is available over a glusterfs fuse mount. By implementing this vfs function users of a glusterfs fuse mount achieve a much better performance in create based workloads where samba then can avoid trying multiple case folding options to detect the real filename. Patch is based on an initial patch provided by Poornima G BUG: https://bugzilla.samba.org/show_bug.cgi?id=13774 Guenther Signed-off-by: Günther Deschner Reviewed-by: Ralph Boehme Autobuild-User(master): Günther Deschner Autobuild-Date(master): Tue Jan 22 18:37:56 CET 2019 on sn-devel-144 (cherry picked from commit adffe0dcf002aa4721dc7897261895e3486d5271) --- docs-xml/manpages/vfs_glusterfs_fuse.8.xml | 103 +++++++++++++++++++++ docs-xml/wscript_build | 1 + source3/modules/vfs_glusterfs_fuse.c | 71 ++++++++++++++ source3/modules/wscript_build | 8 ++ source3/wscript | 1 + 5 files changed, 184 insertions(+) create mode 100644 docs-xml/manpages/vfs_glusterfs_fuse.8.xml create mode 100644 source3/modules/vfs_glusterfs_fuse.c diff --git a/docs-xml/manpages/vfs_glusterfs_fuse.8.xml b/docs-xml/manpages/vfs_glusterfs_fuse.8.xml new file mode 100644 index 00000000000..b9f7f42c6f2 --- /dev/null +++ b/docs-xml/manpages/vfs_glusterfs_fuse.8.xml @@ -0,0 +1,103 @@ + + + + + + vfs_glusterfs_fuse + 8 + Samba + System Administration tools + &doc.version; + + + + + vfs_glusterfs_fuse + + Utilize features provided by GlusterFS + + + + + + vfs objects = glusterfs_fuse + + + + + DESCRIPTION + + This VFS module is part of the + samba + 8 suite. + + + GlusterFS + (http://www.gluster.org) + is an Open Source clustered file system capable of scaling to + several peta-bytes. With its FUSE based native client, + GlusterFS is available as a POSIX compliant file system and can + hence be shared by Samba without additional steps. + + + + The vfs_glusterfs_fuse VFS module provides an enhanced way + to access a Gluster filesystem using a Gluster FUSE mount. It provides support + for the get_real_filename VFS call which enhances file access performance + by avoiding multiple expensive case folding lookup calls to detect the appropriate + case of an exisiting filename. + + + + This module can be combined with other modules, but it + should be the last module in the vfs objects + list. Modules added to this list to the right of the glusterfs + entry may not have any effect at all. + + + + + CONFIGURATION + + + A basic configuration looks like this. + + + + + glusterfs_fuse + /absolute/path_of_fusemount + + + + Note that vfs_glusterfs_fuse requires a Gluster mount. For accessing glusterfs directly + over the GFAPI library please use the vfs_glusterfs module. + + + + + OPTIONS + + This module does currently have no further options. + + + + + VERSION + + + This man page is part of version &doc.version; of the Samba suite. + + + + + AUTHOR + + The original Samba software and related utilities + were created by Andrew Tridgell. Samba is now developed + by the Samba Team as an Open Source project similar + to the way the Linux kernel is developed. + + + + diff --git a/docs-xml/wscript_build b/docs-xml/wscript_build index 1b4335cbb5d..86600ae4a82 100644 --- a/docs-xml/wscript_build +++ b/docs-xml/wscript_build @@ -82,6 +82,7 @@ vfs_module_manpages = ['vfs_acl_tdb', 'vfs_fruit', 'vfs_full_audit', 'vfs_glusterfs', + 'vfs_glusterfs_fuse', 'vfs_gpfs', 'vfs_linux_xfs_sgid', 'vfs_media_harmony', diff --git a/source3/modules/vfs_glusterfs_fuse.c b/source3/modules/vfs_glusterfs_fuse.c new file mode 100644 index 00000000000..64c1b0035c1 --- /dev/null +++ b/source3/modules/vfs_glusterfs_fuse.c @@ -0,0 +1,71 @@ +/* + Unix SMB/CIFS implementation. + + Copyright (c) 2019 Guenther Deschner + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "includes.h" +#include "smbd/smbd.h" +#include "system/filesys.h" + +static int vfs_gluster_fuse_get_real_filename(struct vfs_handle_struct *handle, + const char *path, + const char *name, + TALLOC_CTX *mem_ctx, + char **_found_name) +{ + int ret; + char key_buf[NAME_MAX + 64]; + char val_buf[NAME_MAX + 1]; + char *found_name = NULL; + + if (strlen(name) >= NAME_MAX) { + errno = ENAMETOOLONG; + return -1; + } + + snprintf(key_buf, NAME_MAX + 64, + "glusterfs.get_real_filename:%s", name); + + ret = getxattr(path, key_buf, val_buf, NAME_MAX + 1); + if (ret == -1) { + if (errno == ENODATA) { + errno = EOPNOTSUPP; + } + return -1; + } + + found_name = talloc_strdup(mem_ctx, val_buf); + if (found_name == NULL) { + errno = ENOMEM; + return -1; + } + *_found_name = found_name; + return 0; +} + +struct vfs_fn_pointers glusterfs_fuse_fns = { + + /* File Operations */ + .get_real_filename_fn = vfs_gluster_fuse_get_real_filename, +}; + +static_decl_vfs; +NTSTATUS vfs_glusterfs_fuse_init(TALLOC_CTX *ctx) +{ + return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, + "glusterfs_fuse", &glusterfs_fuse_fns); +} diff --git a/source3/modules/wscript_build b/source3/modules/wscript_build index db083f50646..4a51002182f 100644 --- a/source3/modules/wscript_build +++ b/source3/modules/wscript_build @@ -515,6 +515,14 @@ bld.SAMBA3_MODULE('vfs_glusterfs', internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_glusterfs'), enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_glusterfs')) +bld.SAMBA3_MODULE('vfs_glusterfs_fuse', + subsystem='vfs', + source='vfs_glusterfs_fuse.c', + deps='', + init_function='', + internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_glusterfs_fuse'), + enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_glusterfs_fuse')) + bld.SAMBA3_MODULE('vfs_worm', subsystem='vfs', source='vfs_worm.c', diff --git a/source3/wscript b/source3/wscript index 24e52e592c9..d2916593888 100644 --- a/source3/wscript +++ b/source3/wscript @@ -1661,6 +1661,7 @@ main() { vfs_media_harmony vfs_unityed_media vfs_fruit vfs_shell_snap vfs_commit vfs_worm vfs_crossrename vfs_linux_xfs_sgid vfs_time_audit vfs_offline vfs_virusfilter + vfs_glusterfs_fuse ''')) default_shared_modules.extend(TO_LIST('auth_script idmap_tdb2 idmap_script')) # these have broken dependencies -- 2.20.1 From 173ac2654c9f0eff2a3bdb674de4e412b96f4e22 Mon Sep 17 00:00:00 2001 From: Anoop C S Date: Wed, 23 Jan 2019 15:40:43 +0530 Subject: [PATCH 2/2] s3-vfs: Use ENOATTR in errno comparison for getxattr * ENODATA is not defined in FreeBSD * ENOATTR is defined to be a synonym for ENODATA in Linux * In its absence Samba already defines ENOATTR to either ENODATA or ENOENT Thus it is safe and correct to compare with ENOATTR rather than ENODATA. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13774 Signed-off-by: Anoop C S Reviewed-by: Uri Simchoni Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Wed Jan 23 21:59:10 CET 2019 on sn-devel-144 (cherry picked from commit c99402724a65f4e1f8ed4dcd236a43e0603bef0a) --- source3/modules/posixacl_xattr.c | 4 ++-- source3/modules/vfs_glusterfs.c | 2 +- source3/modules/vfs_glusterfs_fuse.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source3/modules/posixacl_xattr.c b/source3/modules/posixacl_xattr.c index 8f6f365bff9..6f016e17e0b 100644 --- a/source3/modules/posixacl_xattr.c +++ b/source3/modules/posixacl_xattr.c @@ -379,7 +379,7 @@ SMB_ACL_T posixacl_xattr_acl_get_file(vfs_handle_struct *handle, if (ret > 0) { return posixacl_xattr_to_smb_acl(buf, ret, mem_ctx); } - if (ret == 0 || errno == ENOATTR || errno == ENODATA) { + if (ret == 0 || errno == ENOATTR) { mode_t mode = 0; TALLOC_CTX *frame = talloc_stackframe(); struct smb_filename *smb_fname_tmp = @@ -434,7 +434,7 @@ SMB_ACL_T posixacl_xattr_acl_get_fd(vfs_handle_struct *handle, if (ret > 0) { return posixacl_xattr_to_smb_acl(buf, ret, mem_ctx); } - if (ret == 0 || errno == ENOATTR || errno == ENODATA) { + if (ret == 0 || errno == ENOATTR) { SMB_STRUCT_STAT sbuf; ret = SMB_VFS_FSTAT(fsp, &sbuf); if (ret == 0) diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c index c9d57b4b646..a241ac9db9f 100644 --- a/source3/modules/vfs_glusterfs.c +++ b/source3/modules/vfs_glusterfs.c @@ -1443,7 +1443,7 @@ static int vfs_gluster_get_real_filename(struct vfs_handle_struct *handle, ret = glfs_getxattr(handle->data, path, key_buf, val_buf, NAME_MAX + 1); if (ret == -1) { - if (errno == ENODATA) { + if (errno == ENOATTR) { errno = EOPNOTSUPP; } return -1; diff --git a/source3/modules/vfs_glusterfs_fuse.c b/source3/modules/vfs_glusterfs_fuse.c index 64c1b0035c1..8855cd18d01 100644 --- a/source3/modules/vfs_glusterfs_fuse.c +++ b/source3/modules/vfs_glusterfs_fuse.c @@ -42,7 +42,7 @@ static int vfs_gluster_fuse_get_real_filename(struct vfs_handle_struct *handle, ret = getxattr(path, key_buf, val_buf, NAME_MAX + 1); if (ret == -1) { - if (errno == ENODATA) { + if (errno == ENOATTR) { errno = EOPNOTSUPP; } return -1; -- 2.20.1