mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-17 01:51:00 +03:00
ab8d9c1783
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
102 lines
3.3 KiB
C
102 lines
3.3 KiB
C
/*
|
|
* CDDL HEADER START
|
|
*
|
|
* The contents of this file are subject to the terms of the
|
|
* Common Development and Distribution License (the "License").
|
|
* You may not use this file except in compliance with the License.
|
|
*
|
|
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
|
* or https://opensource.org/licenses/CDDL-1.0.
|
|
* See the License for the specific language governing permissions
|
|
* and limitations under the License.
|
|
*
|
|
* When distributing Covered Code, include this CDDL HEADER in each
|
|
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
|
* If applicable, add the following below this CDDL HEADER, with the
|
|
* fields enclosed by brackets "[]" replaced with your own identifying
|
|
* information: Portions Copyright [yyyy] [name of copyright owner]
|
|
*
|
|
* CDDL HEADER END
|
|
*/
|
|
|
|
|
|
#ifndef _ZFS_IOCTL_IMPL_H_
|
|
#define _ZFS_IOCTL_IMPL_H_
|
|
|
|
extern kmutex_t zfsdev_state_lock;
|
|
extern uint64_t zfs_max_nvlist_src_size;
|
|
|
|
typedef int zfs_ioc_legacy_func_t(zfs_cmd_t *);
|
|
typedef int zfs_ioc_func_t(const char *, nvlist_t *, nvlist_t *);
|
|
typedef int zfs_secpolicy_func_t(zfs_cmd_t *, nvlist_t *, cred_t *);
|
|
|
|
typedef enum {
|
|
POOL_CHECK_NONE = 1 << 0,
|
|
POOL_CHECK_SUSPENDED = 1 << 1,
|
|
POOL_CHECK_READONLY = 1 << 2,
|
|
} zfs_ioc_poolcheck_t;
|
|
|
|
typedef enum {
|
|
NO_NAME,
|
|
POOL_NAME,
|
|
DATASET_NAME,
|
|
ENTITY_NAME
|
|
} zfs_ioc_namecheck_t;
|
|
|
|
/*
|
|
* IOC Keys are used to document and validate user->kernel interface inputs.
|
|
* See zfs_keys_recv_new for an example declaration. Any key name that is not
|
|
* listed will be rejected as input.
|
|
*
|
|
* The keyname 'optional' is always allowed, and must be an nvlist if present.
|
|
* Arguments which older kernels can safely ignore can be placed under the
|
|
* "optional" key.
|
|
*
|
|
* When adding new keys to an existing ioc for new functionality, consider:
|
|
* - adding an entry into zfs_sysfs.c zfs_features[] list
|
|
* - updating the libzfs_input_check.c test utility
|
|
*
|
|
* Note: in the ZK_WILDCARDLIST case, the name serves as documentation
|
|
* for the expected name (bookmark, snapshot, property, etc) but there
|
|
* is no validation in the preflight zfs_check_input_nvpairs() check.
|
|
*/
|
|
typedef enum {
|
|
ZK_OPTIONAL = 1 << 0, /* pair is optional */
|
|
ZK_WILDCARDLIST = 1 << 1, /* one or more unspecified key names */
|
|
} ioc_key_flag_t;
|
|
|
|
typedef struct zfs_ioc_key {
|
|
const char *zkey_name;
|
|
data_type_t zkey_type;
|
|
ioc_key_flag_t zkey_flags;
|
|
} zfs_ioc_key_t;
|
|
|
|
int zfs_secpolicy_config(zfs_cmd_t *, nvlist_t *, cred_t *);
|
|
|
|
void zfs_ioctl_register_dataset_nolog(zfs_ioc_t, zfs_ioc_legacy_func_t *,
|
|
zfs_secpolicy_func_t *, zfs_ioc_poolcheck_t);
|
|
|
|
void zfs_ioctl_register(const char *, zfs_ioc_t, zfs_ioc_func_t *,
|
|
zfs_secpolicy_func_t *, zfs_ioc_namecheck_t, zfs_ioc_poolcheck_t,
|
|
boolean_t, boolean_t, const zfs_ioc_key_t *, size_t);
|
|
|
|
uint64_t zfs_max_nvlist_src_size_os(void);
|
|
void zfs_ioctl_update_mount_cache(const char *dsname);
|
|
void zfs_ioctl_init_os(void);
|
|
|
|
boolean_t zfs_vfs_held(zfsvfs_t *);
|
|
int zfs_vfs_ref(zfsvfs_t **);
|
|
void zfs_vfs_rele(zfsvfs_t *);
|
|
|
|
long zfsdev_ioctl_common(uint_t, zfs_cmd_t *, int);
|
|
int zfsdev_attach(void);
|
|
void zfsdev_detach(void);
|
|
void zfsdev_private_set_state(void *, zfsdev_state_t *);
|
|
zfsdev_state_t *zfsdev_private_get_state(void *);
|
|
int zfsdev_state_init(void *);
|
|
void zfsdev_state_destroy(void *);
|
|
int zfs_kmod_init(void);
|
|
void zfs_kmod_fini(void);
|
|
|
|
#endif
|