vfs_gpfs: Block punchhole calls for non-sparse files
authorChristof Schmitt <cs@samba.org>
Wed, 8 Aug 2018 21:54:24 +0000 (14:54 -0700)
committerJeremy Allison <jra@samba.org>
Tue, 23 Apr 2019 00:33:03 +0000 (00:33 +0000)
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 <cs@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Apr 23 00:33:03 UTC 2019 on sn-devel-144

source3/modules/vfs_gpfs.c

index 4de8720e940279d5ed8824f9ab1973f567bb1b0a..52c4e5ef25d748bfaea88eca3fa9a1e6991cdfa4 100644 (file)
@@ -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);
 }