mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-23 19:04:45 +03:00
Cleanup: 64-bit kernel module parameters should use fixed width types
Various module parameters such as `zfs_arc_max` were originally `uint64_t` on OpenSolaris/Illumos, but were changed to `unsigned long` for Linux compatibility because Linux's kernel default module parameter implementation did not support 64-bit types on 32-bit platforms. This caused problems when porting OpenZFS to Windows because its LLP64 memory model made `unsigned long` a 32-bit type on 64-bit, which created the undesireable situation that parameters that should accept 64-bit values could not on 64-bit Windows. Upon inspection, it turns out that the Linux kernel module parameter interface is extensible, such that we are allowed to define our own types. Rather than maintaining the original type change via hacks to to continue shrinking module parameters on 32-bit Linux, we implement support for 64-bit module parameters on Linux. After doing a review of all 64-bit kernel parameters (found via the man page and also proposed changes by Andrew Innes), the kernel module parameters fell into a few groups: Parameters that were originally 64-bit on Illumos: * dbuf_cache_max_bytes * dbuf_metadata_cache_max_bytes * l2arc_feed_min_ms * l2arc_feed_secs * l2arc_headroom * l2arc_headroom_boost * l2arc_write_boost * l2arc_write_max * metaslab_aliquot * metaslab_force_ganging * zfetch_array_rd_sz * zfs_arc_max * zfs_arc_meta_limit * zfs_arc_meta_min * zfs_arc_min * zfs_async_block_max_blocks * zfs_condense_max_obsolete_bytes * zfs_condense_min_mapping_bytes * zfs_deadman_checktime_ms * zfs_deadman_synctime_ms * zfs_initialize_chunk_size * zfs_initialize_value * zfs_lua_max_instrlimit * zfs_lua_max_memlimit * zil_slog_bulk Parameters that were originally 32-bit on Illumos: * zfs_per_txg_dirty_frees_percent Parameters that were originally `ssize_t` on Illumos: * zfs_immediate_write_sz Note that `ssize_t` is `int32_t` on 32-bit and `int64_t` on 64-bit. It has been upgraded to 64-bit. Parameters that were `long`/`unsigned long` because of Linux/FreeBSD influence: * l2arc_rebuild_blocks_min_l2size * zfs_key_max_salt_uses * zfs_max_log_walking * zfs_max_logsm_summary_length * zfs_metaslab_max_size_cache_sec * zfs_min_metaslabs_to_flush * zfs_multihost_interval * zfs_unflushed_log_block_max * zfs_unflushed_log_block_min * zfs_unflushed_log_block_pct * zfs_unflushed_max_mem_amt * zfs_unflushed_max_mem_ppm New parameters that do not exist in Illumos: * l2arc_trim_ahead * vdev_file_logical_ashift * vdev_file_physical_ashift * zfs_arc_dnode_limit * zfs_arc_dnode_limit_percent * zfs_arc_dnode_reduce_percent * zfs_arc_meta_limit_percent * zfs_arc_sys_free * zfs_deadman_ziotime_ms * zfs_delete_blocks * zfs_history_output_max * zfs_livelist_max_entries * zfs_max_async_dedup_frees * zfs_max_nvlist_src_size * zfs_rebuild_max_segment * zfs_rebuild_vdev_limit * zfs_unflushed_log_txg_max * zfs_vdev_max_auto_ashift * zfs_vdev_min_auto_ashift * zfs_vnops_read_chunk_size * zvol_max_discard_blocks Rather than clutter the lists with commentary, the module parameters that need comments are repeated below. A few parameters were defined in Linux/FreeBSD specific code, where the use of ulong/long is not an issue for portability, so we leave them alone: * zfs_delete_blocks * zfs_key_max_salt_uses * zvol_max_discard_blocks The documentation for a few parameters was found to be incorrect: * zfs_deadman_checktime_ms - incorrectly documented as int * zfs_delete_blocks - not documented as Linux only * zfs_history_output_max - incorrectly documented as int * zfs_vnops_read_chunk_size - incorrectly documented as long * zvol_max_discard_blocks - incorrectly documented as ulong The documentation for these has been fixed, alongside the changes to document the switch to fixed width types. In addition, several kernel module parameters were percentages or held ashift values, so being 64-bit never made sense for them. They have been downgraded to 32-bit: * vdev_file_logical_ashift * vdev_file_physical_ashift * zfs_arc_dnode_limit_percent * zfs_arc_dnode_reduce_percent * zfs_arc_meta_limit_percent * zfs_per_txg_dirty_frees_percent * zfs_unflushed_log_block_pct * zfs_vdev_max_auto_ashift * zfs_vdev_min_auto_ashift Of special note are `zfs_vdev_max_auto_ashift` and `zfs_vdev_min_auto_ashift`, which were already defined as `uint64_t`, and passed to the kernel as `ulong`. This is inherently buggy on big endian 32-bit Linux, since the values would not be written to the correct locations. 32-bit FreeBSD was unaffected because its sysctl code correctly treated this as a `uint64_t`. Lastly, a code comment suggests that `zfs_arc_sys_free` is Linux-specific, but there is nothing to indicate to me that it is Linux-specific. Nothing was done about that. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Jorgen Lundman <lundman@lundman.net> Reviewed-by: Ryan Moeller <ryan@iXsystems.com> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Original-patch-by: Andrew Innes <andrew.c12@gmail.com> Original-patch-by: Jorgen Lundman <lundman@lundman.net> Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu> Closes #13984 Closes #14004
This commit is contained in:
committed by
Brian Behlendorf
parent
ff7a0a108f
commit
ab8d9c1783
+38
-38
@@ -419,12 +419,12 @@ boolean_t arc_warm;
|
||||
/*
|
||||
* These tunables are for performance analysis.
|
||||
*/
|
||||
unsigned long zfs_arc_max = 0;
|
||||
unsigned long zfs_arc_min = 0;
|
||||
unsigned long zfs_arc_meta_limit = 0;
|
||||
unsigned long zfs_arc_meta_min = 0;
|
||||
static unsigned long zfs_arc_dnode_limit = 0;
|
||||
static unsigned long zfs_arc_dnode_reduce_percent = 10;
|
||||
uint64_t zfs_arc_max = 0;
|
||||
uint64_t zfs_arc_min = 0;
|
||||
uint64_t zfs_arc_meta_limit = 0;
|
||||
uint64_t zfs_arc_meta_min = 0;
|
||||
static uint64_t zfs_arc_dnode_limit = 0;
|
||||
static uint_t zfs_arc_dnode_reduce_percent = 10;
|
||||
static uint_t zfs_arc_grow_retry = 0;
|
||||
static uint_t zfs_arc_shrink_shift = 0;
|
||||
static uint_t zfs_arc_p_min_shift = 0;
|
||||
@@ -449,17 +449,17 @@ int zfs_compressed_arc_enabled = B_TRUE;
|
||||
* ARC will evict meta buffers that exceed arc_meta_limit. This
|
||||
* tunable make arc_meta_limit adjustable for different workloads.
|
||||
*/
|
||||
static unsigned long zfs_arc_meta_limit_percent = 75;
|
||||
static uint64_t zfs_arc_meta_limit_percent = 75;
|
||||
|
||||
/*
|
||||
* Percentage that can be consumed by dnodes of ARC meta buffers.
|
||||
*/
|
||||
static unsigned long zfs_arc_dnode_limit_percent = 10;
|
||||
static uint_t zfs_arc_dnode_limit_percent = 10;
|
||||
|
||||
/*
|
||||
* These tunables are Linux-specific
|
||||
*/
|
||||
static unsigned long zfs_arc_sys_free = 0;
|
||||
static uint64_t zfs_arc_sys_free = 0;
|
||||
static uint_t zfs_arc_min_prefetch_ms = 0;
|
||||
static uint_t zfs_arc_min_prescient_prefetch_ms = 0;
|
||||
static int zfs_arc_p_dampener_disable = 1;
|
||||
@@ -781,12 +781,12 @@ uint64_t zfs_crc64_table[256];
|
||||
#define L2ARC_FEED_TYPES 4
|
||||
|
||||
/* L2ARC Performance Tunables */
|
||||
unsigned long l2arc_write_max = L2ARC_WRITE_SIZE; /* def max write size */
|
||||
unsigned long l2arc_write_boost = L2ARC_WRITE_SIZE; /* extra warmup write */
|
||||
unsigned long l2arc_headroom = L2ARC_HEADROOM; /* # of dev writes */
|
||||
unsigned long l2arc_headroom_boost = L2ARC_HEADROOM_BOOST;
|
||||
unsigned long l2arc_feed_secs = L2ARC_FEED_SECS; /* interval seconds */
|
||||
unsigned long l2arc_feed_min_ms = L2ARC_FEED_MIN_MS; /* min interval msecs */
|
||||
uint64_t l2arc_write_max = L2ARC_WRITE_SIZE; /* def max write size */
|
||||
uint64_t l2arc_write_boost = L2ARC_WRITE_SIZE; /* extra warmup write */
|
||||
uint64_t l2arc_headroom = L2ARC_HEADROOM; /* # of dev writes */
|
||||
uint64_t l2arc_headroom_boost = L2ARC_HEADROOM_BOOST;
|
||||
uint64_t l2arc_feed_secs = L2ARC_FEED_SECS; /* interval seconds */
|
||||
uint64_t l2arc_feed_min_ms = L2ARC_FEED_MIN_MS; /* min interval msecs */
|
||||
int l2arc_noprefetch = B_TRUE; /* don't cache prefetch bufs */
|
||||
int l2arc_feed_again = B_TRUE; /* turbo warmup */
|
||||
int l2arc_norw = B_FALSE; /* no reads during writes */
|
||||
@@ -909,7 +909,7 @@ static int l2arc_mfuonly = 0;
|
||||
* will vary depending of how well the specific device handles
|
||||
* these commands.
|
||||
*/
|
||||
static unsigned long l2arc_trim_ahead = 0;
|
||||
static uint64_t l2arc_trim_ahead = 0;
|
||||
|
||||
/*
|
||||
* Performance tuning of L2ARC persistence:
|
||||
@@ -925,7 +925,7 @@ static unsigned long l2arc_trim_ahead = 0;
|
||||
* not to waste space.
|
||||
*/
|
||||
static int l2arc_rebuild_enabled = B_TRUE;
|
||||
static unsigned long l2arc_rebuild_blocks_min_l2size = 1024 * 1024 * 1024;
|
||||
static uint64_t l2arc_rebuild_blocks_min_l2size = 1024 * 1024 * 1024;
|
||||
|
||||
/* L2ARC persistence rebuild control routines. */
|
||||
void l2arc_rebuild_vdev(vdev_t *vd, boolean_t reopen);
|
||||
@@ -11077,20 +11077,20 @@ EXPORT_SYMBOL(arc_add_prune_callback);
|
||||
EXPORT_SYMBOL(arc_remove_prune_callback);
|
||||
|
||||
ZFS_MODULE_PARAM_CALL(zfs_arc, zfs_arc_, min, param_set_arc_min,
|
||||
param_get_ulong, ZMOD_RW, "Minimum ARC size in bytes");
|
||||
spl_param_get_u64, ZMOD_RW, "Minimum ARC size in bytes");
|
||||
|
||||
ZFS_MODULE_PARAM_CALL(zfs_arc, zfs_arc_, max, param_set_arc_max,
|
||||
param_get_ulong, ZMOD_RW, "Maximum ARC size in bytes");
|
||||
spl_param_get_u64, ZMOD_RW, "Maximum ARC size in bytes");
|
||||
|
||||
ZFS_MODULE_PARAM_CALL(zfs_arc, zfs_arc_, meta_limit, param_set_arc_long,
|
||||
param_get_ulong, ZMOD_RW, "Metadata limit for ARC size in bytes");
|
||||
ZFS_MODULE_PARAM_CALL(zfs_arc, zfs_arc_, meta_limit, param_set_arc_u64,
|
||||
spl_param_get_u64, ZMOD_RW, "Metadata limit for ARC size in bytes");
|
||||
|
||||
ZFS_MODULE_PARAM_CALL(zfs_arc, zfs_arc_, meta_limit_percent,
|
||||
param_set_arc_long, param_get_ulong, ZMOD_RW,
|
||||
param_set_arc_int, param_get_uint, ZMOD_RW,
|
||||
"Percent of ARC size for ARC meta limit");
|
||||
|
||||
ZFS_MODULE_PARAM_CALL(zfs_arc, zfs_arc_, meta_min, param_set_arc_long,
|
||||
param_get_ulong, ZMOD_RW, "Minimum ARC metadata size in bytes");
|
||||
ZFS_MODULE_PARAM_CALL(zfs_arc, zfs_arc_, meta_min, param_set_arc_u64,
|
||||
spl_param_get_u64, ZMOD_RW, "Minimum ARC metadata size in bytes");
|
||||
|
||||
ZFS_MODULE_PARAM(zfs_arc, zfs_arc_, meta_prune, INT, ZMOD_RW,
|
||||
"Meta objects to scan for prune");
|
||||
@@ -11129,25 +11129,25 @@ ZFS_MODULE_PARAM_CALL(zfs_arc, zfs_arc_, min_prescient_prefetch_ms,
|
||||
param_set_arc_int, param_get_uint, ZMOD_RW,
|
||||
"Min life of prescient prefetched block in ms");
|
||||
|
||||
ZFS_MODULE_PARAM(zfs_l2arc, l2arc_, write_max, ULONG, ZMOD_RW,
|
||||
ZFS_MODULE_PARAM(zfs_l2arc, l2arc_, write_max, U64, ZMOD_RW,
|
||||
"Max write bytes per interval");
|
||||
|
||||
ZFS_MODULE_PARAM(zfs_l2arc, l2arc_, write_boost, ULONG, ZMOD_RW,
|
||||
ZFS_MODULE_PARAM(zfs_l2arc, l2arc_, write_boost, U64, ZMOD_RW,
|
||||
"Extra write bytes during device warmup");
|
||||
|
||||
ZFS_MODULE_PARAM(zfs_l2arc, l2arc_, headroom, ULONG, ZMOD_RW,
|
||||
ZFS_MODULE_PARAM(zfs_l2arc, l2arc_, headroom, U64, ZMOD_RW,
|
||||
"Number of max device writes to precache");
|
||||
|
||||
ZFS_MODULE_PARAM(zfs_l2arc, l2arc_, headroom_boost, ULONG, ZMOD_RW,
|
||||
ZFS_MODULE_PARAM(zfs_l2arc, l2arc_, headroom_boost, U64, ZMOD_RW,
|
||||
"Compressed l2arc_headroom multiplier");
|
||||
|
||||
ZFS_MODULE_PARAM(zfs_l2arc, l2arc_, trim_ahead, ULONG, ZMOD_RW,
|
||||
ZFS_MODULE_PARAM(zfs_l2arc, l2arc_, trim_ahead, U64, ZMOD_RW,
|
||||
"TRIM ahead L2ARC write size multiplier");
|
||||
|
||||
ZFS_MODULE_PARAM(zfs_l2arc, l2arc_, feed_secs, ULONG, ZMOD_RW,
|
||||
ZFS_MODULE_PARAM(zfs_l2arc, l2arc_, feed_secs, U64, ZMOD_RW,
|
||||
"Seconds between L2ARC writing");
|
||||
|
||||
ZFS_MODULE_PARAM(zfs_l2arc, l2arc_, feed_min_ms, ULONG, ZMOD_RW,
|
||||
ZFS_MODULE_PARAM(zfs_l2arc, l2arc_, feed_min_ms, U64, ZMOD_RW,
|
||||
"Min feed interval in milliseconds");
|
||||
|
||||
ZFS_MODULE_PARAM(zfs_l2arc, l2arc_, noprefetch, INT, ZMOD_RW,
|
||||
@@ -11165,7 +11165,7 @@ ZFS_MODULE_PARAM(zfs_l2arc, l2arc_, meta_percent, UINT, ZMOD_RW,
|
||||
ZFS_MODULE_PARAM(zfs_l2arc, l2arc_, rebuild_enabled, INT, ZMOD_RW,
|
||||
"Rebuild the L2ARC when importing a pool");
|
||||
|
||||
ZFS_MODULE_PARAM(zfs_l2arc, l2arc_, rebuild_blocks_min_l2size, ULONG, ZMOD_RW,
|
||||
ZFS_MODULE_PARAM(zfs_l2arc, l2arc_, rebuild_blocks_min_l2size, U64, ZMOD_RW,
|
||||
"Min size in bytes to write rebuild log blocks in L2ARC");
|
||||
|
||||
ZFS_MODULE_PARAM(zfs_l2arc, l2arc_, mfuonly, INT, ZMOD_RW,
|
||||
@@ -11177,17 +11177,17 @@ ZFS_MODULE_PARAM(zfs_l2arc, l2arc_, exclude_special, INT, ZMOD_RW,
|
||||
ZFS_MODULE_PARAM_CALL(zfs_arc, zfs_arc_, lotsfree_percent, param_set_arc_int,
|
||||
param_get_uint, ZMOD_RW, "System free memory I/O throttle in bytes");
|
||||
|
||||
ZFS_MODULE_PARAM_CALL(zfs_arc, zfs_arc_, sys_free, param_set_arc_long,
|
||||
param_get_ulong, ZMOD_RW, "System free memory target size in bytes");
|
||||
ZFS_MODULE_PARAM_CALL(zfs_arc, zfs_arc_, sys_free, param_set_arc_u64,
|
||||
spl_param_get_u64, ZMOD_RW, "System free memory target size in bytes");
|
||||
|
||||
ZFS_MODULE_PARAM_CALL(zfs_arc, zfs_arc_, dnode_limit, param_set_arc_long,
|
||||
param_get_ulong, ZMOD_RW, "Minimum bytes of dnodes in ARC");
|
||||
ZFS_MODULE_PARAM_CALL(zfs_arc, zfs_arc_, dnode_limit, param_set_arc_u64,
|
||||
spl_param_get_u64, ZMOD_RW, "Minimum bytes of dnodes in ARC");
|
||||
|
||||
ZFS_MODULE_PARAM_CALL(zfs_arc, zfs_arc_, dnode_limit_percent,
|
||||
param_set_arc_long, param_get_ulong, ZMOD_RW,
|
||||
param_set_arc_int, param_get_uint, ZMOD_RW,
|
||||
"Percent of ARC meta buffers for dnodes");
|
||||
|
||||
ZFS_MODULE_PARAM(zfs_arc, zfs_arc_, dnode_reduce_percent, ULONG, ZMOD_RW,
|
||||
ZFS_MODULE_PARAM(zfs_arc, zfs_arc_, dnode_reduce_percent, UINT, ZMOD_RW,
|
||||
"Percentage of excess dnodes to try to unpin");
|
||||
|
||||
ZFS_MODULE_PARAM(zfs_arc, zfs_arc_, eviction_pct, UINT, ZMOD_RW,
|
||||
|
||||
Reference in New Issue
Block a user