summaryrefslogtreecommitdiff
path: root/source3/modules
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2019-01-17 15:21:07 +0100
committerKarolin Seeger <kseeger@samba.org>2019-02-05 15:33:26 +0100
commit3db3eff31200022106f417c26c4d23f4870d07ab (patch)
tree59b1587840677f5c75ae82252680988d15406f14 /source3/modules
parent103600771227e074b46038f1bbb5a345c786d0b9 (diff)
downloadsamba-3db3eff31200022106f417c26c4d23f4870d07ab.tar.gz
s3-vfs: add glusterfs_fuse vfs module.
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 <pgurusid@redhat.com> BUG: https://bugzilla.samba.org/show_bug.cgi?id=13774 Guenther Signed-off-by: Günther Deschner <gd@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> Autobuild-User(master): Günther Deschner <gd@samba.org> Autobuild-Date(master): Tue Jan 22 18:37:56 CET 2019 on sn-devel-144 (cherry picked from commit adffe0dcf002aa4721dc7897261895e3486d5271)
Diffstat (limited to 'source3/modules')
-rw-r--r--source3/modules/vfs_glusterfs_fuse.c71
-rw-r--r--source3/modules/wscript_build8
2 files changed, 79 insertions, 0 deletions
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 <gd@samba.org>
+
+ 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 <http://www.gnu.org/licenses/>.
+*/
+
+#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 1f9730b5347..23cfa3050d5 100644
--- a/source3/modules/wscript_build
+++ b/source3/modules/wscript_build
@@ -494,6 +494,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',