From owner-freebsd-fs@freebsd.org Thu Sep 28 15:36:34 2017 Return-Path: Delivered-To: freebsd-fs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E807AE019B7 for ; Thu, 28 Sep 2017 15:36:34 +0000 (UTC) (envelope-from freebsd-listen@fabiankeil.de) Received: from smtprelay02.ispgateway.de (smtprelay02.ispgateway.de [80.67.31.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8B0543D17 for ; Thu, 28 Sep 2017 15:36:34 +0000 (UTC) (envelope-from freebsd-listen@fabiankeil.de) Received: from [78.35.164.62] (helo=fabiankeil.de) by smtprelay02.ispgateway.de with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1dxajB-0002RF-NM for freebsd-fs@freebsd.org; Thu, 28 Sep 2017 17:27:53 +0200 Date: Thu, 28 Sep 2017 17:26:09 +0200 From: Fabian Keil To: Freebsd fs 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> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; boundary="Sig_/kFRu/vYwbbUeM7q2Hajwz1x"; protocol="application/pgp-signature" X-Df-Sender: Nzc1MDY3 X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Sep 2017 15:36:35 -0000 --Sig_/kFRu/vYwbbUeM7q2Hajwz1x Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Ben RUBSON 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--