[PATCH] vfs_glusterfs: Add fallocate support for vfs_glusterfs
David Disseldorp
ddiss at suse.de
Tue Jan 9 22:56:30 UTC 2018
Hi Sachin,
A couple of comments inline...
On Tue, 09 Jan 2018 13:02:13 +0530, Sachin Prabhu via samba-technical wrote:
> From 05f47588b2641242d219564e6eb8468f9484a3d4 Mon Sep 17 00:00:00 2001
> From: Sachin Prabhu <sprabhu at redhat.com>
> Date: Tue, 14 Nov 2017 15:51:44 +0530
> Subject: [PATCH] vfs_glusterfs: Add fallocate support for vfs_glusterfs
>
> Adds fallocate support to the vfs glusterfs plugin.
>
> RHBZ: 1478875
>
> Signed-off-by: Sachin Prabhu <sprabhu at redhat.com>
> ---
> source3/modules/vfs_glusterfs.c | 26 ++++++++++++++++++++++----
> 1 file changed, 22 insertions(+), 4 deletions(-)
>
> diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c
> index 953c46af4cd..c0ea722c1df 100644
> --- a/source3/modules/vfs_glusterfs.c
> +++ b/source3/modules/vfs_glusterfs.c
> @@ -462,7 +462,8 @@ static int vfs_gluster_statvfs(struct vfs_handle_struct *handle,
> static uint32_t vfs_gluster_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;
> + uint32_t caps = FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES
> + | FILE_SUPPORTS_SPARSE_FILES;
Does glusterfs support SEEK_DATA / SEEK_HOLE? Keep in mind that sparse
aware clients may issue Query Allocated Ranges requests, which can be
mapped by the SMB2 server into VFS lseek(SEEK_DATA / SEEK_HOLE) calls.
> #ifdef STAT_HAVE_NSEC
> *p_ts_res = TIMESTAMP_SET_NT_OR_BETTER;
> @@ -1148,9 +1149,26 @@ static int vfs_gluster_fallocate(struct vfs_handle_struct *handle,
> uint32_t mode,
> off_t offset, off_t len)
> {
> - /* TODO: add support using glfs_fallocate() and glfs_zerofill() */
> - errno = ENOTSUP;
> - return -1;
> + int keep_size, punch_hole;
> +
> + keep_size = mode & VFS_FALLOCATE_FL_KEEP_SIZE;
> + punch_hole = mode & VFS_FALLOCATE_FL_PUNCH_HOLE;
> +
> + mode &= ~(VFS_FALLOCATE_FL_KEEP_SIZE|VFS_FALLOCATE_FL_PUNCH_HOLE);
> + if (mode) {
> + errno = ENOTSUP;
> + return -1;
> + }
> +
> + if (punch_hole) {
> + return glfs_discard(*(glfs_fd_t **)
> + VFS_FETCH_FSP_EXTENSION(handle, fsp),
> + offset, len);
I assume glfs_discard() will never change the file size here, i.e. it
matches fallocate(mode = VFS_FALLOCATE_FL_PUNCH_HOLE
| VFS_FALLOCATE_FL_KEEP_SIZE) behaviour?
> + }
> +
> + return glfs_fallocate(*(glfs_fd_t **)
> + VFS_FETCH_FSP_EXTENSION(handle, fsp),
> + keep_size, offset, len);
> }
>
> static struct smb_filename *vfs_gluster_realpath(struct vfs_handle_struct *handle,
Cheers, David
More information about the samba-technical
mailing list