zfsonlinux/zfs — pull request #2619 by dweeezil (2014-08-22 14:16:54+00:00)
Title: Implement fallocate FALLOC_FL_PUNCH_HOLE

Add support for the FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE mode of
fallocate(2). 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.

Add an autotools check for the truncate_pagecache_range() helper function
and a compatible implementation if the kernel doesn't support it.

Hole punching clears the relevent pagecache entries in zfs_space()
via truncate_pagecache_range(). For better source compatibility with
other implementations within the zfs_setattr() function, its call to
truncate_setsize() has been moved to zfs_space().