Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 6 Mar 2011 09:54:45 +0100
From:      Pawel Jakub Dawidek <pjd@FreeBSD.org>
To:        Attila Nagy <bra@fsn.hu>
Cc:        freebsd-fs@freebsd.org
Subject:   Re: Punching holes into (sparse) files - porting Solaris fcntl(F_FREESP) to FreeBSD?
Message-ID:  <20110306084217.GA9791@garage.freebsd.pl>
In-Reply-To: <4D710154.90409@fsn.hu>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
On Fri, Mar 04, 2011 at 04:12:20PM +0100, Attila Nagy wrote:
> Hi,
> 
> Is it possible to make regions of files, with already written data 
> sparse? (I'm interested to do this on ZFS)
> 
> All I could find in this topic is:
> http://www.mail-archive.com/zfs-discuss@opensolaris.org/msg29047.html
> 
> grepping through the source gives a match for VOP_SPACE in 
> cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_replay.c:
> zfs_replay_truncate(zfsvfs_t *zfsvfs, lr_truncate_t *lr, boolean_t byteswap)
> {
> #ifdef sun
> [...]
>         error = VOP_SPACE(ZTOV(zp), F_FREESP, &fl, FWRITE | FOFFMAX,
>             lr->lr_offset, kcred, NULL);
> 
> And the relevant section from fcntl(2) in Solaris:
>      F_FREESP
> 
>          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 <fcntl.h>
>          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.
> 
> F_FREESP seems to be my friend, and it's implemented in Solaris's ZFS. 
> How hard would it be to complete the port and make it accessible from 
> 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.

-- 
Pawel Jakub Dawidek                       http://www.wheelsystems.com
FreeBSD committer                         http://www.FreeBSD.org
Am I Evil? Yes, I Am!                     http://yomoli.com

[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (FreeBSD)

iEUEARECAAYFAk1zS9QACgkQForvXbEpPzQE5QCYo51Ht4WXKSPPGLPXZj8lFyHn
UACfTowvfEMJD7/s4NEYIR11T6zTH5Y=
=q7p7
-----END PGP SIGNATURE-----
help

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