Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Sep 2017 18:11:02 +0200
From:      Ben RUBSON <ben.rubson@gmail.com>
To:        Freebsd fs <freebsd-fs@freebsd.org>
Subject:   Re: How to create holes in files ?
Message-ID:  <15FEA4C2-7434-4CED-8369-AB4695B47654@gmail.com>
In-Reply-To: <20170928172609.0e6d5c77@fabiankeil.de>
References:  <44E32501-4213-4A09-992C-92DB4EF33C0C@gmail.com> <20170928172609.0e6d5c77@fabiankeil.de>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi Fabian,

And thank you very much for your answer !

> On 28 Sep 2017, at 17:26, Fabian Keil <freebsd-listen@fabiankeil.de> =
wrote:
>=20
> Ben RUBSON <ben.rubson@gmail.com> wrote:
>=20
>> I'm trying to make holes in files in C.
>> Goal is to deallocate huge files on ZFS while (randomly) reading =
them.
>=20
> My interpretation of the above is that you want to create holes
> without changing the file size and without affecting data that
> is located before or after the holes that you want to create.

Exactly.

> Otherwise you could simply "deallocate" the content with
> truncate(1).
>=20
>> The only thing I found is on Linux, fallocate(2) with
>> FALLOC_FL_PUNCH_HOLE.
>>=20
>> What about FreeBSD ?
>=20
> I remember some discussions about adding something similar
> for FreeBSD but I don't remember ever seeing any patches
> (or commits) for it.

Would really be nice !

> As a work around you can enable ZFS compression (if it isn't
> enabled already) and "overwrite" data you don't need anymore
> with zeros.
>=20
> As an example see the delete_range() function in:
> =
https://www.fabiankeil.de/sourcecode/electrobsd/ElectroBSD-r312620-6cfa243=
f1516/0033-ggate-cd-Add-BIO_DELETE-support.diff
>=20
> Obviously this only works with ZFS, but you didn't mention
> other file systems anyway.

You're right I only use ZFS.
This is clearly a nice workaround !
Unfortunately, for some reasons, I can't enable ZFS compression.
(I absolutely need userquota on logical size so can't enable =
compression)

Thank you again !

Ben




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?15FEA4C2-7434-4CED-8369-AB4695B47654>