mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 18:40:43 +03:00
zfs_file: implement zfs_file_deallocate for FreeBSD 14
FreeBSD 14 gained a `VOP_DEALLOCATE` VFS operation and a `fspacectl` syscall to use it. At minimum, these zero the given region, and if the underlying filesystem supports it, can make the region sparse. We can use this to get TRIM-like behaviour for file vdevs. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #16496
This commit is contained in:
committed by
Brian Behlendorf
parent
fa330646b9
commit
f245541e24
@@ -295,8 +295,20 @@ zfs_file_fsync(zfs_file_t *fp, int flags)
|
||||
int
|
||||
zfs_file_deallocate(zfs_file_t *fp, loff_t offset, loff_t len)
|
||||
{
|
||||
int rc;
|
||||
#if __FreeBSD_version >= 1400029
|
||||
struct thread *td;
|
||||
|
||||
td = curthread;
|
||||
rc = fo_fspacectl(fp, SPACECTL_DEALLOC, &offset, &len, 0,
|
||||
td->td_ucred, td);
|
||||
#else
|
||||
(void) fp, (void) offset, (void) len;
|
||||
return (SET_ERROR(EOPNOTSUPP));
|
||||
rc = EOPNOTSUPP;
|
||||
#endif
|
||||
if (rc)
|
||||
return (SET_ERROR(rc));
|
||||
return (0);
|
||||
}
|
||||
|
||||
zfs_file_t *
|
||||
|
||||
Reference in New Issue
Block a user