1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-02 09:47:23 +03:00

system: add hole punch support to sys_fallocate()

If Samba is configured with FALLOC_FL_PUNCH_HOLE support, then allow
sys_fallocate() to propogate the flag to syscall invocation.

Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
David Disseldorp 2015-02-10 14:32:07 +01:00 committed by Jeremy Allison
parent 762f9cbe60
commit 47f15b14ae
2 changed files with 10 additions and 2 deletions

View File

@ -490,6 +490,7 @@ enum vfs_translate_direction {
enum vfs_fallocate_flags {
VFS_FALLOCATE_FL_KEEP_SIZE = 0x0001,
VFS_FALLOCATE_FL_PUNCH_HOLE = 0x0002,
};
/*

View File

@ -488,6 +488,13 @@ int sys_fallocate(int fd, uint32_t mode, off_t offset, off_t len)
mode &= ~VFS_FALLOCATE_FL_KEEP_SIZE;
}
#if defined(HAVE_FALLOC_FL_PUNCH_HOLE)
if (mode & VFS_FALLOCATE_FL_PUNCH_HOLE) {
lmode |= FALLOC_FL_PUNCH_HOLE;
mode &= ~VFS_FALLOCATE_FL_PUNCH_HOLE;
}
#endif /* HAVE_FALLOC_FL_PUNCH_HOLE */
if (mode != 0) {
DEBUG(2, ("unmapped fallocate flags: %lx\n",
(unsigned long)mode));
@ -495,11 +502,11 @@ int sys_fallocate(int fd, uint32_t mode, off_t offset, off_t len)
return -1;
}
return fallocate(fd, lmode, offset, len);
#else
#else /* HAVE_LINUX_FALLOCATE */
/* TODO - plumb in fallocate from other filesysetms like VXFS etc. JRA. */
errno = ENOSYS;
return -1;
#endif
#endif /* HAVE_LINUX_FALLOCATE */
}
#if HAVE_KERNEL_SHARE_MODES