]> git.proxmox.com Git - mirror_zfs.git/blob - include/os/linux/kernel/linux/mod_compat.h
Enable zpool events tunables and tests on FreeBSD
[mirror_zfs.git] / include / os / linux / kernel / linux / mod_compat.h
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>.
24 */
25
26 #ifndef _MOD_COMPAT_H
27 #define _MOD_COMPAT_H
28
29 #include <linux/module.h>
30 #include <linux/moduleparam.h>
31
32 /* Grsecurity kernel API change */
33 #ifdef MODULE_PARAM_CALL_CONST
34 typedef const struct kernel_param zfs_kernel_param_t;
35 #else
36 typedef struct kernel_param zfs_kernel_param_t;
37 #endif
38
39 #define ZMOD_RW 0644
40 #define ZMOD_RD 0444
41
42 /* BEGIN CSTYLED */
43 #define INT int
44 #define UINT uint
45 #define ULONG ulong
46 #define LONG long
47 #define STRING charp
48 /* END CSTYLED */
49
50 enum scope_prefix_types {
51 zfs,
52 zfs_arc,
53 zfs_condense,
54 zfs_dbuf,
55 zfs_dbuf_cache,
56 zfs_deadman,
57 zfs_l2arc,
58 zfs_livelist,
59 zfs_livelist_condense,
60 zfs_lua,
61 zfs_metaslab,
62 zfs_mg,
63 zfs_multihost,
64 zfs_prefetch,
65 zfs_reconstruct,
66 zfs_recv,
67 zfs_send,
68 zfs_spa,
69 zfs_trim,
70 zfs_vdev,
71 zfs_vdev_cache,
72 zfs_vdev_mirror,
73 zfs_zevent,
74 zfs_zio,
75 zfs_zil,
76 spa
77 };
78
79 /*
80 * Declare a module parameter / sysctl node
81 *
82 * "scope_prefix" the part of the the sysctl / sysfs tree the node resides under
83 * (currently a no-op on Linux)
84 * "name_prefix" the part of the variable name that will be excluded from the
85 * exported names on platforms with a hierarchical namespace
86 * "name" the part of the variable that will be exposed on platforms with a
87 * hierarchical namespace, or as name_prefix ## name on Linux
88 * "type" the variable type
89 * "perm" the permissions (read/write or read only)
90 * "desc" a brief description of the option
91 *
92 * Examples:
93 * ZFS_MODULE_PARAM(zfs_vdev_mirror, zfs_vdev_mirror_, rotating_inc, UINT,
94 * ZMOD_RW, "Rotating media load increment for non-seeking I/O's");
95 * on FreeBSD:
96 * vfs.zfs.vdev.mirror.rotating_inc
97 * on Linux:
98 * zfs_vdev_mirror_rotating_inc
99 *
100 * ZFS_MODULE_PARAM(zfs, , dmu_prefetch_max, UINT, ZMOD_RW,
101 * "Limit one prefetch call to this size");
102 * on FreeBSD:
103 * vfs.zfs.dmu_prefetch_max
104 * on Linux:
105 * dmu_prefetch_max
106 */
107 /* BEGIN CSTYLED */
108 #define ZFS_MODULE_PARAM(scope_prefix, name_prefix, name, type, perm, desc) \
109 CTASSERT_GLOBAL((sizeof (scope_prefix) == sizeof (enum scope_prefix_types))); \
110 module_param(name_prefix ## name, type, perm); \
111 MODULE_PARM_DESC(name_prefix ## name, desc)
112 /* END CSTYLED */
113
114 /*
115 * Declare a module parameter / sysctl node
116 *
117 * "scope_prefix" the part of the the sysctl / sysfs tree the node resides under
118 * (currently a no-op on Linux)
119 * "name_prefix" the part of the variable name that will be excluded from the
120 * exported names on platforms with a hierarchical namespace
121 * "name" the part of the variable that will be exposed on platforms with a
122 * hierarchical namespace, or as name_prefix ## name on Linux
123 * "setfunc" setter function
124 * "getfunc" getter function
125 * "perm" the permissions (read/write or read only)
126 * "desc" a brief description of the option
127 *
128 * Examples:
129 * ZFS_MODULE_PARAM_CALL(zfs_spa, spa_, slop_shift, param_set_slop_shift,
130 * param_get_int, ZMOD_RW, "Reserved free space in pool");
131 * on FreeBSD:
132 * vfs.zfs.spa_slop_shift
133 * on Linux:
134 * spa_slop_shift
135 */
136 /* BEGIN CSTYLED */
137 #define ZFS_MODULE_PARAM_CALL(scope_prefix, name_prefix, name, setfunc, getfunc, perm, desc) \
138 CTASSERT_GLOBAL((sizeof (scope_prefix) == sizeof (enum scope_prefix_types))); \
139 module_param_call(name_prefix ## name, setfunc, getfunc, &name_prefix ## name, perm); \
140 MODULE_PARM_DESC(name_prefix ## name, desc)
141 /* END CSTYLED */
142
143 #define ZFS_MODULE_DESCRIPTION(s) MODULE_DESCRIPTION(s)
144 #define ZFS_MODULE_AUTHOR(s) MODULE_AUTHOR(s)
145 #define ZFS_MODULE_LICENSE(s) MODULE_LICENSE(s)
146 #define ZFS_MODULE_VERSION(s) MODULE_VERSION(s)
147
148 #endif /* _MOD_COMPAT_H */