This differential proposeAdd fspacectl(2) system calls, vn_deallocate(9) function
and VOP_DEALLOCATE(9) call for hole-punching.
fspacectl(2) is a system call for performingto provide space management operationsupport to
on a file. Hole-punching is currently supporteduserspace applications. For hole-punchingVOP_DEALLOCATE(9) is a VOP call to perform the
operdeallocation,. subsequent reads on such range return 0 in case the operation
succeedsvn_deallocate(9) is a public KPI.
The main purpose of proposing thea new system call and VOP is to allow bhyve, a KPI and a VOP call is to
allow bhyve or other hypervisor monitors to emulate the behavior of SCSI unmap on a
UNMAP/NVMe DEALLOCATE on a plain file.
SPACECTL_ALLOC backs the given range with space allocation such thatfspacectl(2) comprises of cmd and flags parameters to specify the
subsequent writespace management operations in the given region will not fail due to to be performed. Currently cmd can be
insufficient space. posix_fallocate(2) is implemented with SPACECTL_ALLOC.
For file system that can never make such guarantee, EINVAL would be
returned.SPACECTL_DEALLOC, Currently calling posix_fallocate(2) in ZFS returns EINVAL before
and after this revisionand flags can be 0 or SPACECTL_F_CANEXTEND.
SPACECTL_DEALLOC performs deallocation on the range aligned tofo_fspacectl is added to fileops.
mapping granularity,VOP_DEALLOCATE(9) is added as a new VOP call. and zero-fill the range not aligned to mappingA trivial implementation
granularity, in caseof VOP_DEALLOCATE(9) is implemented by the
underlying file systemprovided.
A fallback implementation of VOP_DEALLOCATE(9) is provided to performSubmitted by: Ka Ho Ng <khng@freebsdfoundation.org>
zero-filling on non-hole region.
By default, fspacectl(2) does not extend file size in case the specified range
exceeds the current file size. If SPACECTL_F_CANEXTEND is specified, the
file size will be extended in such case.
fo_fspacectl is added to fileops. VOP_DEALLOCATE(9) is added as a new VOP
operation. vn_deallocate(9) is a vnode public KPI.
Submitted by: Ka Ho Ng
Sponsored by: Sponsored by: The FreeBSD Foundation