zfsonlinux/zfs — pull request #2499 by dweeezil (2014-07-15 20:25:55+00:00)
Title: Linux semantics for fallocate()

According to the Linux documentation, the FALLOC_FL_KEEP_SIZE flag must be
set in conjunction with the FALLOC_FL_PUNCH_HOLE flag. The previous
logic caused a failure whenever FALLOC_FL_KEEP_SIZE was present.

Also, mimic the behavior of other native file systems such as ext4 in
cases where the file might be extended. If the offset is beyond the end
of the file, return success without changing the file. If the extent of
the punched hole would extend the file, only the existing tail of the
file is punched.

References:
https://git.kernel.org/cgit/docs/man-pages/man-pages.git/tree/man2/fallocate.2#n102