diff options
author | Matthew Macy <[email protected]> | 2019-09-05 14:49:49 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2019-09-05 14:49:49 -0700 |
commit | 03fdcb9adc596fb86a65edb56d8088b77ea2d891 (patch) | |
tree | c68cec08565296ad37d53677fdfbc4d5c6e7ef7d /include | |
parent | 65a91b166e66a57c44b62bb5ca20ccb6f0ecc46d (diff) |
Make module tunables cross platform
Adds ZFS_MODULE_PARAM to abstract module parameter
setting to operating systems other than Linux.
Reviewed-by: Jorgen Lundman <[email protected]>
Reviewed-by: Igor Kozhukhov <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Matt Macy <[email protected]>
Signed-off-by: Ryan Moeller <[email protected]>
Closes #9230
Diffstat (limited to 'include')
-rw-r--r-- | include/os/linux/kernel/linux/mod_compat.h | 73 | ||||
-rw-r--r-- | include/sys/zfs_context.h | 11 |
2 files changed, 84 insertions, 0 deletions
diff --git a/include/os/linux/kernel/linux/mod_compat.h b/include/os/linux/kernel/linux/mod_compat.h index 32aea4471..1f19f4b40 100644 --- a/include/os/linux/kernel/linux/mod_compat.h +++ b/include/os/linux/kernel/linux/mod_compat.h @@ -36,4 +36,77 @@ typedef const struct kernel_param zfs_kernel_param_t; typedef struct kernel_param zfs_kernel_param_t; #endif +#define ZMOD_RW 0644 +#define ZMOD_RD 0444 + +/* BEGIN CSTYLED */ +#define INT int +#define UINT uint +#define ULONG ulong +#define LONG long +#define STRING charp +/* END CSTYLED */ + +enum scope_prefix_types { + zfs, + zfs_arc, + zfs_condense, + zfs_dbuf, + zfs_dbuf_cache, + zfs_l2arc, + zfs_livelist, + zfs_livelist_condense, + zfs_lua, + zfs_metaslab, + zfs_mg, + zfs_multihost, + zfs_prefetch, + zfs_reconstruct, + zfs_recv, + zfs_send, + zfs_spa, + zfs_trim, + zfs_vdev, + zfs_vdev_cache, + zfs_vdev_mirror, + zfs_zio, + zfs_zil, +}; + +/* + * Declare a module parameter / sysctl node + * + * scope_prefix the part of the the sysctl / sysfs tree the node resides under + * (currently a no-op on Linux) + * name_prefix the part of the variable name that will be excluded from the + * exported names on platforms with a hierarchical namespace + * name the part of the variable that will be exposed on platforms with a + * hierarchical namespace, or as name_prefix ## name on Linux + * type the variable type + * perm the permissions (read/write or read only) + * desc a brief description of the option + * + * Examples: + * ZFS_MODULE_PARAM(zfs_vdev_mirror, zfs_vdev_mirror_, rotating_inc, UINT, + * ZMOD_RW, "Rotating media load increment for non-seeking I/O's"); + * on FreeBSD: + * vfs.zfs.vdev.mirror.rotating_inc + * on Linux: + * zfs_vdev_mirror_rotating_inc + * + * *ZFS_MODULE_PARAM(zfs, , dmu_prefetch_max, UINT, ZMOD_RW, + * "Limit one prefetch call to this size"); + * on FreeBSD: + * vfs.zfs.dmu_prefetch_max + * on Linux: + * dmu_prefetch_max + */ +/* BEGIN CSTYLED */ +#define ZFS_MODULE_PARAM(scope_prefix, name_prefix, name, type, perm, desc) \ + CTASSERT_GLOBAL((sizeof (scope_prefix) == sizeof (enum scope_prefix_types))); \ + module_param(name_prefix ## name, type, perm); \ + MODULE_PARM_DESC(name_prefix ## name, desc) +/* END CSTYLED */ + + #endif /* _MOD_COMPAT_H */ diff --git a/include/sys/zfs_context.h b/include/sys/zfs_context.h index 60a248486..a55009f35 100644 --- a/include/sys/zfs_context.h +++ b/include/sys/zfs_context.h @@ -65,6 +65,7 @@ #include <sys/procfs_list.h> #include <linux/dcache_compat.h> #include <linux/utsname_compat.h> +#include <linux/mod_compat.h> #else /* _KERNEL */ @@ -201,6 +202,16 @@ extern int aok; (unsigned long)i) /* + * Tunables. + */ +#define ZFS_MODULE_PARAM(scope_prefix, name_prefix, name, type, perm, desc) + +/* + * Exported symbols + */ +#define EXPORT_SYMBOL(x) + +/* * Threads. */ typedef pthread_t kthread_t; |