Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Sep 2017 17:26:09 +0200
From:      Fabian Keil <freebsd-listen@fabiankeil.de>
To:        Freebsd fs <freebsd-fs@freebsd.org>
Subject:   Re: How to create holes in files ?
Message-ID:  <20170928172609.0e6d5c77@fabiankeil.de>
In-Reply-To: <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
--Sig_/kFRu/vYwbbUeM7q2Hajwz1x
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

Ben RUBSON <ben.rubson@gmail.com> wrote:

> I'm trying to make holes in files in C.
> Goal is to deallocate huge files on ZFS while (randomly) reading them.

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.

Otherwise you could simply "deallocate" the content with
truncate(1).

> The only thing I found is on Linux, fallocate(2) with
> FALLOC_FL_PUNCH_HOLE.
>=20
> What about FreeBSD ?

I remember some discussions about adding something similar
for FreeBSD but I don't remember ever seeing any patches
(or commits) for it.

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.

As an example see the delete_range() function in:
https://www.fabiankeil.de/sourcecode/electrobsd/ElectroBSD-r312620-6cfa243f=
1516/0033-ggate-cd-Add-BIO_DELETE-support.diff

Obviously this only works with ZFS, but you didn't mention
other file systems anyway.

Fabian

--Sig_/kFRu/vYwbbUeM7q2Hajwz1x
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iF0EARECAB0WIQTKUNd6H/m3+ByGULIFiohV/3dUnQUCWc0UkQAKCRAFiohV/3dU
ncxfAKCScSzAx+nmuz4qndr/n0Cgvr5w5ACgjcdzkmgCW95l/67zI1nk1Mb2I4U=
=ppiM
-----END PGP SIGNATURE-----

--Sig_/kFRu/vYwbbUeM7q2Hajwz1x--



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