Skip to content

Commit 068913e

Browse files
Pawel Jakub DawidekPawel Jakub Dawidek
Pawel Jakub Dawidek
authored and
Pawel Jakub Dawidek
committed
zfs: Add vfs.zfs.bclone_enabled sysctl.
Keep block cloning disabled by default for now, but allow to enable and use it after setting vfs.zfs.bclone_enabled to 1, so people can easily try it. Approved by: oshogbo Reviewed by: mm, oshogbo Differential Revision: https://reviews.freebsd.org/D39613
1 parent 401f034 commit 068913e

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_vfsops_os.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ typedef struct zfid_long {
287287

288288
extern uint_t zfs_fsyncer_key;
289289
extern int zfs_super_owner;
290+
extern int zfs_bclone_enabled;
290291

291292
extern void zfs_init(void);
292293
extern void zfs_fini(void);

sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vfsops.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ int zfs_debug_level;
8989
SYSCTL_INT(_vfs_zfs, OID_AUTO, debug, CTLFLAG_RWTUN, &zfs_debug_level, 0,
9090
"Debug level");
9191

92+
int zfs_bclone_enabled;
93+
SYSCTL_INT(_vfs_zfs, OID_AUTO, bclone_enabled, CTLFLAG_RWTUN,
94+
&zfs_bclone_enabled, 0, "Enable block cloning");
95+
9296
struct zfs_jailparam {
9397
int mount_snapshot;
9498
};

sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6214,7 +6214,6 @@ zfs_deallocate(struct vop_deallocate_args *ap)
62146214
}
62156215
#endif
62166216

6217-
#if 0
62186217
#ifndef _SYS_SYSPROTO_H_
62196218
struct vop_copy_file_range_args {
62206219
struct vnode *a_invp;
@@ -6245,6 +6244,11 @@ zfs_freebsd_copy_file_range(struct vop_copy_file_range_args *ap)
62456244
int error;
62466245
uint64_t len = *ap->a_lenp;
62476246

6247+
if (!zfs_bclone_enabled) {
6248+
mp = NULL;
6249+
goto bad_write_fallback;
6250+
}
6251+
62486252
/*
62496253
* TODO: If offset/length is not aligned to recordsize, use
62506254
* vn_generic_copy_file_range() on this fragment.
@@ -6310,7 +6314,6 @@ zfs_freebsd_copy_file_range(struct vop_copy_file_range_args *ap)
63106314
ap->a_incred, ap->a_outcred, ap->a_fsizetd);
63116315
return (error);
63126316
}
6313-
#endif
63146317

63156318
struct vop_vector zfs_vnodeops;
63166319
struct vop_vector zfs_fifoops;
@@ -6375,6 +6378,7 @@ struct vop_vector zfs_vnodeops = {
63756378
#if __FreeBSD_version >= 1400043
63766379
.vop_add_writecount = vop_stdadd_writecount_nomsync,
63776380
#endif
6381+
.vop_copy_file_range = zfs_freebsd_copy_file_range,
63786382
};
63796383
VFS_VOP_VECTOR_REGISTER(zfs_vnodeops);
63806384

0 commit comments

Comments
 (0)