From f3bbeb970e03cfc8e7b2d90702e3f471668b3ef8 Mon Sep 17 00:00:00 2001 From: Ka Ho Ng Date: Wed, 4 Aug 2021 23:57:48 +0800 Subject: FreeBSD: Implement hole-punching support This adds supports for hole-punching facilities in the FreeBSD kernel starting from __FreeBSD_version 1400032. Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Reviewed-by: Ryan Moeller Signed-off-by: Ka Ho Ng Sponsored-by: The FreeBSD Foundation Closes #12458 --- module/os/freebsd/zfs/zfs_znode.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'module/os/freebsd/zfs/zfs_znode.c') diff --git a/module/os/freebsd/zfs/zfs_znode.c b/module/os/freebsd/zfs/zfs_znode.c index 6a59c0eae..9b48dcda1 100644 --- a/module/os/freebsd/zfs/zfs_znode.c +++ b/module/os/freebsd/zfs/zfs_znode.c @@ -1476,12 +1476,16 @@ zfs_free_range(znode_t *zp, uint64_t off, uint64_t len) error = dmu_free_long_range(zfsvfs->z_os, zp->z_id, off, len); if (error == 0) { +#if __FreeBSD_version >= 1400032 + vnode_pager_purge_range(ZTOV(zp), off, off + len); +#else /* - * In FreeBSD we cannot free block in the middle of a file, - * but only at the end of a file, so this code path should - * never happen. + * Before __FreeBSD_version 1400032 we cannot free block in the + * middle of a file, but only at the end of a file, so this code + * path should never happen. */ vnode_pager_setsize(ZTOV(zp), off); +#endif } zfs_rangelock_exit(lr); -- cgit v1.2.3