From owner-freebsd-fs@FreeBSD.ORG Sun Mar 6 08:54:54 2011 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 169D3106566B for ; Sun, 6 Mar 2011 08:54:54 +0000 (UTC) (envelope-from pawel@dawidek.net) Received: from mail.garage.freebsd.pl (60.wheelsystems.com [83.12.187.60]) by mx1.freebsd.org (Postfix) with ESMTP id B2DBF8FC12 for ; Sun, 6 Mar 2011 08:54:53 +0000 (UTC) Received: by mail.garage.freebsd.pl (Postfix, from userid 65534) id 5E0B345DD8; Sun, 6 Mar 2011 09:54:51 +0100 (CET) Received: from localhost (89-73-195-149.dynamic.chello.pl [89.73.195.149]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.garage.freebsd.pl (Postfix) with ESMTP id B3FF845CA6; Sun, 6 Mar 2011 09:54:45 +0100 (CET) Date: Sun, 6 Mar 2011 09:54:45 +0100 From: Pawel Jakub Dawidek To: Attila Nagy Message-ID: <20110306084217.GA9791@garage.freebsd.pl> References: <4D710154.90409@fsn.hu> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="jL2BoiuKMElzg3CS" Content-Disposition: inline In-Reply-To: <4D710154.90409@fsn.hu> User-Agent: Mutt/1.4.2.3i X-PGP-Key-URL: http://people.freebsd.org/~pjd/pjd.asc X-OS: FreeBSD 9.0-CURRENT amd64 X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on mail.garage.freebsd.pl X-Spam-Level: X-Spam-Status: No, score=-0.6 required=4.5 tests=BAYES_00,RCVD_IN_SORBS_DUL autolearn=no version=3.0.4 Cc: freebsd-fs@freebsd.org Subject: Re: Punching holes into (sparse) files - porting Solaris fcntl(F_FREESP) to FreeBSD? X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Mar 2011 08:54:54 -0000 --jL2BoiuKMElzg3CS Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Mar 04, 2011 at 04:12:20PM +0100, Attila Nagy wrote: > Hi, >=20 > Is it possible to make regions of files, with already written data=20 > sparse? (I'm interested to do this on ZFS) >=20 > All I could find in this topic is: > http://www.mail-archive.com/zfs-discuss@opensolaris.org/msg29047.html >=20 > grepping through the source gives a match for VOP_SPACE in=20 > cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_replay.c: > zfs_replay_truncate(zfsvfs_t *zfsvfs, lr_truncate_t *lr, boolean_t bytesw= ap) > { > #ifdef sun > [...] > error =3D VOP_SPACE(ZTOV(zp), F_FREESP, &fl, FWRITE | FOFFMAX, > lr->lr_offset, kcred, NULL); >=20 > And the relevant section from fcntl(2) in Solaris: > F_FREESP >=20 > Free storage space associated with a section of the > ordinary file fildes. The section is specified by a > variable of data type struct flock pointed to by arg. > The data type struct flock is defined in the > header (see fcntl.h(3HEAD)) and is described below. Note > that all file systems might not support all possible > variations of F_FREESP arguments. In particular, many > file systems allow space to be freed only at the end of > a file. >=20 > F_FREESP seems to be my friend, and it's implemented in Solaris's ZFS.=20 > How hard would it be to complete the port and make it accessible from=20 > FreeBSD? > I guess it was left out with a reason... Well, adding new VOP is important decision. We could eventually implement this via ioctl(2), I think... This is a nice feature after all. I don't know why do you need this, but note that when compression is enabled on a ZFS file system, all-zeros blocks are turned into holes, so if you do have compression enabled and you write all zeros in the place you want to punch a hole, the pool space should be reclaimed. --=20 Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com --jL2BoiuKMElzg3CS Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEUEARECAAYFAk1zS9QACgkQForvXbEpPzQE5QCYo51Ht4WXKSPPGLPXZj8lFyHn UACfTowvfEMJD7/s4NEYIR11T6zTH5Y= =q7p7 -----END PGP SIGNATURE----- --jL2BoiuKMElzg3CS--