2016-08-21 22:29:49 +03:00
|
|
|
/*
|
|
|
|
* 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 http://www.opensolaris.org/os/licensing.
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2016 Gvozden Neskovic <neskovic@gmail.com>.
|
2020-09-18 22:13:47 +03:00
|
|
|
* Copyright (c) 2020 by Delphix. All rights reserved.
|
2016-08-21 22:29:49 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _MOD_COMPAT_H
|
|
|
|
#define _MOD_COMPAT_H
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/moduleparam.h>
|
|
|
|
|
|
|
|
/* Grsecurity kernel API change */
|
|
|
|
#ifdef MODULE_PARAM_CALL_CONST
|
|
|
|
typedef const struct kernel_param zfs_kernel_param_t;
|
|
|
|
#else
|
|
|
|
typedef struct kernel_param zfs_kernel_param_t;
|
|
|
|
#endif
|
|
|
|
|
2019-09-06 00:49:49 +03:00
|
|
|
#define ZMOD_RW 0644
|
|
|
|
#define ZMOD_RD 0444
|
|
|
|
|
|
|
|
#define INT int
|
2022-01-21 19:07:15 +03:00
|
|
|
#define LONG long
|
|
|
|
/* BEGIN CSTYLED */
|
2019-09-06 00:49:49 +03:00
|
|
|
#define UINT uint
|
|
|
|
#define ULONG ulong
|
|
|
|
/* END CSTYLED */
|
2022-01-21 19:07:15 +03:00
|
|
|
#define STRING charp
|
2019-09-06 00:49:49 +03:00
|
|
|
|
|
|
|
enum scope_prefix_types {
|
|
|
|
zfs,
|
|
|
|
zfs_arc,
|
|
|
|
zfs_condense,
|
|
|
|
zfs_dbuf,
|
|
|
|
zfs_dbuf_cache,
|
2019-10-31 19:52:22 +03:00
|
|
|
zfs_deadman,
|
2020-04-15 21:14:47 +03:00
|
|
|
zfs_dedup,
|
2019-09-06 00:49:49 +03:00
|
|
|
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,
|
2020-04-15 21:14:47 +03:00
|
|
|
zfs_txg,
|
2019-09-06 00:49:49 +03:00
|
|
|
zfs_vdev,
|
|
|
|
zfs_vdev_cache,
|
2020-09-18 22:13:47 +03:00
|
|
|
zfs_vdev_file,
|
2019-09-06 00:49:49 +03:00
|
|
|
zfs_vdev_mirror,
|
2020-10-22 00:08:06 +03:00
|
|
|
zfs_vnops,
|
2020-02-18 22:22:56 +03:00
|
|
|
zfs_zevent,
|
2019-09-06 00:49:49 +03:00
|
|
|
zfs_zio,
|
2020-04-15 21:14:47 +03:00
|
|
|
zfs_zil
|
2019-09-06 00:49:49 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Declare a module parameter / sysctl node
|
|
|
|
*
|
2021-04-03 04:38:53 +03:00
|
|
|
* "scope_prefix" the part of the sysctl / sysfs tree the node resides under
|
2019-09-06 00:49:49 +03:00
|
|
|
* (currently a no-op on Linux)
|
2019-10-27 01:22:19 +03:00
|
|
|
* "name_prefix" the part of the variable name that will be excluded from the
|
2019-09-06 00:49:49 +03:00
|
|
|
* exported names on platforms with a hierarchical namespace
|
2019-10-27 01:22:19 +03:00
|
|
|
* "name" the part of the variable that will be exposed on platforms with a
|
2019-09-06 00:49:49 +03:00
|
|
|
* hierarchical namespace, or as name_prefix ## name on Linux
|
2019-10-27 01:22:19 +03:00
|
|
|
* "type" the variable type
|
|
|
|
* "perm" the permissions (read/write or read only)
|
|
|
|
* "desc" a brief description of the option
|
2019-09-06 00:49:49 +03:00
|
|
|
*
|
|
|
|
* Examples:
|
|
|
|
* ZFS_MODULE_PARAM(zfs_vdev_mirror, zfs_vdev_mirror_, rotating_inc, UINT,
|
2019-10-27 01:22:19 +03:00
|
|
|
* ZMOD_RW, "Rotating media load increment for non-seeking I/O's");
|
2019-09-06 00:49:49 +03:00
|
|
|
* on FreeBSD:
|
|
|
|
* vfs.zfs.vdev.mirror.rotating_inc
|
|
|
|
* on Linux:
|
|
|
|
* zfs_vdev_mirror_rotating_inc
|
|
|
|
*
|
2019-10-27 01:22:19 +03:00
|
|
|
* ZFS_MODULE_PARAM(zfs, , dmu_prefetch_max, UINT, ZMOD_RW,
|
|
|
|
* "Limit one prefetch call to this size");
|
2019-09-06 00:49:49 +03:00
|
|
|
* on FreeBSD:
|
|
|
|
* vfs.zfs.dmu_prefetch_max
|
|
|
|
* on Linux:
|
|
|
|
* dmu_prefetch_max
|
|
|
|
*/
|
|
|
|
#define ZFS_MODULE_PARAM(scope_prefix, name_prefix, name, type, perm, desc) \
|
2022-01-21 19:07:15 +03:00
|
|
|
CTASSERT_GLOBAL( \
|
|
|
|
sizeof (scope_prefix) == sizeof (enum scope_prefix_types)); \
|
2019-09-06 00:49:49 +03:00
|
|
|
module_param(name_prefix ## name, type, perm); \
|
|
|
|
MODULE_PARM_DESC(name_prefix ## name, desc)
|
|
|
|
|
2019-10-27 01:22:19 +03:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
* "setfunc" setter function
|
|
|
|
* "getfunc" getter function
|
|
|
|
* "perm" the permissions (read/write or read only)
|
|
|
|
* "desc" a brief description of the option
|
|
|
|
*
|
|
|
|
* Examples:
|
|
|
|
* ZFS_MODULE_PARAM_CALL(zfs_spa, spa_, slop_shift, param_set_slop_shift,
|
|
|
|
* param_get_int, ZMOD_RW, "Reserved free space in pool");
|
|
|
|
* on FreeBSD:
|
|
|
|
* vfs.zfs.spa_slop_shift
|
|
|
|
* on Linux:
|
|
|
|
* spa_slop_shift
|
|
|
|
*/
|
2022-01-21 19:07:15 +03:00
|
|
|
#define ZFS_MODULE_PARAM_CALL( \
|
|
|
|
scope_prefix, name_prefix, name, setfunc, getfunc, perm, desc) \
|
|
|
|
CTASSERT_GLOBAL( \
|
|
|
|
sizeof (scope_prefix) == sizeof (enum scope_prefix_types)); \
|
|
|
|
module_param_call(name_prefix ## name, setfunc, getfunc, \
|
|
|
|
&name_prefix ## name, perm); \
|
2019-10-27 01:22:19 +03:00
|
|
|
MODULE_PARM_DESC(name_prefix ## name, desc)
|
2019-09-06 00:49:49 +03:00
|
|
|
|
2020-12-03 00:45:08 +03:00
|
|
|
/*
|
|
|
|
* As above, but there is no variable with the name name_prefix ## name,
|
|
|
|
* so NULL is passed to module_param_call instead.
|
|
|
|
*/
|
2022-01-21 19:07:15 +03:00
|
|
|
#define ZFS_MODULE_VIRTUAL_PARAM_CALL( \
|
|
|
|
scope_prefix, name_prefix, name, setfunc, getfunc, perm, desc) \
|
|
|
|
CTASSERT_GLOBAL(\
|
|
|
|
sizeof (scope_prefix) == sizeof (enum scope_prefix_types)); \
|
2020-12-03 00:45:08 +03:00
|
|
|
module_param_call(name_prefix ## name, setfunc, getfunc, NULL, perm); \
|
|
|
|
MODULE_PARM_DESC(name_prefix ## name, desc)
|
|
|
|
|
2020-04-07 20:06:22 +03:00
|
|
|
#define ZFS_MODULE_PARAM_ARGS const char *buf, zfs_kernel_param_t *kp
|
|
|
|
|
2019-11-01 20:41:03 +03:00
|
|
|
#define ZFS_MODULE_DESCRIPTION(s) MODULE_DESCRIPTION(s)
|
|
|
|
#define ZFS_MODULE_AUTHOR(s) MODULE_AUTHOR(s)
|
|
|
|
#define ZFS_MODULE_LICENSE(s) MODULE_LICENSE(s)
|
|
|
|
#define ZFS_MODULE_VERSION(s) MODULE_VERSION(s)
|
|
|
|
|
2020-12-10 08:29:00 +03:00
|
|
|
#define module_init_early(fn) module_init(fn)
|
|
|
|
|
2016-08-21 22:29:49 +03:00
|
|
|
#endif /* _MOD_COMPAT_H */
|