Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-doc
Path: blob/main/website/content/en/status/report-2021-07-2021-09/holepunching.adoc
18097 views
=== Hole-punching support on FreeBSD

Links: +
link:https://cgit.freebsd.org/src/commit/?id=0dc332bff200c940edc36c4715b629a2e1e9f9ae[Commit 0dc332bff200] URL: link:https://cgit.freebsd.org/src/commit/?id=0dc332bff200c940edc36c4715b629a2e1e9f9ae[https://cgit.freebsd.org/src/commit/?id=0dc332bff200c940edc36c4715b629a2e1e9f9ae] +
link:https://cgit.freebsd.org/src/commit/?id=9e202d036dd6f38ce0f578aa2086ebc358315bab[Commit 9e202d036dd6] URL: link:https://cgit.freebsd.org/src/commit/?id=9e202d036dd6f38ce0f578aa2086ebc358315bab[https://cgit.freebsd.org/src/commit/?id=9e202d036dd6f38ce0f578aa2086ebc358315bab] +
link:https://cgit.freebsd.org/src/commit/?id=5ee2c35751ef5d131222423bf3e25073f997c337[Commit 5ee2c35751ef] URL: link:https://cgit.freebsd.org/src/commit/?id=5ee2c35751ef5d131222423bf3e25073f997c337[https://cgit.freebsd.org/src/commit/?id=5ee2c35751ef5d131222423bf3e25073f997c337] +
link:https://github.com/openzfs/zfs/pull/12458[OpenZFS Pull Request #12458] URL: link:https://github.com/openzfs/zfs/pull/12458[https://github.com/openzfs/zfs/pull/12458]

Contact: Ka Ho Ng <[email protected]>

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