]>
Commit | Line | Data |
---|---|---|
9cc1844a GN |
1 | /* |
2 | * CDDL HEADER START | |
3 | * | |
4 | * The contents of this file are subject to the terms of the | |
5 | * Common Development and Distribution License (the "License"). | |
6 | * You may not use this file except in compliance with the License. | |
7 | * | |
8 | * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE | |
9 | * or http://www.opensolaris.org/os/licensing. | |
10 | * See the License for the specific language governing permissions | |
11 | * and limitations under the License. | |
12 | * | |
13 | * When distributing Covered Code, include this CDDL HEADER in each | |
14 | * file and include the License file at usr/src/OPENSOLARIS.LICENSE. | |
15 | * If applicable, add the following below this CDDL HEADER, with the | |
16 | * fields enclosed by brackets "[]" replaced with your own identifying | |
17 | * information: Portions Copyright [yyyy] [name of copyright owner] | |
18 | * | |
19 | * CDDL HEADER END | |
20 | */ | |
21 | ||
22 | /* | |
23 | * Copyright (C) 2016 Gvozden Neskovic <neskovic@gmail.com>. | |
c494aa7f | 24 | * Copyright (c) 2020 by Delphix. All rights reserved. |
9cc1844a GN |
25 | */ |
26 | ||
27 | #ifndef _MOD_COMPAT_H | |
28 | #define _MOD_COMPAT_H | |
29 | ||
30 | #include <linux/module.h> | |
31 | #include <linux/moduleparam.h> | |
32 | ||
33 | /* Grsecurity kernel API change */ | |
34 | #ifdef MODULE_PARAM_CALL_CONST | |
35 | typedef const struct kernel_param zfs_kernel_param_t; | |
36 | #else | |
37 | typedef struct kernel_param zfs_kernel_param_t; | |
38 | #endif | |
39 | ||
03fdcb9a MM |
40 | #define ZMOD_RW 0644 |
41 | #define ZMOD_RD 0444 | |
42 | ||
03fdcb9a | 43 | #define INT int |
7ada752a AZ |
44 | #define LONG long |
45 | /* BEGIN CSTYLED */ | |
03fdcb9a MM |
46 | #define UINT uint |
47 | #define ULONG ulong | |
03fdcb9a | 48 | /* END CSTYLED */ |
7ada752a | 49 | #define STRING charp |
03fdcb9a MM |
50 | |
51 | enum scope_prefix_types { | |
52 | zfs, | |
53 | zfs_arc, | |
54 | zfs_condense, | |
55 | zfs_dbuf, | |
56 | zfs_dbuf_cache, | |
2a3aa5a1 | 57 | zfs_deadman, |
a7929f31 | 58 | zfs_dedup, |
03fdcb9a MM |
59 | zfs_l2arc, |
60 | zfs_livelist, | |
61 | zfs_livelist_condense, | |
62 | zfs_lua, | |
63 | zfs_metaslab, | |
64 | zfs_mg, | |
65 | zfs_multihost, | |
66 | zfs_prefetch, | |
67 | zfs_reconstruct, | |
68 | zfs_recv, | |
69 | zfs_send, | |
70 | zfs_spa, | |
71 | zfs_trim, | |
a7929f31 | 72 | zfs_txg, |
03fdcb9a MM |
73 | zfs_vdev, |
74 | zfs_vdev_cache, | |
c494aa7f | 75 | zfs_vdev_file, |
03fdcb9a | 76 | zfs_vdev_mirror, |
e53d678d | 77 | zfs_vnops, |
5f087dda | 78 | zfs_zevent, |
03fdcb9a | 79 | zfs_zio, |
a7929f31 | 80 | zfs_zil |
03fdcb9a MM |
81 | }; |
82 | ||
83 | /* | |
84 | * Declare a module parameter / sysctl node | |
85 | * | |
bf169e9f | 86 | * "scope_prefix" the part of the sysctl / sysfs tree the node resides under |
03fdcb9a | 87 | * (currently a no-op on Linux) |
e3570464 | 88 | * "name_prefix" the part of the variable name that will be excluded from the |
03fdcb9a | 89 | * exported names on platforms with a hierarchical namespace |
e3570464 | 90 | * "name" the part of the variable that will be exposed on platforms with a |
03fdcb9a | 91 | * hierarchical namespace, or as name_prefix ## name on Linux |
e3570464 | 92 | * "type" the variable type |
93 | * "perm" the permissions (read/write or read only) | |
94 | * "desc" a brief description of the option | |
03fdcb9a MM |
95 | * |
96 | * Examples: | |
97 | * ZFS_MODULE_PARAM(zfs_vdev_mirror, zfs_vdev_mirror_, rotating_inc, UINT, | |
e3570464 | 98 | * ZMOD_RW, "Rotating media load increment for non-seeking I/O's"); |
03fdcb9a MM |
99 | * on FreeBSD: |
100 | * vfs.zfs.vdev.mirror.rotating_inc | |
101 | * on Linux: | |
102 | * zfs_vdev_mirror_rotating_inc | |
103 | * | |
e3570464 | 104 | * ZFS_MODULE_PARAM(zfs, , dmu_prefetch_max, UINT, ZMOD_RW, |
105 | * "Limit one prefetch call to this size"); | |
03fdcb9a MM |
106 | * on FreeBSD: |
107 | * vfs.zfs.dmu_prefetch_max | |
108 | * on Linux: | |
109 | * dmu_prefetch_max | |
110 | */ | |
03fdcb9a | 111 | #define ZFS_MODULE_PARAM(scope_prefix, name_prefix, name, type, perm, desc) \ |
7ada752a AZ |
112 | CTASSERT_GLOBAL( \ |
113 | sizeof (scope_prefix) == sizeof (enum scope_prefix_types)); \ | |
03fdcb9a MM |
114 | module_param(name_prefix ## name, type, perm); \ |
115 | MODULE_PARM_DESC(name_prefix ## name, desc) | |
03fdcb9a | 116 | |
e3570464 | 117 | /* |
118 | * Declare a module parameter / sysctl node | |
119 | * | |
120 | * "scope_prefix" the part of the the sysctl / sysfs tree the node resides under | |
121 | * (currently a no-op on Linux) | |
122 | * "name_prefix" the part of the variable name that will be excluded from the | |
123 | * exported names on platforms with a hierarchical namespace | |
124 | * "name" the part of the variable that will be exposed on platforms with a | |
125 | * hierarchical namespace, or as name_prefix ## name on Linux | |
126 | * "setfunc" setter function | |
127 | * "getfunc" getter function | |
128 | * "perm" the permissions (read/write or read only) | |
129 | * "desc" a brief description of the option | |
130 | * | |
131 | * Examples: | |
132 | * ZFS_MODULE_PARAM_CALL(zfs_spa, spa_, slop_shift, param_set_slop_shift, | |
133 | * param_get_int, ZMOD_RW, "Reserved free space in pool"); | |
134 | * on FreeBSD: | |
135 | * vfs.zfs.spa_slop_shift | |
136 | * on Linux: | |
137 | * spa_slop_shift | |
138 | */ | |
7ada752a AZ |
139 | #define ZFS_MODULE_PARAM_CALL( \ |
140 | scope_prefix, name_prefix, name, setfunc, getfunc, perm, desc) \ | |
141 | CTASSERT_GLOBAL( \ | |
142 | sizeof (scope_prefix) == sizeof (enum scope_prefix_types)); \ | |
143 | module_param_call(name_prefix ## name, setfunc, getfunc, \ | |
144 | &name_prefix ## name, perm); \ | |
e3570464 | 145 | MODULE_PARM_DESC(name_prefix ## name, desc) |
03fdcb9a | 146 | |
439dc034 RM |
147 | /* |
148 | * As above, but there is no variable with the name name_prefix ## name, | |
149 | * so NULL is passed to module_param_call instead. | |
150 | */ | |
7ada752a AZ |
151 | #define ZFS_MODULE_VIRTUAL_PARAM_CALL( \ |
152 | scope_prefix, name_prefix, name, setfunc, getfunc, perm, desc) \ | |
153 | CTASSERT_GLOBAL(\ | |
154 | sizeof (scope_prefix) == sizeof (enum scope_prefix_types)); \ | |
439dc034 RM |
155 | module_param_call(name_prefix ## name, setfunc, getfunc, NULL, perm); \ |
156 | MODULE_PARM_DESC(name_prefix ## name, desc) | |
439dc034 | 157 | |
7e3df9db RM |
158 | #define ZFS_MODULE_PARAM_ARGS const char *buf, zfs_kernel_param_t *kp |
159 | ||
4a2ed900 MM |
160 | #define ZFS_MODULE_DESCRIPTION(s) MODULE_DESCRIPTION(s) |
161 | #define ZFS_MODULE_AUTHOR(s) MODULE_AUTHOR(s) | |
162 | #define ZFS_MODULE_LICENSE(s) MODULE_LICENSE(s) | |
163 | #define ZFS_MODULE_VERSION(s) MODULE_VERSION(s) | |
164 | ||
e0716250 RM |
165 | #define module_init_early(fn) module_init(fn) |
166 | ||
9cc1844a | 167 | #endif /* _MOD_COMPAT_H */ |