From 1c3731ccefb198adc9fb00b8bd61150c3ce23d14 Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Wed, 8 Aug 2018 14:54:24 -0700 Subject: [PATCH] vfs_gpfs: Block punchhole calls for non-sparse files The core smbd code implements ZERO_DATA for non-sparse files by punching a hole and filling it again with a fallocate(FL_KEEP_SIZE) call. As GPFS does not provide the fallocate(FL_KEEP_SIZE) call and non-sparse files should not contain holes, block the punchhole; effectively only allowing ZERO_DATA/punchhole calls for sparse files. Signed-off-by: Christof Schmitt Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Tue Apr 23 00:33:03 UTC 2019 on sn-devel-144 --- source3/modules/vfs_gpfs.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index 4de8720e940..52c4e5ef25d 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -1946,6 +1946,21 @@ static int vfs_gpfs_fallocate(struct vfs_handle_struct *handle, struct files_struct *fsp, uint32_t mode, off_t offset, off_t len) { + if (mode == (VFS_FALLOCATE_FL_PUNCH_HOLE|VFS_FALLOCATE_FL_KEEP_SIZE) && + !fsp->is_sparse && + lp_strict_allocate(SNUM(fsp->conn))) { + /* + * This is from a ZERO_DATA request on a non-sparse + * file. GPFS does not support FL_KEEP_SIZE and thus + * cannot fill the whole again in the subsequent + * fallocate(FL_KEEP_SIZE). Deny this FL_PUNCH_HOLE + * call to not end up with a hole in a non-sparse + * file. + */ + errno = ENOTSUP; + return -1; + } + return SMB_VFS_NEXT_FALLOCATE(handle, fsp, mode, offset, len); } -- 2.34.1