From 572bd325bbbebf23f60fa88df7be3409bb3c3e2f Mon Sep 17 00:00:00 2001 From: David Disseldorp Date: Wed, 10 Jan 2018 01:37:14 +0100 Subject: [PATCH 1/2] vfs_ceph: add fs_capabilities hook to avoid local statvfs Adding the fs_capabilities() hook to the CephFS VFS module avoids fallback to the vfs_default code-path, which calls statvfs() against the share path on the *local* filesystem. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13208 Signed-off-by: David Disseldorp Reviewed-by: Jeremy Allison (cherry picked from commit 2724e0cac29cd1632ea28075a740fcc888affb36) --- source3/modules/vfs_ceph.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c index e3d22bfce29..28426472dee 100644 --- a/source3/modules/vfs_ceph.c +++ b/source3/modules/vfs_ceph.c @@ -251,6 +251,20 @@ static int cephwrap_statvfs(struct vfs_handle_struct *handle, const char *path, return ret; } +static uint32_t cephwrap_fs_capabilities(struct vfs_handle_struct *handle, + enum timestamp_set_resolution *p_ts_res) +{ + uint32_t caps = FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES; + +#ifdef HAVE_CEPH_STATX + *p_ts_res = TIMESTAMP_SET_NT_OR_BETTER; +#else + *p_ts_res = TIMESTAMP_SET_MSEC; +#endif + + return caps; +} + /* Directory operations */ static DIR *cephwrap_opendir(struct vfs_handle_struct *handle, @@ -1339,6 +1353,7 @@ static struct vfs_fn_pointers ceph_fns = { .get_quota_fn = cephwrap_get_quota, .set_quota_fn = cephwrap_set_quota, .statvfs_fn = cephwrap_statvfs, + .fs_capabilities_fn = cephwrap_fs_capabilities, /* Directory operations */ -- 2.13.6 From f02aeb968d2321b301898348cd6401bcf9230374 Mon Sep 17 00:00:00 2001 From: David Disseldorp Date: Wed, 10 Jan 2018 14:03:09 +0100 Subject: [PATCH 2/2] vfs_default: use VFS statvfs macro in fs_capabilities Currently the vfs_default fs_capabilities handler calls statvfs directly, rather than calling the vfs macro. This behaviour may cause issues for VFS modules that delegate fs_capabilities handling to vfs_default but offer their own statvfs hook. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13208 Signed-off-by: David Disseldorp Reviewed-by: Jeremy Allison (cherry picked from commit 4b25c9f4a4d336a16894452862ea059701b025de) --- source3/modules/vfs_default.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index ce1b6e25693..910078d7128 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -121,8 +121,14 @@ static uint32_t vfswrap_fs_capabilities(struct vfs_handle_struct *handle, struct vfs_statvfs_struct statbuf; int ret; + smb_fname_cpath = synthetic_smb_fname(talloc_tos(), conn->connectpath, + NULL, NULL, 0); + if (smb_fname_cpath == NULL) { + return caps; + } + ZERO_STRUCT(statbuf); - ret = sys_statvfs(conn->connectpath, &statbuf); + ret = SMB_VFS_STATVFS(conn, smb_fname_cpath, &statbuf); if (ret == 0) { caps = statbuf.FsCapabilities; } @@ -132,12 +138,6 @@ static uint32_t vfswrap_fs_capabilities(struct vfs_handle_struct *handle, /* Work out what timestamp resolution we can * use when setting a timestamp. */ - smb_fname_cpath = synthetic_smb_fname(talloc_tos(), conn->connectpath, - NULL, NULL, 0); - if (smb_fname_cpath == NULL) { - return caps; - } - ret = SMB_VFS_STAT(conn, smb_fname_cpath); if (ret == -1) { TALLOC_FREE(smb_fname_cpath); -- 2.13.6