Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Sep 2017 00:21:16 -0700
From:      Bakul Shah <bakul@bitblocks.com>
To:        Ben RUBSON <ben.rubson@gmail.com>
Cc:        Freebsd fs <freebsd-fs@freebsd.org>
Subject:   Re: How to create holes in files ?
Message-ID:  <20170929072131.68594156E525@mail.bitblocks.com>
In-Reply-To: Your message of "Thu, 28 Sep 2017 16:39:28 %2B0200." <44E32501-4213-4A09-992C-92DB4EF33C0C@gmail.com>
References:  <44E32501-4213-4A09-992C-92DB4EF33C0C@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 28 Sep 2017 16:39:28 +0200 Ben RUBSON <ben.rubson@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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20170929072131.68594156E525>