HomeFreeBSD

Add support for DISCARD to ZVOLs.

Description

Add support for DISCARD to ZVOLs.

DISCARD (REQ_DISCARD, BLKDISCARD) is useful for thin provisioning.
It allows ZVOL clients to discard (unmap, trim) block ranges from
a ZVOL, thus optimizing disk space usage by allowing a ZVOL to
shrink instead of just grow.

We can't use zfs_space() or zfs_freesp() here, since these functions
only work on regular files, not volumes. Fortunately we can use the
low-level function dmu_free_long_range() which does exactly what we
want.

Currently the discard operation is not added to the log. That's not
a big deal since losing discard requests cannot result in data
corruption. It would however result in disk space usage higher than
it should be. Thus adding log support to zvol_discard() is probably
a good idea for a future improvement.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>

Details

Provenance
Etienne Dechamps <etienne.dechamps@ovh.net>Authored on Sep 2 2011, 1:23 PM
Brian Behlendorf <behlendorf1@llnl.gov>Committed on Feb 10 2012, 12:19 AM
Parents
rGcb2d19010d8f: Support the fallocate() file operation.
Branches
Unknown
Tags
Unknown

Event Timeline

Brian Behlendorf <behlendorf1@llnl.gov> committed rG30930fba2196: Add support for DISCARD to ZVOLs. (authored by Etienne Dechamps <etienne.dechamps@ovh.net>).Feb 10 2012, 12:19 AM