From owner-freebsd-fs@freebsd.org Thu Sep 28 16:11:06 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 BC80AE02999 for ; Thu, 28 Sep 2017 16:11:06 +0000 (UTC) (envelope-from ben.rubson@gmail.com) Received: from mail-wr0-x229.google.com (mail-wr0-x229.google.com [IPv6:2a00:1450:400c:c0c::229]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4573B644DB for ; Thu, 28 Sep 2017 16:11:06 +0000 (UTC) (envelope-from ben.rubson@gmail.com) Received: by mail-wr0-x229.google.com with SMTP id l39so3581508wrl.12 for ; Thu, 28 Sep 2017 09:11:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to; bh=F/waumL4fK+5yJAu34SbdbMtWFQTRAXq9g1Zi4JuLcQ=; b=i9DSfb9+eO180dvU0ZF5YdzdfaMG7zRiaPgoHSN6L+iZIFcbqqiXqb5/tlVGAQRbt8 nlY5btnyLipiDcMDdF1o4RudVOXi8dTXkPhkO73TnYxLXtaanXKAPan4VLJjEyG0nguy 4CK0fb2ilDD9xISLuWUoqdasD6R2T82c1chBy6fabvA+/WhnKKv18kC7i2fDQlgQKZWf ETZ/SWa+TfztmNnZc9kppokPDYoI7JHtaXIKgQ1TziTv54u7XiRwv6ZkAiEkqLuFHMeJ 2xEZorh11sHCLZMr2KmkkCLeIhNN6xblofw/xCjZbfXYf1DCe2rnOE1aEzFdrUhhKlma ZJhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to; bh=F/waumL4fK+5yJAu34SbdbMtWFQTRAXq9g1Zi4JuLcQ=; b=f2wjwT/RH3Tclek99pn9NsGDN+GAEzMmCX5i7yIcMFBXGGdH7ltyTJpdcjZc48dpxq VdvJklj1PKCNC+sm/j5ujSK8PGGdT40qDgcR1BSrBcQDqmzsIRe3Lb2144ho/ERpxLGu jSFgh6uaimTT496puXpXtH+D5wd4inlji2cipdpSjS6OamkHqziM0+F/ZEk/aEFE5uKl WUfNHBItX1H/UgvBedgHshMFbaAYaeoRTyWb4/YdaszYpc9MQMOqHnLukGM8cwHtiCO3 ha4RIHGoKCI5L5AuJGTf1VhxQJFEMO2zsznhzD8m/Klht71NCIghj8qeTZBaHFtCaBdr LW+Q== X-Gm-Message-State: AHPjjUiyjOD+B5s8oTwJaQPyJO9617CAsvUOWtoQU4mV9JTkWX2Z4QgY qt3EcnT0bR+B2rCP8xrYUQr7Z0Dh X-Google-Smtp-Source: AOwi7QDpL4uOwO5ahJx3ZYv6bTlr3pamtQQNLio3ztj2Y5bhnKFvNmP3QSY81bPfU0OSDorUopy3sg== X-Received: by 10.223.174.150 with SMTP id y22mr5313812wrc.29.1506615064377; Thu, 28 Sep 2017 09:11:04 -0700 (PDT) Received: from bens-mac.home (LFbn-MAR-1-445-220.w2-15.abo.wanadoo.fr. [2.15.38.220]) by smtp.gmail.com with ESMTPSA id w4sm3063506wrc.78.2017.09.28.09.11.03 for (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Sep 2017 09:11:03 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Subject: Re: How to create holes in files ? From: Ben RUBSON In-Reply-To: <20170928172609.0e6d5c77@fabiankeil.de> Date: Thu, 28 Sep 2017 18:11:02 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <15FEA4C2-7434-4CED-8369-AB4695B47654@gmail.com> References: <44E32501-4213-4A09-992C-92DB4EF33C0C@gmail.com> <20170928172609.0e6d5c77@fabiankeil.de> To: Freebsd fs X-Mailer: Apple Mail (2.3124) 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 16:11:06 -0000 Hi Fabian, And thank you very much for your answer ! > On 28 Sep 2017, at 17:26, Fabian Keil = wrote: >=20 > Ben RUBSON 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