How to create holes in files ?
Bakul Shah
bakul at bitblocks.com
Fri Sep 29 07:21:53 UTC 2017
On Thu, 28 Sep 2017 16:39:28 +0200 Ben RUBSON <ben.rubson at gmail.com> wrote:
Ben RUBSON writes:
> Hi,
>
> I'm trying to make holes in files in C.
> Goal is to deallocate huge files on ZFS while (randomly) reading them.
>
> The only thing I found is on Linux, fallocate(2) with FALLOC_FL_PUNCH_HOLE.
>
> What about FreeBSD ?
You can copy such a file using rsync with -S or --sparse
option or dd with conv=sparse option. I don't know if these
programs use seek with SEEK_HOLE and SEEK_DATA to avoid
reading existing holes in the source file as zeroes.
Someone mentioned TRIM support but AFAIK this is only used (if
available) when a file is freed. Replacing a zero block write
with lseek will impact every write (you have to check if the
block is all zeroes) so not worth doing in the general case.
More information about the freebsd-fs
mailing list