Hole-punching support on FreeBSD
Links:
Commit 0dc332bff200 URL:
https://cgit.freebsd.org/src/commit/?id=0dc332bff200c940edc36c4715b629a2e1e9f9ae
Commit 9e202d036dd6 URL:
https://cgit.freebsd.org/src/commit/?id=9e202d036dd6f38ce0f578aa2086ebc358315bab
Commit 5ee2c35751ef URL:
https://cgit.freebsd.org/src/commit/?id=5ee2c35751ef5d131222423bf3e25073f997c337
OpenZFS Pull
Request #12458 URL: https://github.com/openzfs/zfs/pull/12458
Contact: Ka Ho Ng <khng@FreeBSD.org>
Hole-punching functionality allows turning a contiguous range of bytes into a hole for a given file. File systems supporting hole-punching may deallocate the file system space from the given file. One use case for the functionality is to convert TRIM/UNMAP/DEALLOCATE requests from a virtual machine guest to hole-punching calls on the host’s side, thus allows reclamation of file system space when unneeded by the guest.
A set of APIs and KPIs are added that developers can call to
invoke hole-punching on a given file, if the underlying file system
exposes that functionality. For file systems not supporting
hole-punching there is a fallback implementation in the kernel
which does zero-filling instead. Besides the APIs and KPIs
addition, the truncate(1)
utility is expanded by
adding a -d
flag to support invoking hole-punching as
well.
At the time of writing this report, OpenZFS and tmpfs are the file systems that support hole-punching.
Sponsor: The FreeBSD Foundation
Last modified on: November 15, 2021 by Daniel Ebdrup Jensen