Skip to content

Commit

Permalink
BRT: Move zfs_bclone_enabled and zfs_bclone_wait_dirty tunables
Browse files Browse the repository at this point in the history
Relocate declaration of zfs_bclone_enabled and zfs_bclone_wait_dirty
to the platform independant code.  Add some additional documention
to these tunables at the same time.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
  • Loading branch information
behlendorf committed Feb 5, 2024
1 parent 26128c6 commit 4d5e9ea
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 26 deletions.
1 change: 0 additions & 1 deletion include/os/freebsd/zfs/sys/zfs_vfsops_os.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ typedef struct zfid_long {
#define LONG_FID_LEN (sizeof (zfid_long_t) - sizeof (uint16_t))

extern int zfs_super_owner;
extern int zfs_bclone_enabled;

extern void zfs_init(void);
extern void zfs_fini(void);
Expand Down
3 changes: 0 additions & 3 deletions include/os/linux/zfs/sys/zfs_vfsops_os.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ extern "C" {
typedef struct zfsvfs zfsvfs_t;
struct znode;

extern int zfs_bclone_enabled;
extern int zfs_bclone_wait_dirty;

/*
* This structure emulates the vfs_t from other platforms. It's purpose
* is to facilitate the handling of mount options and minimize structural
Expand Down
3 changes: 3 additions & 0 deletions include/sys/zfs_vnops.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@

#ifndef _SYS_FS_ZFS_VNOPS_H
#define _SYS_FS_ZFS_VNOPS_H

#include <sys/zfs_vnops_os.h>

extern int zfs_bclone_enabled;

extern int zfs_fsync(znode_t *, int, cred_t *);
extern int zfs_read(znode_t *, zfs_uio_t *, int, cred_t *);
extern int zfs_write(znode_t *, zfs_uio_t *, int, cred_t *);
Expand Down
8 changes: 0 additions & 8 deletions module/os/freebsd/zfs/zfs_vfsops.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,6 @@ int zfs_debug_level;
SYSCTL_INT(_vfs_zfs, OID_AUTO, debug, CTLFLAG_RWTUN, &zfs_debug_level, 0,
"Debug level");

int zfs_bclone_enabled = 1;
SYSCTL_INT(_vfs_zfs, OID_AUTO, bclone_enabled, CTLFLAG_RWTUN,
&zfs_bclone_enabled, 0, "Enable block cloning");

int zfs_bclone_wait_dirty = 0;
SYSCTL_INT(_vfs_zfs, OID_AUTO, bclone_wait_dirty, CTLFLAG_RWTUN,
&zfs_bclone_wait_dirty, 0, "Wait for dirty blocks when cloning");

struct zfs_jailparam {
int mount_snapshot;
};
Expand Down
9 changes: 0 additions & 9 deletions module/os/linux/zfs/zfs_vnops_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -4255,13 +4255,4 @@ EXPORT_SYMBOL(zfs_map);
/* CSTYLED */
module_param(zfs_delete_blocks, ulong, 0644);
MODULE_PARM_DESC(zfs_delete_blocks, "Delete files larger than N blocks async");

/* CSTYLED */
module_param(zfs_bclone_enabled, int, 0644);
MODULE_PARM_DESC(zfs_bclone_enabled, "Enable block cloning");

/* CSTYLED */
module_param(zfs_bclone_wait_dirty, int, 0644);
MODULE_PARM_DESC(zfs_bclone_wait_dirty, "Wait for dirty blocks when cloning");

#endif
3 changes: 0 additions & 3 deletions module/os/linux/zfs/zpl_file_range.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
#include <sys/zfs_vnops.h>
#include <sys/zfeature.h>

int zfs_bclone_enabled = 1;
int zfs_bclone_wait_dirty = 0;

/*
* Clone part of a file via block cloning.
*
Expand Down
28 changes: 26 additions & 2 deletions module/zfs/zfs_vnops.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,26 @@
#include <sys/zfs_vfsops.h>
#include <sys/zfs_znode.h>

/*
* Enable the experimental block cloning feature. If this setting is 0, then
* even if feature@block_cloning is enabled, attempts to clone blocks will act
* as though the feature is disabled.
*/
int zfs_bclone_enabled = 1;

/*
* When set zfs_clone_range() waits for dirty data to be written to disk.
* This allows the clone operation to reliably succeed when a file is modified
* and then immediately cloned. For small files this may be slower than making
* a copy of the file and is therefore not the default. However, in certain
* scenarios this behavior may be desirable so a tunable is provided.
*/
static int zfs_bclone_wait_dirty = 0;

/*
* Maximum bytes to read per chunk in zfs_read().
*/
static uint64_t zfs_vnops_read_chunk_size = 1024 * 1024;

int
zfs_fsync(znode_t *zp, int syncflag, cred_t *cr)
Expand Down Expand Up @@ -182,8 +202,6 @@ zfs_access(znode_t *zp, int mode, int flag, cred_t *cr)
return (error);
}

static uint64_t zfs_vnops_read_chunk_size = 1024 * 1024; /* Tunable */

/*
* Read bytes from specified file into supplied buffer.
*
Expand Down Expand Up @@ -1526,3 +1544,9 @@ EXPORT_SYMBOL(zfs_clone_range_replay);

ZFS_MODULE_PARAM(zfs_vnops, zfs_vnops_, read_chunk_size, U64, ZMOD_RW,
"Bytes to read per chunk");

ZFS_MODULE_PARAM(zfs, zfs_, bclone_enabled, INT, ZMOD_RW,
"Enable block cloning");

ZFS_MODULE_PARAM(zfs, zfs_, bclone_wait_dirty, INT, ZMOD_RW,
"Wait for dirty blocks when cloning");

0 comments on commit 4d5e9ea

Please sign in to comment.