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 <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Tony Hutter <[email protected]>
Signed-off-by: Rick Macklem <[email protected]>
Closes #17645
This commit is contained in:
rmacklem authored and GitHub committed 2025-09-09 08:52:40 -07:00
1 parent 8266fa5858
commit 59f8f5dfe1
1 file changed
+19
+19
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));