BRT: Move zfs_bclone_enabled and zfs_bclone_wait_dirty tunables

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>
This commit is contained in:
Brian Behlendorf 2024-02-05 10:38:28 -08:00
parent 26128c6a7f
commit 4d5e9ea425
7 changed files with 29 additions and 26 deletions

View File

@ -285,7 +285,6 @@ typedef struct zfid_long {
#define LONG_FID_LEN (sizeof (zfid_long_t) - sizeof (uint16_t)) #define LONG_FID_LEN (sizeof (zfid_long_t) - sizeof (uint16_t))
extern int zfs_super_owner; extern int zfs_super_owner;
extern int zfs_bclone_enabled;
extern void zfs_init(void); extern void zfs_init(void);
extern void zfs_fini(void); extern void zfs_fini(void);

View File

@ -45,9 +45,6 @@ extern "C" {
typedef struct zfsvfs zfsvfs_t; typedef struct zfsvfs zfsvfs_t;
struct znode; 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 * This structure emulates the vfs_t from other platforms. It's purpose
* is to facilitate the handling of mount options and minimize structural * is to facilitate the handling of mount options and minimize structural

View File

@ -24,8 +24,11 @@
#ifndef _SYS_FS_ZFS_VNOPS_H #ifndef _SYS_FS_ZFS_VNOPS_H
#define _SYS_FS_ZFS_VNOPS_H #define _SYS_FS_ZFS_VNOPS_H
#include <sys/zfs_vnops_os.h> #include <sys/zfs_vnops_os.h>
extern int zfs_bclone_enabled;
extern int zfs_fsync(znode_t *, int, cred_t *); extern int zfs_fsync(znode_t *, int, cred_t *);
extern int zfs_read(znode_t *, zfs_uio_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 *); extern int zfs_write(znode_t *, zfs_uio_t *, int, cred_t *);

View File

@ -89,14 +89,6 @@ int zfs_debug_level;
SYSCTL_INT(_vfs_zfs, OID_AUTO, debug, CTLFLAG_RWTUN, &zfs_debug_level, 0, SYSCTL_INT(_vfs_zfs, OID_AUTO, debug, CTLFLAG_RWTUN, &zfs_debug_level, 0,
"Debug level"); "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 { struct zfs_jailparam {
int mount_snapshot; int mount_snapshot;
}; };

View File

@ -4255,13 +4255,4 @@ EXPORT_SYMBOL(zfs_map);
/* CSTYLED */ /* CSTYLED */
module_param(zfs_delete_blocks, ulong, 0644); module_param(zfs_delete_blocks, ulong, 0644);
MODULE_PARM_DESC(zfs_delete_blocks, "Delete files larger than N blocks async"); 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 #endif

View File

@ -31,9 +31,6 @@
#include <sys/zfs_vnops.h> #include <sys/zfs_vnops.h>
#include <sys/zfeature.h> #include <sys/zfeature.h>
int zfs_bclone_enabled = 1;
int zfs_bclone_wait_dirty = 0;
/* /*
* Clone part of a file via block cloning. * Clone part of a file via block cloning.
* *

View File

@ -58,6 +58,26 @@
#include <sys/zfs_vfsops.h> #include <sys/zfs_vfsops.h>
#include <sys/zfs_znode.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 int
zfs_fsync(znode_t *zp, int syncflag, cred_t *cr) zfs_fsync(znode_t *zp, int syncflag, cred_t *cr)
@ -182,8 +202,6 @@ zfs_access(znode_t *zp, int mode, int flag, cred_t *cr)
return (error); return (error);
} }
static uint64_t zfs_vnops_read_chunk_size = 1024 * 1024; /* Tunable */
/* /*
* Read bytes from specified file into supplied buffer. * Read bytes from specified file into supplied buffer.
* *
@ -1526,3 +1544,9 @@ EXPORT_SYMBOL(zfs_clone_range_replay);
ZFS_MODULE_PARAM(zfs_vnops, zfs_vnops_, read_chunk_size, U64, ZMOD_RW, ZFS_MODULE_PARAM(zfs_vnops, zfs_vnops_, read_chunk_size, U64, ZMOD_RW,
"Bytes to read per chunk"); "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");