OK, you have a sparse ZFS zvol which houses a filesystem. Say you temporarily write a huge file into the filesystem, and then delete it. How do you get the zvol to realize that the space has been “freed” again? It’s not really any of ZFS’s business to figure this out, so we have to help it.

Option 1: fill the FS with zeros!

Something like dd if=/dev/zero bs=8M of=/thefilesystem/bigfile ; rm /thefilesystem/bigfile (which temporarily completely fills the filesystem!) will suffice. This works basically by assuming that the filesystem will represent (at some level) a big file consisting of a bunch of zeros as a bunch of zeros on disk. ZFS will see the zero writes and reclaim the space.

Option 2: have the filesystem do something smart

With FreeBSD’s UFS, you can fsck_ufs -Z /dev/thedevice to force it to write zeros to unused bits of the zvol. Nice! This is, unfortunately, miserably slow. Ideally, one could tunefs -t enable /dev/thedevice, but depends on everything in between your filesystem and the zvol cooperating nicely to turn BIO_DELETE commands into zeroes on the zvol.