FreeBSD: Fix ZFS so that snapshots under .zfs/snapshot are NFS visible
[zfs.git] / include / os / freebsd / spl / sys / mod_os.h
blob77ce75ca3f113d737cd18d5f0c5523c81f974b8c
1 /*
2 * Copyright (c) 2020 iXsystems, Inc.
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
26 * $FreeBSD$
29 #ifndef _SPL_MOD_H
30 #define _SPL_MOD_H
32 #include <sys/sysctl.h>
34 #define ZMOD_RW CTLFLAG_RWTUN
35 #define ZMOD_RD CTLFLAG_RDTUN
37 #define ZFS_MODULE_PARAM(scope_prefix, name_prefix, name, type, perm, desc) \
38 SYSCTL_DECL(_vfs_ ## scope_prefix); \
39 SYSCTL_##type(_vfs_ ## scope_prefix, OID_AUTO, name, perm, \
40 &name_prefix ## name, 0, desc)
42 #define ZFS_MODULE_PARAM_ARGS SYSCTL_HANDLER_ARGS
44 #define ZFS_MODULE_PARAM_CALL_IMPL(parent, name, perm, args, desc) \
45 SYSCTL_DECL(parent); \
46 SYSCTL_PROC(parent, OID_AUTO, name, CTLFLAG_MPSAFE | perm | args, desc)
48 #define ZFS_MODULE_PARAM_CALL( \
49 scope_prefix, name_prefix, name, func, _, perm, desc) \
50 ZFS_MODULE_PARAM_CALL_IMPL(_vfs_ ## scope_prefix, name, perm, \
51 func ## _args(name_prefix ## name), desc)
53 #define ZFS_MODULE_VIRTUAL_PARAM_CALL ZFS_MODULE_PARAM_CALL
55 #define param_set_arc_u64_args(var) \
56 CTLTYPE_U64, &var, 0, param_set_arc_u64, "QU"
58 #define param_set_arc_int_args(var) \
59 CTLTYPE_INT, &var, 0, param_set_arc_int, "I"
61 #define param_set_arc_min_args(var) \
62 CTLTYPE_U64, NULL, 0, param_set_arc_min, "QU"
64 #define param_set_arc_max_args(var) \
65 CTLTYPE_U64, NULL, 0, param_set_arc_max, "QU"
67 #define param_set_arc_free_target_args(var) \
68 CTLTYPE_UINT, NULL, 0, param_set_arc_free_target, "IU"
70 #define param_set_arc_no_grow_shift_args(var) \
71 CTLTYPE_INT, NULL, 0, param_set_arc_no_grow_shift, "I"
73 #define param_set_deadman_failmode_args(var) \
74 CTLTYPE_STRING, NULL, 0, param_set_deadman_failmode, "A"
76 #define param_set_deadman_synctime_args(var) \
77 CTLTYPE_U64, NULL, 0, param_set_deadman_synctime, "QU"
79 #define param_set_deadman_ziotime_args(var) \
80 CTLTYPE_U64, NULL, 0, param_set_deadman_ziotime, "QU"
82 #define param_set_multihost_interval_args(var) \
83 CTLTYPE_U64, NULL, 0, param_set_multihost_interval, "QU"
85 #define param_set_slop_shift_args(var) \
86 CTLTYPE_INT, NULL, 0, param_set_slop_shift, "I"
88 #define param_set_min_auto_ashift_args(var) \
89 CTLTYPE_UINT, NULL, 0, param_set_min_auto_ashift, "IU"
91 #define param_set_max_auto_ashift_args(var) \
92 CTLTYPE_UINT, NULL, 0, param_set_max_auto_ashift, "IU"
94 #define fletcher_4_param_set_args(var) \
95 CTLTYPE_STRING, NULL, 0, fletcher_4_param, "A"
97 #define blake3_param_set_args(var) \
98 CTLTYPE_STRING, NULL, 0, blake3_param, "A"
100 #define sha256_param_set_args(var) \
101 CTLTYPE_STRING, NULL, 0, sha256_param, "A"
103 #define sha512_param_set_args(var) \
104 CTLTYPE_STRING, NULL, 0, sha512_param, "A"
106 #include <sys/kernel.h>
107 #define module_init(fn) \
108 static void \
109 wrap_ ## fn(void *dummy __unused) \
111 fn(); \
113 SYSINIT(zfs_ ## fn, SI_SUB_LAST, SI_ORDER_FIRST, wrap_ ## fn, NULL)
115 #define module_init_early(fn) \
116 static void \
117 wrap_ ## fn(void *dummy __unused) \
119 fn(); \
121 SYSINIT(zfs_ ## fn, SI_SUB_INT_CONFIG_HOOKS, SI_ORDER_FIRST, wrap_ ## fn, NULL)
123 #define module_exit(fn) \
124 static void \
125 wrap_ ## fn(void *dummy __unused) \
127 fn(); \
129 SYSUNINIT(zfs_ ## fn, SI_SUB_LAST, SI_ORDER_FIRST, wrap_ ## fn, NULL)
131 #endif /* SPL_MOD_H */