zfs_vnops_os.c: Add support for the _PC_CLONE_BLKSIZE name

FreeBSD now has a pathconf name called _PC_CLONE_BLKSIZE
which is the block size supported for block cloning for
the file system.  Since ZFS's block size varies per file,
return the largest size likely to be used, or zero if block
cloning is not supported.

Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Rick Macklem <rmacklem@uoguelph.ca>
Closes #17645
This commit is contained in:
rmacklem 2025-09-09 08:52:40 -07:00 committed by Brian Behlendorf
parent 02fa962af0
commit b727163db9

View File

@ -61,6 +61,7 @@
#include <sys/fs/zfs.h>
#include <sys/dmu.h>
#include <sys/dmu_objset.h>
#include <sys/dsl_dataset.h>
#include <sys/spa.h>
#include <sys/txg.h>
#include <sys/dbuf.h>
@ -5729,6 +5730,9 @@ zfs_freebsd_pathconf(struct vop_pathconf_args *ap)
{
ulong_t val;
int error;
#ifdef _PC_CLONE_BLKSIZE
zfsvfs_t *zfsvfs;
#endif
error = zfs_pathconf(ap->a_vp, ap->a_name, &val,
curthread->td_ucred, NULL);
@ -5774,6 +5778,21 @@ zfs_freebsd_pathconf(struct vop_pathconf_args *ap)
case _PC_HAS_HIDDENSYSTEM:
*ap->a_retval = 1;
return (0);
#endif
#ifdef _PC_CLONE_BLKSIZE
case _PC_CLONE_BLKSIZE:
zfsvfs = (zfsvfs_t *)ap->a_vp->v_mount->mnt_data;
if (zfs_bclone_enabled &&
spa_feature_is_enabled(dmu_objset_spa(zfsvfs->z_os),
SPA_FEATURE_BLOCK_CLONING))
*ap->a_retval = dsl_dataset_feature_is_active(
zfsvfs->z_os->os_dsl_dataset,
SPA_FEATURE_LARGE_BLOCKS) ?
SPA_MAXBLOCKSIZE :
SPA_OLD_MAXBLOCKSIZE;
else
*ap->a_retval = 0;
return (0);
#endif
default:
return (vop_stdpathconf(ap));