]> git.proxmox.com Git - mirror_zfs.git/blame - config/kernel.m4
Linux 6.9 compat: bdev handles are now struct file
[mirror_zfs.git] / config / kernel.m4
CommitLineData
c9c0d073 1dnl #
fc0c72b1 2dnl # Default ZFS kernel configuration
c9c0d073
BB
3dnl #
4AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
9f0a21e6
MM
5 AM_COND_IF([BUILD_LINUX], [
6 dnl # Setup the kernel build environment.
7 ZFS_AC_KERNEL
8 ZFS_AC_QAT
608f8749 9
9f0a21e6 10 dnl # Sanity checks for module building and CONFIG_* defines
9f0a21e6 11 ZFS_AC_KERNEL_CONFIG_DEFINED
a0dfd98a 12 ZFS_AC_MODULE_SYMVERS
608f8749 13
9f0a21e6
MM
14 dnl # Sequential ZFS_LINUX_TRY_COMPILE tests
15 ZFS_AC_KERNEL_FPU_HEADER
8c7d604c 16 ZFS_AC_KERNEL_OBJTOOL_HEADER
9f0a21e6
MM
17 ZFS_AC_KERNEL_WAIT_QUEUE_ENTRY_T
18 ZFS_AC_KERNEL_MISC_MINOR
19 ZFS_AC_KERNEL_DECLARE_EVENT_CLASS
608f8749 20
9f0a21e6
MM
21 dnl # Parallel ZFS_LINUX_TEST_SRC / ZFS_LINUX_TEST_RESULT tests
22 ZFS_AC_KERNEL_TEST_SRC
23 ZFS_AC_KERNEL_TEST_RESULT
608f8749 24
9f0a21e6
MM
25 AS_IF([test "$LINUX_OBJ" != "$LINUX"], [
26 KERNEL_MAKE="$KERNEL_MAKE O=$LINUX_OBJ"
27 ])
608f8749 28
9f0a21e6
MM
29 AC_SUBST(KERNEL_MAKE)
30 ])
608f8749
BB
31])
32
33dnl #
34dnl # Generate and compile all of the kernel API test cases to determine
35dnl # which interfaces are available. By invoking the kernel build system
36dnl # only once the compilation can be done in parallel significantly
37dnl # speeding up the process.
38dnl #
39AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [
40 ZFS_AC_KERNEL_SRC_OBJTOOL
41 ZFS_AC_KERNEL_SRC_GLOBAL_PAGE_STATE
42 ZFS_AC_KERNEL_SRC_ACCESS_OK_TYPE
608f8749
BB
43 ZFS_AC_KERNEL_SRC_PDE_DATA
44 ZFS_AC_KERNEL_SRC_FALLOCATE
320f0c60
FY
45 ZFS_AC_KERNEL_SRC_FADVISE
46 ZFS_AC_KERNEL_SRC_GENERIC_FADVISE
608f8749
BB
47 ZFS_AC_KERNEL_SRC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
48 ZFS_AC_KERNEL_SRC_RWSEM
49 ZFS_AC_KERNEL_SRC_SCHED
50 ZFS_AC_KERNEL_SRC_USLEEP_RANGE
51 ZFS_AC_KERNEL_SRC_KMEM_CACHE
66955885 52 ZFS_AC_KERNEL_SRC_KVMALLOC
080102a1 53 ZFS_AC_KERNEL_SRC_VMALLOC_PAGE_KERNEL
608f8749
BB
54 ZFS_AC_KERNEL_SRC_WAIT
55 ZFS_AC_KERNEL_SRC_INODE_TIMES
56 ZFS_AC_KERNEL_SRC_INODE_LOCK
57 ZFS_AC_KERNEL_SRC_GROUP_INFO_GID
58 ZFS_AC_KERNEL_SRC_RW
59 ZFS_AC_KERNEL_SRC_TIMER_SETUP
608f8749 60 ZFS_AC_KERNEL_SRC_SUPER_USER_NS
0dd73648 61 ZFS_AC_KERNEL_SRC_PROC_OPERATIONS
608f8749 62 ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS
066e8252
BB
63 ZFS_AC_KERNEL_SRC_BIO
64 ZFS_AC_KERNEL_SRC_BLKDEV
65 ZFS_AC_KERNEL_SRC_BLK_QUEUE
026f126b 66 ZFS_AC_KERNEL_SRC_GENHD_FLAGS
19697e45 67 ZFS_AC_KERNEL_SRC_REVALIDATE_DISK
608f8749
BB
68 ZFS_AC_KERNEL_SRC_GET_DISK_RO
69 ZFS_AC_KERNEL_SRC_GENERIC_READLINK_GLOBAL
70 ZFS_AC_KERNEL_SRC_DISCARD_GRANULARITY
71 ZFS_AC_KERNEL_SRC_INODE_OWNER_OR_CAPABLE
72 ZFS_AC_KERNEL_SRC_XATTR
73 ZFS_AC_KERNEL_SRC_ACL
d4dc53da 74 ZFS_AC_KERNEL_SRC_INODE_SETATTR
608f8749
BB
75 ZFS_AC_KERNEL_SRC_INODE_GETATTR
76 ZFS_AC_KERNEL_SRC_INODE_SET_FLAGS
77 ZFS_AC_KERNEL_SRC_INODE_SET_IVERSION
78 ZFS_AC_KERNEL_SRC_SHOW_OPTIONS
79 ZFS_AC_KERNEL_SRC_FILE_INODE
80 ZFS_AC_KERNEL_SRC_FILE_DENTRY
81 ZFS_AC_KERNEL_SRC_FSYNC
82 ZFS_AC_KERNEL_SRC_AIO_FSYNC
83 ZFS_AC_KERNEL_SRC_EVICT_INODE
84 ZFS_AC_KERNEL_SRC_DIRTY_INODE
85 ZFS_AC_KERNEL_SRC_SHRINKER
e2a82961 86 ZFS_AC_KERNEL_SRC_MKDIR
066e8252 87 ZFS_AC_KERNEL_SRC_LOOKUP_FLAGS
e2a82961 88 ZFS_AC_KERNEL_SRC_CREATE
eebfd28e 89 ZFS_AC_KERNEL_SRC_PERMISSION
608f8749
BB
90 ZFS_AC_KERNEL_SRC_GET_LINK
91 ZFS_AC_KERNEL_SRC_PUT_LINK
92 ZFS_AC_KERNEL_SRC_TMPFILE
608f8749
BB
93 ZFS_AC_KERNEL_SRC_AUTOMOUNT
94 ZFS_AC_KERNEL_SRC_ENCODE_FH_WITH_INODE
95 ZFS_AC_KERNEL_SRC_COMMIT_METADATA
96 ZFS_AC_KERNEL_SRC_CLEAR_INODE
97 ZFS_AC_KERNEL_SRC_SETATTR_PREPARE
98 ZFS_AC_KERNEL_SRC_INSERT_INODE_LOCKED
99 ZFS_AC_KERNEL_SRC_DENTRY
86db35c4 100 ZFS_AC_KERNEL_SRC_DENTRY_ALIAS_D_U
608f8749
BB
101 ZFS_AC_KERNEL_SRC_TRUNCATE_SETSIZE
102 ZFS_AC_KERNEL_SRC_SECURITY_INODE
103 ZFS_AC_KERNEL_SRC_FST_MOUNT
104 ZFS_AC_KERNEL_SRC_BDI
105 ZFS_AC_KERNEL_SRC_SET_NLINK
608f8749
BB
106 ZFS_AC_KERNEL_SRC_SGET
107 ZFS_AC_KERNEL_SRC_LSEEK_EXECUTE
7dde17e8 108 ZFS_AC_KERNEL_SRC_VFS_FILEMAP_DIRTY_FOLIO
c2c2e7bb 109 ZFS_AC_KERNEL_SRC_VFS_READ_FOLIO
608f8749
BB
110 ZFS_AC_KERNEL_SRC_VFS_GETATTR
111 ZFS_AC_KERNEL_SRC_VFS_FSYNC_2ARGS
112 ZFS_AC_KERNEL_SRC_VFS_ITERATE
113 ZFS_AC_KERNEL_SRC_VFS_DIRECT_IO
b9d98453
BB
114 ZFS_AC_KERNEL_SRC_VFS_READPAGES
115 ZFS_AC_KERNEL_SRC_VFS_SET_PAGE_DIRTY_NOBUFFERS
608f8749
BB
116 ZFS_AC_KERNEL_SRC_VFS_RW_ITERATE
117 ZFS_AC_KERNEL_SRC_VFS_GENERIC_WRITE_CHECKS
1c2358c1 118 ZFS_AC_KERNEL_SRC_VFS_IOV_ITER
5a35c68b
RN
119 ZFS_AC_KERNEL_SRC_VFS_COPY_FILE_RANGE
120 ZFS_AC_KERNEL_SRC_VFS_GENERIC_COPY_FILE_RANGE
ef08a4d4 121 ZFS_AC_KERNEL_SRC_VFS_SPLICE_COPY_FILE_RANGE
5a35c68b
RN
122 ZFS_AC_KERNEL_SRC_VFS_REMAP_FILE_RANGE
123 ZFS_AC_KERNEL_SRC_VFS_CLONE_FILE_RANGE
124 ZFS_AC_KERNEL_SRC_VFS_DEDUPE_FILE_RANGE
6b0a4be5 125 ZFS_AC_KERNEL_SRC_VFS_FILE_OPERATIONS_EXTEND
608f8749
BB
126 ZFS_AC_KERNEL_SRC_KMAP_ATOMIC_ARGS
127 ZFS_AC_KERNEL_SRC_FOLLOW_DOWN_ONE
128 ZFS_AC_KERNEL_SRC_MAKE_REQUEST_FN
129 ZFS_AC_KERNEL_SRC_GENERIC_IO_ACCT
130 ZFS_AC_KERNEL_SRC_FPU
131 ZFS_AC_KERNEL_SRC_FMODE_T
132 ZFS_AC_KERNEL_SRC_KUIDGID_T
133 ZFS_AC_KERNEL_SRC_KUID_HELPERS
e2a82961 134 ZFS_AC_KERNEL_SRC_RENAME
608f8749
BB
135 ZFS_AC_KERNEL_SRC_CURRENT_TIME
136 ZFS_AC_KERNEL_SRC_USERNS_CAPABILITIES
137 ZFS_AC_KERNEL_SRC_IN_COMPAT_SYSCALL
ff5587d6 138 ZFS_AC_KERNEL_SRC_KTIME
608f8749
BB
139 ZFS_AC_KERNEL_SRC_TOTALRAM_PAGES_FUNC
140 ZFS_AC_KERNEL_SRC_TOTALHIGH_PAGES
141 ZFS_AC_KERNEL_SRC_KSTRTOUL
ec1fea45 142 ZFS_AC_KERNEL_SRC_PERCPU
60a4c7d2 143 ZFS_AC_KERNEL_SRC_CPU_HOTPLUG
d4dc53da 144 ZFS_AC_KERNEL_SRC_GENERIC_FILLATTR
e2a82961
CK
145 ZFS_AC_KERNEL_SRC_MKNOD
146 ZFS_AC_KERNEL_SRC_SYMLINK
ffd6978e 147 ZFS_AC_KERNEL_SRC_BIO_MAX_SEGS
414f7249
PD
148 ZFS_AC_KERNEL_SRC_SIGNAL_STOP
149 ZFS_AC_KERNEL_SRC_SIGINFO
0cdda2ed 150 ZFS_AC_KERNEL_SRC_SYSFS
414f7249 151 ZFS_AC_KERNEL_SRC_SET_SPECIAL_STATE
a3588c68 152 ZFS_AC_KERNEL_SRC_STANDALONE_LINUX_STDARG
84980ee0
RN
153 ZFS_AC_KERNEL_SRC_STRLCPY
154 ZFS_AC_KERNEL_SRC_STRSCPY
c0fb44c5 155 ZFS_AC_KERNEL_SRC_PAGEMAP_FOLIO_WAIT_BIT
12fa250d 156 ZFS_AC_KERNEL_SRC_ADD_DISK
a9856574 157 ZFS_AC_KERNEL_SRC_KTHREAD
becc717f 158 ZFS_AC_KERNEL_SRC_ZERO_PAGE
849c14e0 159 ZFS_AC_KERNEL_SRC___COPY_FROM_USER_INATOMIC
4ed5e250 160 ZFS_AC_KERNEL_SRC_USER_NS_COMMON_INUM
2a068a13 161 ZFS_AC_KERNEL_SRC_IDMAP_MNT_API
2e6b3c4d 162 ZFS_AC_KERNEL_SRC_IDMAP_NO_USERNS
f224eddf 163 ZFS_AC_KERNEL_SRC_IATTR_VFSID
3fc92adc 164 ZFS_AC_KERNEL_SRC_FILEMAP
8eb2f260 165 ZFS_AC_KERNEL_SRC_WRITEPAGE_T
f8447cf2 166 ZFS_AC_KERNEL_SRC_RECLAIMED
e47e9bbe 167 ZFS_AC_KERNEL_SRC_REGISTER_SYSCTL_TABLE
8ce2eba9 168 ZFS_AC_KERNEL_SRC_COPY_SPLICE_READ
7ac56b86 169 ZFS_AC_KERNEL_SRC_SYNC_BDEV
df04efe3 170 ZFS_AC_KERNEL_SRC_MM_PAGE_SIZE
589f59b5
W
171 case "$host_cpu" in
172 powerpc*)
173 ZFS_AC_KERNEL_SRC_CPU_HAS_FEATURE
174 ZFS_AC_KERNEL_SRC_FLUSH_DCACHE_PAGE
175 ;;
86239a5b
SC
176 riscv*)
177 ZFS_AC_KERNEL_SRC_FLUSH_DCACHE_PAGE
178 ;;
589f59b5 179 esac
608f8749
BB
180
181 AC_MSG_CHECKING([for available kernel interfaces])
182 ZFS_LINUX_TEST_COMPILE_ALL([kabi])
183 AC_MSG_RESULT([done])
184])
185
186dnl #
187dnl # Check results of kernel interface tests.
188dnl #
189AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [
190 ZFS_AC_KERNEL_ACCESS_OK_TYPE
191 ZFS_AC_KERNEL_GLOBAL_PAGE_STATE
650383f2 192 ZFS_AC_KERNEL_OBJTOOL
93ce2b4c 193 ZFS_AC_KERNEL_PDE_DATA
93ce2b4c 194 ZFS_AC_KERNEL_FALLOCATE
320f0c60
FY
195 ZFS_AC_KERNEL_FADVISE
196 ZFS_AC_KERNEL_GENERIC_FADVISE
93ce2b4c 197 ZFS_AC_KERNEL_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
608f8749
BB
198 ZFS_AC_KERNEL_RWSEM
199 ZFS_AC_KERNEL_SCHED
93ce2b4c 200 ZFS_AC_KERNEL_USLEEP_RANGE
608f8749 201 ZFS_AC_KERNEL_KMEM_CACHE
66955885 202 ZFS_AC_KERNEL_KVMALLOC
080102a1 203 ZFS_AC_KERNEL_VMALLOC_PAGE_KERNEL
608f8749 204 ZFS_AC_KERNEL_WAIT
6413c95f 205 ZFS_AC_KERNEL_INODE_TIMES
93ce2b4c
BB
206 ZFS_AC_KERNEL_INODE_LOCK
207 ZFS_AC_KERNEL_GROUP_INFO_GID
608f8749 208 ZFS_AC_KERNEL_RW
8b8b44d0 209 ZFS_AC_KERNEL_TIMER_SETUP
938cfeb0 210 ZFS_AC_KERNEL_SUPER_USER_NS
0dd73648 211 ZFS_AC_KERNEL_PROC_OPERATIONS
608f8749 212 ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS
066e8252
BB
213 ZFS_AC_KERNEL_BIO
214 ZFS_AC_KERNEL_BLKDEV
215 ZFS_AC_KERNEL_BLK_QUEUE
026f126b 216 ZFS_AC_KERNEL_GENHD_FLAGS
19697e45 217 ZFS_AC_KERNEL_REVALIDATE_DISK
c9c0d073 218 ZFS_AC_KERNEL_GET_DISK_RO
a5e046ea 219 ZFS_AC_KERNEL_GENERIC_READLINK_GLOBAL
ee5fd0bb 220 ZFS_AC_KERNEL_DISCARD_GRANULARITY
023699cd 221 ZFS_AC_KERNEL_INODE_OWNER_OR_CAPABLE
608f8749
BB
222 ZFS_AC_KERNEL_XATTR
223 ZFS_AC_KERNEL_ACL
d4dc53da 224 ZFS_AC_KERNEL_INODE_SETATTR
608f8749 225 ZFS_AC_KERNEL_INODE_GETATTR
a5248129 226 ZFS_AC_KERNEL_INODE_SET_FLAGS
18f57327 227 ZFS_AC_KERNEL_INODE_SET_IVERSION
47621f3d 228 ZFS_AC_KERNEL_SHOW_OPTIONS
534759fa 229 ZFS_AC_KERNEL_FILE_INODE
d9c97ec0 230 ZFS_AC_KERNEL_FILE_DENTRY
adcd70bd 231 ZFS_AC_KERNEL_FSYNC
7ca25051 232 ZFS_AC_KERNEL_AIO_FSYNC
608f8749
BB
233 ZFS_AC_KERNEL_EVICT_INODE
234 ZFS_AC_KERNEL_DIRTY_INODE
235 ZFS_AC_KERNEL_SHRINKER
e2a82961 236 ZFS_AC_KERNEL_MKDIR
066e8252 237 ZFS_AC_KERNEL_LOOKUP_FLAGS
e2a82961 238 ZFS_AC_KERNEL_CREATE
eebfd28e 239 ZFS_AC_KERNEL_PERMISSION
beeed459 240 ZFS_AC_KERNEL_GET_LINK
bd29109f 241 ZFS_AC_KERNEL_PUT_LINK
ace1eae8 242 ZFS_AC_KERNEL_TMPFILE
ebe7e575 243 ZFS_AC_KERNEL_AUTOMOUNT
756c3e5a 244 ZFS_AC_KERNEL_ENCODE_FH_WITH_INODE
393b44c7 245 ZFS_AC_KERNEL_COMMIT_METADATA
739a1a82 246 ZFS_AC_KERNEL_CLEAR_INODE
3b0ba3ba 247 ZFS_AC_KERNEL_SETATTR_PREPARE
bdf4328b 248 ZFS_AC_KERNEL_INSERT_INODE_LOCKED
608f8749 249 ZFS_AC_KERNEL_DENTRY
86db35c4 250 ZFS_AC_KERNEL_DENTRY_ALIAS_D_U
b3129792 251 ZFS_AC_KERNEL_TRUNCATE_SETSIZE
608f8749 252 ZFS_AC_KERNEL_SECURITY_INODE
93b43af1 253 ZFS_AC_KERNEL_FST_MOUNT
7dae2c81 254 ZFS_AC_KERNEL_BDI
28eb9213 255 ZFS_AC_KERNEL_SET_NLINK
608f8749 256 ZFS_AC_KERNEL_SGET
802e7b5f 257 ZFS_AC_KERNEL_LSEEK_EXECUTE
7dde17e8 258 ZFS_AC_KERNEL_VFS_FILEMAP_DIRTY_FOLIO
c2c2e7bb 259 ZFS_AC_KERNEL_VFS_READ_FOLIO
608f8749
BB
260 ZFS_AC_KERNEL_VFS_GETATTR
261 ZFS_AC_KERNEL_VFS_FSYNC_2ARGS
0f37d0c8 262 ZFS_AC_KERNEL_VFS_ITERATE
a584ef26 263 ZFS_AC_KERNEL_VFS_DIRECT_IO
b9d98453
BB
264 ZFS_AC_KERNEL_VFS_READPAGES
265 ZFS_AC_KERNEL_VFS_SET_PAGE_DIRTY_NOBUFFERS
608f8749
BB
266 ZFS_AC_KERNEL_VFS_RW_ITERATE
267 ZFS_AC_KERNEL_VFS_GENERIC_WRITE_CHECKS
1c2358c1 268 ZFS_AC_KERNEL_VFS_IOV_ITER
5a35c68b
RN
269 ZFS_AC_KERNEL_VFS_COPY_FILE_RANGE
270 ZFS_AC_KERNEL_VFS_GENERIC_COPY_FILE_RANGE
ef08a4d4 271 ZFS_AC_KERNEL_VFS_SPLICE_COPY_FILE_RANGE
5a35c68b
RN
272 ZFS_AC_KERNEL_VFS_REMAP_FILE_RANGE
273 ZFS_AC_KERNEL_VFS_CLONE_FILE_RANGE
274 ZFS_AC_KERNEL_VFS_DEDUPE_FILE_RANGE
6b0a4be5 275 ZFS_AC_KERNEL_VFS_FILE_OPERATIONS_EXTEND
17888ae3 276 ZFS_AC_KERNEL_KMAP_ATOMIC_ARGS
278bee93 277 ZFS_AC_KERNEL_FOLLOW_DOWN_ONE
37f9dac5 278 ZFS_AC_KERNEL_MAKE_REQUEST_FN
608f8749 279 ZFS_AC_KERNEL_GENERIC_IO_ACCT
fc0c72b1 280 ZFS_AC_KERNEL_FPU
608f8749
BB
281 ZFS_AC_KERNEL_FMODE_T
282 ZFS_AC_KERNEL_KUIDGID_T
82a1b2d6 283 ZFS_AC_KERNEL_KUID_HELPERS
e2a82961 284 ZFS_AC_KERNEL_RENAME
2946a1a1 285 ZFS_AC_KERNEL_CURRENT_TIME
0e85048f 286 ZFS_AC_KERNEL_USERNS_CAPABILITIES
e897a23e 287 ZFS_AC_KERNEL_IN_COMPAT_SYSCALL
ff5587d6 288 ZFS_AC_KERNEL_KTIME
031cea17 289 ZFS_AC_KERNEL_TOTALRAM_PAGES_FUNC
de3e0b91 290 ZFS_AC_KERNEL_TOTALHIGH_PAGES
8708fd88 291 ZFS_AC_KERNEL_KSTRTOUL
ec1fea45 292 ZFS_AC_KERNEL_PERCPU
60a4c7d2 293 ZFS_AC_KERNEL_CPU_HOTPLUG
d4dc53da 294 ZFS_AC_KERNEL_GENERIC_FILLATTR
e2a82961
CK
295 ZFS_AC_KERNEL_MKNOD
296 ZFS_AC_KERNEL_SYMLINK
ffd6978e 297 ZFS_AC_KERNEL_BIO_MAX_SEGS
414f7249
PD
298 ZFS_AC_KERNEL_SIGNAL_STOP
299 ZFS_AC_KERNEL_SIGINFO
0cdda2ed 300 ZFS_AC_KERNEL_SYSFS
414f7249 301 ZFS_AC_KERNEL_SET_SPECIAL_STATE
a3588c68 302 ZFS_AC_KERNEL_STANDALONE_LINUX_STDARG
84980ee0
RN
303 ZFS_AC_KERNEL_STRLCPY
304 ZFS_AC_KERNEL_STRSCPY
c0fb44c5 305 ZFS_AC_KERNEL_PAGEMAP_FOLIO_WAIT_BIT
12fa250d 306 ZFS_AC_KERNEL_ADD_DISK
a9856574 307 ZFS_AC_KERNEL_KTHREAD
becc717f 308 ZFS_AC_KERNEL_ZERO_PAGE
849c14e0 309 ZFS_AC_KERNEL___COPY_FROM_USER_INATOMIC
4ed5e250 310 ZFS_AC_KERNEL_USER_NS_COMMON_INUM
2a068a13 311 ZFS_AC_KERNEL_IDMAP_MNT_API
2e6b3c4d 312 ZFS_AC_KERNEL_IDMAP_NO_USERNS
f224eddf 313 ZFS_AC_KERNEL_IATTR_VFSID
3fc92adc 314 ZFS_AC_KERNEL_FILEMAP
8eb2f260 315 ZFS_AC_KERNEL_WRITEPAGE_T
f8447cf2 316 ZFS_AC_KERNEL_RECLAIMED
e47e9bbe 317 ZFS_AC_KERNEL_REGISTER_SYSCTL_TABLE
8ce2eba9 318 ZFS_AC_KERNEL_COPY_SPLICE_READ
7ac56b86 319 ZFS_AC_KERNEL_SYNC_BDEV
df04efe3 320 ZFS_AC_KERNEL_MM_PAGE_SIZE
589f59b5
W
321 case "$host_cpu" in
322 powerpc*)
323 ZFS_AC_KERNEL_CPU_HAS_FEATURE
324 ZFS_AC_KERNEL_FLUSH_DCACHE_PAGE
86239a5b
SC
325 ;;
326 riscv*)
327 ZFS_AC_KERNEL_FLUSH_DCACHE_PAGE
589f59b5
W
328 ;;
329 esac
c9c0d073
BB
330])
331
332dnl #
333dnl # Detect name used for Module.symvers file in kernel
334dnl #
335AC_DEFUN([ZFS_AC_MODULE_SYMVERS], [
336 modpost=$LINUX/scripts/Makefile.modpost
337 AC_MSG_CHECKING([kernel file name for module symbols])
319a99a3 338 AS_IF([test "x$enable_linux_builtin" != xyes -a -f "$modpost"], [
8366cd6a 339 AS_IF([grep -q Modules.symvers $modpost], [
c9c0d073 340 LINUX_SYMBOLS=Modules.symvers
8366cd6a 341 ], [
c9c0d073 342 LINUX_SYMBOLS=Module.symvers
8366cd6a 343 ])
a60b1c0a 344
8366cd6a 345 AS_IF([test ! -f "$LINUX_OBJ/$LINUX_SYMBOLS"], [
a60b1c0a
BB
346 AC_MSG_ERROR([
347 *** Please make sure the kernel devel package for your distribution
608f8749
BB
348 *** is installed. If you are building with a custom kernel, make sure
349 *** the kernel is configured, built, and the '--with-linux=PATH'
350 *** configure option refers to the location of the kernel source.
351 ])
8366cd6a
PS
352 ])
353 ], [
c9c0d073 354 LINUX_SYMBOLS=NONE
8366cd6a 355 ])
c9c0d073
BB
356 AC_MSG_RESULT($LINUX_SYMBOLS)
357 AC_SUBST(LINUX_SYMBOLS)
358])
359
360dnl #
361dnl # Detect the kernel to be built against
362dnl #
72f3c8b1
DS
363dnl # Most modern Linux distributions have separate locations for bare
364dnl # source (source) and prebuilt (build) files. Additionally, there are
365dnl # `source` and `build` symlinks in `/lib/modules/$(KERNEL_VERSION)`
366dnl # pointing to them. The directory search order is now:
367dnl #
368dnl # - `configure` command line values if both `--with-linux` and
369dnl # `--with-linux-obj` were defined
370dnl #
371dnl # - If only `--with-linux` was defined, `--with-linux-obj` is assumed
372dnl # to have the same value as `--with-linux`
373dnl #
374dnl # - If neither `--with-linux` nor `--with-linux-obj` were defined
375dnl # autodetection is used:
376dnl #
377dnl # - `/lib/modules/$(uname -r)/{source,build}` respectively, if exist.
378dnl #
379dnl # - If only `/lib/modules/$(uname -r)/build` exists, it is assumed
380dnl # to be both source and build directory.
381dnl #
382dnl # - The first directory in `/lib/modules` with the highest version
383dnl # number according to `sort -V` which contains both `source` and
384dnl # `build` symlinks/directories. If module directory contains only
385dnl # `build` component, it is assumed to be both source and build
386dnl # directory.
387dnl #
388dnl # - Last resort: the first directory matching `/usr/src/kernels/*`
389dnl # and `/usr/src/linux-*` with the highest version number according
390dnl # to `sort -V` is assumed to be both source and build directory.
391dnl #
c9c0d073
BB
392AC_DEFUN([ZFS_AC_KERNEL], [
393 AC_ARG_WITH([linux],
394 AS_HELP_STRING([--with-linux=PATH],
395 [Path to kernel source]),
396 [kernelsrc="$withval"])
397
398 AC_ARG_WITH(linux-obj,
399 AS_HELP_STRING([--with-linux-obj=PATH],
400 [Path to kernel build objects]),
401 [kernelbuild="$withval"])
402
72f3c8b1
DS
403 AC_MSG_CHECKING([kernel source and build directories])
404 AS_IF([test -n "$kernelsrc" && test -z "$kernelbuild"], [
405 kernelbuild="$kernelsrc"
406 ], [test -z "$kernelsrc"], [
407 AS_IF([test -e "/lib/modules/$(uname -r)/source" && \
408 test -e "/lib/modules/$(uname -r)/build"], [
409 src="/lib/modules/$(uname -r)/source"
410 build="/lib/modules/$(uname -r)/build"
8366cd6a 411 ], [test -e "/lib/modules/$(uname -r)/build"], [
72f3c8b1
DS
412 build="/lib/modules/$(uname -r)/build"
413 src="$build"
8366cd6a 414 ], [
72f3c8b1
DS
415 src=
416
417 for d in $(ls -1d /lib/modules/* 2>/dev/null | sort -Vr); do
418 if test -e "$d/source" && test -e "$d/build"; then
419 src="$d/source"
420 build="$d/build"
421 break
422 fi
423
424 if test -e "$d/build"; then
425 src="$d/build"
426 build="$d/build"
427 break
428 fi
429 done
430
431 # the least reliable method
432 if test -z "$src"; then
433 src=$(ls -1d /usr/src/kernels/* /usr/src/linux-* \
434 2>/dev/null | grep -v obj | sort -Vr | head -1)
435 build="$src"
436 fi
8366cd6a 437 ])
c9c0d073 438
72f3c8b1
DS
439 AS_IF([test -n "$src" && test -e "$src"], [
440 kernelsrc=$(readlink -e "$src")
8366cd6a 441 ], [
56a517ae 442 kernelsrc="[Not found]"
8366cd6a 443 ])
72f3c8b1
DS
444 AS_IF([test -n "$build" && test -e "$build"], [
445 kernelbuild=$(readlink -e "$build")
446 ], [
447 kernelbuild="[Not found]"
448 ])
8366cd6a
PS
449 ], [
450 AS_IF([test "$kernelsrc" = "NONE"], [
c9c0d073 451 kernsrcver=NONE
8366cd6a 452 ])
1d8da991 453 withlinux=yes
8366cd6a 454 ])
c9c0d073 455
72f3c8b1
DS
456 AC_MSG_RESULT([done])
457 AC_MSG_CHECKING([kernel source directory])
c9c0d073 458 AC_MSG_RESULT([$kernelsrc])
72f3c8b1
DS
459 AC_MSG_CHECKING([kernel build directory])
460 AC_MSG_RESULT([$kernelbuild])
461 AS_IF([test ! -d "$kernelsrc" || test ! -d "$kernelbuild"], [
56a517ae
BB
462 AC_MSG_ERROR([
463 *** Please make sure the kernel devel package for your distribution
4e95cc99 464 *** is installed and then try again. If that fails, you can specify the
72f3c8b1
DS
465 *** location of the kernel source and build with the '--with-linux=PATH' and
466 *** '--with-linux-obj=PATH' options respectively.])
8366cd6a 467 ])
c9c0d073
BB
468
469 AC_MSG_CHECKING([kernel source version])
470 utsrelease1=$kernelbuild/include/linux/version.h
471 utsrelease2=$kernelbuild/include/linux/utsrelease.h
472 utsrelease3=$kernelbuild/include/generated/utsrelease.h
d30577c9 473 AS_IF([test -r $utsrelease1 && grep -qF UTS_RELEASE $utsrelease1], [
06346cc5 474 utsrelease=$utsrelease1
d30577c9 475 ], [test -r $utsrelease2 && grep -qF UTS_RELEASE $utsrelease2], [
06346cc5 476 utsrelease=$utsrelease2
d30577c9 477 ], [test -r $utsrelease3 && grep -qF UTS_RELEASE $utsrelease3], [
06346cc5 478 utsrelease=$utsrelease3
8366cd6a 479 ])
c9c0d073 480
06346cc5
BB
481 AS_IF([test -n "$utsrelease"], [
482 kernsrcver=$($AWK '/UTS_RELEASE/ { gsub(/"/, "", $[3]); print $[3] }' $utsrelease)
8366cd6a 483 AS_IF([test -z "$kernsrcver"], [
c9c0d073 484 AC_MSG_RESULT([Not found])
608f8749
BB
485 AC_MSG_ERROR([
486 *** Cannot determine kernel version.
487 ])
8366cd6a
PS
488 ])
489 ], [
c9c0d073 490 AC_MSG_RESULT([Not found])
319a99a3 491 if test "x$enable_linux_builtin" != xyes; then
608f8749
BB
492 AC_MSG_ERROR([
493 *** Cannot find UTS_RELEASE definition.
494 ])
319a99a3
ED
495 else
496 AC_MSG_ERROR([
497 *** Cannot find UTS_RELEASE definition.
498 *** Please run 'make prepare' inside the kernel source tree.])
499 fi
8366cd6a 500 ])
c9c0d073
BB
501
502 AC_MSG_RESULT([$kernsrcver])
503
066e8252
BB
504 AS_VERSION_COMPARE([$kernsrcver], [$ZFS_META_KVER_MIN], [
505 AC_MSG_ERROR([
506 *** Cannot build against kernel version $kernsrcver.
507 *** The minimum supported kernel version is $ZFS_META_KVER_MIN.
508 ])
509 ])
510
c9c0d073
BB
511 LINUX=${kernelsrc}
512 LINUX_OBJ=${kernelbuild}
513 LINUX_VERSION=${kernsrcver}
514
515 AC_SUBST(LINUX)
516 AC_SUBST(LINUX_OBJ)
517 AC_SUBST(LINUX_VERSION)
c9c0d073
BB
518])
519
6a9d6359 520dnl #
608f8749
BB
521dnl # Detect the QAT module to be built against, QAT provides hardware
522dnl # acceleration for data compression:
523dnl #
524dnl # https://01.org/intel-quickassist-technology
525dnl #
526dnl # 1) Download and install QAT driver from the above link
527dnl # 2) Start QAT driver in your system:
528dnl # service qat_service start
529dnl # 3) Enable QAT in ZFS, e.g.:
530dnl # ./configure --with-qat=<qat-driver-path>/QAT1.6
531dnl # make
532dnl # 4) Set GZIP compression in ZFS dataset:
533dnl # zfs set compression = gzip <dataset>
534dnl #
535dnl # Then the data written to this ZFS pool is compressed by QAT accelerator
536dnl # automatically, and de-compressed by QAT when read from the pool.
537dnl #
538dnl # 1) Get QAT hardware statistics with:
539dnl # cat /proc/icp_dh895xcc_dev/qat
540dnl # 2) To disable QAT:
541dnl # insmod zfs.ko zfs_qat_disable=1
6a9d6359 542dnl #
543AC_DEFUN([ZFS_AC_QAT], [
544 AC_ARG_WITH([qat],
545 AS_HELP_STRING([--with-qat=PATH],
546 [Path to qat source]),
547 AS_IF([test "$withval" = "yes"],
548 AC_MSG_ERROR([--with-qat=PATH requires a PATH]),
549 [qatsrc="$withval"]))
550
551 AC_ARG_WITH([qat-obj],
552 AS_HELP_STRING([--with-qat-obj=PATH],
553 [Path to qat build objects]),
554 [qatbuild="$withval"])
555
556 AS_IF([test ! -z "${qatsrc}"], [
557 AC_MSG_CHECKING([qat source directory])
558 AC_MSG_RESULT([$qatsrc])
559 QAT_SRC="${qatsrc}/quickassist"
560 AS_IF([ test ! -e "$QAT_SRC/include/cpa.h"], [
561 AC_MSG_ERROR([
608f8749
BB
562 *** Please make sure the qat driver package is installed
563 *** and specify the location of the qat source with the
564 *** '--with-qat=PATH' option then try again. Failed to
565 *** find cpa.h in:
566 ${QAT_SRC}/include])
6a9d6359 567 ])
568 ])
569
570 AS_IF([test ! -z "${qatsrc}"], [
571 AC_MSG_CHECKING([qat build directory])
572 AS_IF([test -z "$qatbuild"], [
573 qatbuild="${qatsrc}/build"
574 ])
575
576 AC_MSG_RESULT([$qatbuild])
577 QAT_OBJ=${qatbuild}
1cfdb0e6 578 AS_IF([ ! test -e "$QAT_OBJ/icp_qa_al.ko" && ! test -e "$QAT_OBJ/qat_api.ko"], [
6a9d6359 579 AC_MSG_ERROR([
608f8749
BB
580 *** Please make sure the qat driver is installed then try again.
581 *** Failed to find icp_qa_al.ko or qat_api.ko in:
582 $QAT_OBJ])
6a9d6359 583 ])
584
585 AC_SUBST(QAT_SRC)
586 AC_SUBST(QAT_OBJ)
587
588 AC_DEFINE(HAVE_QAT, 1,
589 [qat is enabled and existed])
590 ])
591
592 dnl #
593 dnl # Detect the name used for the QAT Module.symvers file.
594 dnl #
595 AS_IF([test ! -z "${qatsrc}"], [
596 AC_MSG_CHECKING([qat file for module symbols])
597 QAT_SYMBOLS=$QAT_SRC/lookaside/access_layer/src/Module.symvers
598
599 AS_IF([test -r $QAT_SYMBOLS], [
600 AC_MSG_RESULT([$QAT_SYMBOLS])
601 AC_SUBST(QAT_SYMBOLS)
602 ],[
608f8749
BB
603 AC_MSG_ERROR([
604 *** Please make sure the qat driver is installed then try again.
605 *** Failed to find Module.symvers in:
606 $QAT_SYMBOLS
6a9d6359 607 ])
608 ])
609 ])
610])
611
15805c77 612dnl #
608f8749 613dnl # ZFS_LINUX_CONFTEST_H
15805c77 614dnl #
608f8749
BB
615AC_DEFUN([ZFS_LINUX_CONFTEST_H], [
616test -d build/$2 || mkdir -p build/$2
617cat - <<_ACEOF >build/$2/$2.h
618$1
619_ACEOF
620])
e5b85622 621
608f8749
BB
622dnl #
623dnl # ZFS_LINUX_CONFTEST_C
624dnl #
625AC_DEFUN([ZFS_LINUX_CONFTEST_C], [
626test -d build/$2 || mkdir -p build/$2
627cat confdefs.h - <<_ACEOF >build/$2/$2.c
628$1
629_ACEOF
e5b85622
BB
630])
631
b58986ee 632dnl #
608f8749 633dnl # ZFS_LINUX_CONFTEST_MAKEFILE
b58986ee 634dnl #
608f8749
BB
635dnl # $1 - test case name
636dnl # $2 - add to top-level Makefile
637dnl # $3 - additional build flags
b58986ee 638dnl #
608f8749
BB
639AC_DEFUN([ZFS_LINUX_CONFTEST_MAKEFILE], [
640 test -d build || mkdir -p build
641 test -d build/$1 || mkdir -p build/$1
642
643 file=build/$1/Makefile
644
645 dnl # Example command line to manually build source.
646 cat - <<_ACEOF >$file
647# Example command line to manually build source
648# make modules -C $LINUX_OBJ $ARCH_UM M=$PWD/build/$1
649
650ccflags-y := -Werror $FRAME_LARGER_THAN
651_ACEOF
652
653 dnl # Additional custom CFLAGS as requested.
654 m4_ifval($3, [echo "ccflags-y += $3" >>$file], [])
655
656 dnl # Test case source
657 echo "obj-m := $1.o" >>$file
658
659 AS_IF([test "x$2" = "xyes"], [echo "obj-m += $1/" >>build/Makefile], [])
b58986ee
BB
660])
661
e5b85622 662dnl #
608f8749 663dnl # ZFS_LINUX_TEST_PROGRAM(C)([PROLOGUE], [BODY])
e5b85622 664dnl #
608f8749 665m4_define([ZFS_LINUX_TEST_PROGRAM], [
c347fac5 666#include <linux/module.h>
608f8749 667$1
c347fac5 668
608f8749
BB
669int
670main (void)
671{
672$2
673 ;
674 return 0;
675}
c347fac5
BB
676
677MODULE_DESCRIPTION("conftest");
678MODULE_AUTHOR(ZFS_META_AUTHOR);
679MODULE_VERSION(ZFS_META_VERSION "-" ZFS_META_RELEASE);
680MODULE_LICENSE($3);
608f8749
BB
681])
682
e5b85622 683dnl #
608f8749 684dnl # ZFS_LINUX_TEST_REMOVE
e5b85622 685dnl #
608f8749
BB
686dnl # Removes the specified test source and results.
687dnl #
688AC_DEFUN([ZFS_LINUX_TEST_REMOVE], [
689 test -d build/$1 && rm -Rf build/$1
690 test -f build/Makefile && sed '/$1/d' build/Makefile
691])
e5b85622 692
608f8749
BB
693dnl #
694dnl # ZFS_LINUX_COMPILE
695dnl #
696dnl # $1 - build dir
697dnl # $2 - test command
698dnl # $3 - pass command
699dnl # $4 - fail command
700dnl # $5 - set KBUILD_MODPOST_NOFINAL='yes'
701dnl # $6 - set KBUILD_MODPOST_WARN='yes'
702dnl #
703dnl # Used internally by ZFS_LINUX_TEST_{COMPILE,MODPOST}
704dnl #
705AC_DEFUN([ZFS_LINUX_COMPILE], [
b66140c6
PL
706 AC_ARG_VAR([KERNEL_CC], [C compiler for
707 building kernel modules])
708 AC_ARG_VAR([KERNEL_LD], [Linker for
709 building kernel modules])
710 AC_ARG_VAR([KERNEL_LLVM], [Binary option to
711 build kernel modules with LLVM/CLANG toolchain])
608f8749
BB
712 AC_TRY_COMMAND([
713 KBUILD_MODPOST_NOFINAL="$5" KBUILD_MODPOST_WARN="$6"
a0dfd98a
DS
714 make modules -k -j$TEST_JOBS ${KERNEL_CC:+CC=$KERNEL_CC}
715 ${KERNEL_LD:+LD=$KERNEL_LD} ${KERNEL_LLVM:+LLVM=$KERNEL_LLVM}
716 CONFIG_MODULES=y CFLAGS_MODULE=-DCONFIG_MODULES
717 -C $LINUX_OBJ $ARCH_UM M=$PWD/$1 >$1/build.log 2>&1])
608f8749 718 AS_IF([AC_TRY_COMMAND([$2])], [$3], [$4])
c9c0d073
BB
719])
720
721dnl #
608f8749 722dnl # ZFS_LINUX_TEST_COMPILE
93ce2b4c 723dnl #
608f8749 724dnl # Perform a full compile excluding the final modpost phase.
93ce2b4c 725dnl #
608f8749
BB
726AC_DEFUN([ZFS_LINUX_TEST_COMPILE], [
727 ZFS_LINUX_COMPILE([$2], [test -f $2/build.log], [
728 mv $2/Makefile $2/Makefile.compile.$1
729 mv $2/build.log $2/build.log.$1
93ce2b4c 730 ],[
608f8749
BB
731 AC_MSG_ERROR([
732 *** Unable to compile test source to determine kernel interfaces.])
733 ], [yes], [])
93ce2b4c
BB
734])
735
736dnl #
608f8749 737dnl # ZFS_LINUX_TEST_MODPOST
c9c0d073 738dnl #
608f8749
BB
739dnl # Perform a full compile including the modpost phase. This may
740dnl # be an incremental build if the objects have already been built.
741dnl #
742AC_DEFUN([ZFS_LINUX_TEST_MODPOST], [
743 ZFS_LINUX_COMPILE([$2], [test -f $2/build.log], [
744 mv $2/Makefile $2/Makefile.modpost.$1
745 cat $2/build.log >>build/build.log.$1
746 ],[
747 AC_MSG_ERROR([
748 *** Unable to modpost test source to determine kernel interfaces.])
749 ], [], [yes])
0b39b9f9
PS
750])
751
752dnl #
608f8749 753dnl # Perform the compilation of the test cases in two phases.
0b39b9f9 754dnl #
608f8749
BB
755dnl # Phase 1) attempt to build the object files for all of the tests
756dnl # defined by the ZFS_LINUX_TEST_SRC macro. But do not
757dnl # perform the final modpost stage.
758dnl #
759dnl # Phase 2) disable all tests which failed the initial compilation,
760dnl # then invoke the final modpost step for the remaining tests.
761dnl #
762dnl # This allows us efficiently build the test cases in parallel while
763dnl # remaining resilient to build failures which are expected when
764dnl # detecting the available kernel interfaces.
765dnl #
766dnl # The maximum allowed parallelism can be controlled by setting the
767dnl # TEST_JOBS environment variable. Otherwise, it default to $(nproc).
768dnl #
769AC_DEFUN([ZFS_LINUX_TEST_COMPILE_ALL], [
770 dnl # Phase 1 - Compilation only, final linking is skipped.
771 ZFS_LINUX_TEST_COMPILE([$1], [build])
772
773 dnl #
774 dnl # Phase 2 - When building external modules disable test cases
775 dnl # which failed to compile and invoke modpost to verify the
776 dnl # final linking.
777 dnl #
778 dnl # Test names suffixed with '_license' call modpost independently
779 dnl # to ensure that a single incompatibility does not result in the
780 dnl # modpost phase exiting early. This check is not performed on
781 dnl # every symbol since the majority are compatible and doing so
782 dnl # would significantly slow down this phase.
783 dnl #
784 dnl # When configuring for builtin (--enable-linux-builtin)
785 dnl # fake the linking step artificially create the expected .ko
786 dnl # files for tests which did compile. This is required for
787 dnl # kernels which do not have loadable module support or have
788 dnl # not yet been built.
789 dnl #
790 AS_IF([test "x$enable_linux_builtin" = "xno"], [
791 for dir in $(awk '/^obj-m/ { print [$]3 }' \
792 build/Makefile.compile.$1); do
793 name=${dir%/}
794 AS_IF([test -f build/$name/$name.o], [
795 AS_IF([test "${name##*_}" = "license"], [
796 ZFS_LINUX_TEST_MODPOST([$1],
797 [build/$name])
798 echo "obj-n += $dir" >>build/Makefile
799 ], [
800 echo "obj-m += $dir" >>build/Makefile
801 ])
802 ], [
803 echo "obj-n += $dir" >>build/Makefile
804 ])
805 done
806
807 ZFS_LINUX_TEST_MODPOST([$1], [build])
808 ], [
809 for dir in $(awk '/^obj-m/ { print [$]3 }' \
810 build/Makefile.compile.$1); do
811 name=${dir%/}
812 AS_IF([test -f build/$name/$name.o], [
813 touch build/$name/$name.ko
814 ])
815 done
816 ])
c9c0d073
BB
817])
818
819dnl #
608f8749 820dnl # ZFS_LINUX_TEST_SRC
c9c0d073 821dnl #
608f8749
BB
822dnl # $1 - name
823dnl # $2 - global
824dnl # $3 - source
825dnl # $4 - extra cflags
826dnl # $5 - check license-compatibility
827dnl #
c347fac5
BB
828dnl # Check if the test source is buildable at all and then if it is
829dnl # license compatible.
830dnl #
608f8749
BB
831dnl # N.B because all of the test cases are compiled in parallel they
832dnl # must never depend on the results of previous tests. Each test
833dnl # needs to be entirely independent.
834dnl #
835AC_DEFUN([ZFS_LINUX_TEST_SRC], [
c347fac5
BB
836 ZFS_LINUX_CONFTEST_C([ZFS_LINUX_TEST_PROGRAM([[$2]], [[$3]],
837 [["Dual BSD/GPL"]])], [$1])
608f8749
BB
838 ZFS_LINUX_CONFTEST_MAKEFILE([$1], [yes], [$4])
839
840 AS_IF([ test -n "$5" ], [
c347fac5
BB
841 ZFS_LINUX_CONFTEST_C([ZFS_LINUX_TEST_PROGRAM(
842 [[$2]], [[$3]], [[$5]])], [$1_license])
608f8749
BB
843 ZFS_LINUX_CONFTEST_MAKEFILE([$1_license], [yes], [$4])
844 ])
c9c0d073
BB
845])
846
847dnl #
608f8749 848dnl # ZFS_LINUX_TEST_RESULT
c9c0d073 849dnl #
608f8749
BB
850dnl # $1 - name of a test source (ZFS_LINUX_TEST_SRC)
851dnl # $2 - run on success (valid .ko generated)
852dnl # $3 - run on failure (unable to compile)
853dnl #
854AC_DEFUN([ZFS_LINUX_TEST_RESULT], [
855 AS_IF([test -d build/$1], [
856 AS_IF([test -f build/$1/$1.ko], [$2], [$3])
857 ], [
858 AC_MSG_ERROR([
859 *** No matching source for the "$1" test, check that
860 *** both the test source and result macros refer to the same name.
861 ])
862 ])
c9c0d073
BB
863])
864
865dnl #
608f8749 866dnl # ZFS_LINUX_TEST_ERROR
c9c0d073 867dnl #
608f8749
BB
868dnl # Generic error message which can be used when none of the expected
869dnl # kernel interfaces were detected.
870dnl #
871AC_DEFUN([ZFS_LINUX_TEST_ERROR], [
872 AC_MSG_ERROR([
873 *** None of the expected "$1" interfaces were detected.
874 *** This may be because your kernel version is newer than what is
875 *** supported, or you are using a patched custom kernel with
876 *** incompatible modifications.
877 ***
878 *** ZFS Version: $ZFS_META_ALIAS
879 *** Compatible Kernels: $ZFS_META_KVER_MIN - $ZFS_META_KVER_MAX
880 ])
c9c0d073
BB
881])
882
883dnl #
608f8749 884dnl # ZFS_LINUX_TEST_RESULT_SYMBOL
c9c0d073 885dnl #
608f8749
BB
886dnl # Like ZFS_LINUX_TEST_RESULT except ZFS_CHECK_SYMBOL_EXPORT is called to
887dnl # verify symbol exports, unless --enable-linux-builtin was provided to
888dnl # configure.
889dnl #
890AC_DEFUN([ZFS_LINUX_TEST_RESULT_SYMBOL], [
891 AS_IF([ ! test -f build/$1/$1.ko], [
892 $5
893 ], [
894 AS_IF([test "x$enable_linux_builtin" != "xyes"], [
895 ZFS_CHECK_SYMBOL_EXPORT([$2], [$3], [$4], [$5])
896 ], [
897 $4
898 ])
c9c0d073
BB
899 ])
900])
901
608f8749
BB
902dnl #
903dnl # ZFS_LINUX_COMPILE_IFELSE
904dnl #
905AC_DEFUN([ZFS_LINUX_COMPILE_IFELSE], [
906 ZFS_LINUX_TEST_REMOVE([conftest])
907
908 m4_ifvaln([$1], [ZFS_LINUX_CONFTEST_C([$1], [conftest])])
909 m4_ifvaln([$5], [ZFS_LINUX_CONFTEST_H([$5], [conftest])],
910 [ZFS_LINUX_CONFTEST_H([], [conftest])])
911
912 ZFS_LINUX_CONFTEST_MAKEFILE([conftest], [no],
913 [m4_ifvaln([$5], [-I$PWD/build/conftest], [])])
914 ZFS_LINUX_COMPILE([build/conftest], [$2], [$3], [$4], [], [])
915])
916
917dnl #
918dnl # ZFS_LINUX_TRY_COMPILE
919dnl #
920dnl # $1 - global
921dnl # $2 - source
922dnl # $3 - run on success (valid .ko generated)
923dnl # $4 - run on failure (unable to compile)
924dnl #
3f99a3ab
BB
925dnl # When configuring as builtin (--enable-linux-builtin) for kernels
926dnl # without loadable module support (CONFIG_MODULES=n) only the object
927dnl # file is created. See ZFS_LINUX_TEST_COMPILE_ALL for details.
928dnl #
608f8749 929AC_DEFUN([ZFS_LINUX_TRY_COMPILE], [
3f99a3ab
BB
930 AS_IF([test "x$enable_linux_builtin" = "xyes"], [
931 ZFS_LINUX_COMPILE_IFELSE(
c347fac5
BB
932 [ZFS_LINUX_TEST_PROGRAM([[$1]], [[$2]],
933 [[ZFS_META_LICENSE]])],
3f99a3ab
BB
934 [test -f build/conftest/conftest.o], [$3], [$4])
935 ], [
936 ZFS_LINUX_COMPILE_IFELSE(
c347fac5
BB
937 [ZFS_LINUX_TEST_PROGRAM([[$1]], [[$2]],
938 [[ZFS_META_LICENSE]])],
3f99a3ab
BB
939 [test -f build/conftest/conftest.ko], [$3], [$4])
940 ])
608f8749
BB
941])
942
c9c0d073
BB
943dnl #
944dnl # ZFS_CHECK_SYMBOL_EXPORT
608f8749
BB
945dnl #
946dnl # Check if a symbol is exported on not by consulting the symbols
947dnl # file, or optionally the source code.
c9c0d073 948dnl #
70574182 949AC_DEFUN([ZFS_CHECK_SYMBOL_EXPORT], [
c9c0d073
BB
950 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
951 $LINUX_OBJ/$LINUX_SYMBOLS 2>/dev/null
952 rc=$?
70574182 953 if test $rc -ne 0; then
c9c0d073
BB
954 export=0
955 for file in $2; do
70574182
ED
956 grep -q -E "EXPORT_SYMBOL.*($1)" \
957 "$LINUX/$file" 2>/dev/null
c9c0d073 958 rc=$?
70574182 959 if test $rc -eq 0; then
8366cd6a
PS
960 export=1
961 break;
70574182 962 fi
c9c0d073 963 done
70574182 964 if test $export -eq 0; then :
c9c0d073 965 $4
70574182 966 else :
c9c0d073 967 $3
70574182
ED
968 fi
969 else :
c9c0d073 970 $3
70574182
ED
971 fi
972])
973
974dnl #
975dnl # ZFS_LINUX_TRY_COMPILE_SYMBOL
608f8749
BB
976dnl #
977dnl # Like ZFS_LINUX_TRY_COMPILER except ZFS_CHECK_SYMBOL_EXPORT is called
978dnl # to verify symbol exports, unless --enable-linux-builtin was provided
979dnl # to configure.
70574182
ED
980dnl #
981AC_DEFUN([ZFS_LINUX_TRY_COMPILE_SYMBOL], [
982 ZFS_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
983 if test $rc -ne 0; then :
984 $6
985 else
986 if test "x$enable_linux_builtin" != xyes; then
987 ZFS_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
988 fi
989 if test $rc -ne 0; then :
990 $6
991 else :
992 $5
993 fi
994 fi
c9c0d073 995])
0b39b9f9
PS
996
997dnl #
998dnl # ZFS_LINUX_TRY_COMPILE_HEADER
999dnl # like ZFS_LINUX_TRY_COMPILE, except the contents conftest.h are
1000dnl # provided via the fifth parameter
1001dnl #
608f8749 1002AC_DEFUN([ZFS_LINUX_TRY_COMPILE_HEADER], [
ab49df48
AL
1003 AS_IF([test "x$enable_linux_builtin" = "xyes"], [
1004 ZFS_LINUX_COMPILE_IFELSE(
1005 [ZFS_LINUX_TEST_PROGRAM([[$1]], [[$2]],
1006 [[ZFS_META_LICENSE]])],
1007 [test -f build/conftest/conftest.o], [$3], [$4], [$5])
1008 ], [
1009 ZFS_LINUX_COMPILE_IFELSE(
1010 [ZFS_LINUX_TEST_PROGRAM([[$1]], [[$2]],
1011 [[ZFS_META_LICENSE]])],
1012 [test -f build/conftest/conftest.ko], [$3], [$4], [$5])
1013 ])
0b39b9f9 1014])
556ed095
AR
1015
1016dnl #
1017dnl # AS_VERSION_COMPARE_LE
1018dnl # like AS_VERSION_COMPARE_LE, but runs $3 if (and only if) $1 <= $2
1019dnl # AS_VERSION_COMPARE_LE (version-1, version-2, [action-if-less-or-equal], [action-if-greater])
1020dnl #
1021AC_DEFUN([AS_VERSION_COMPARE_LE], [
1022 AS_VERSION_COMPARE([$1], [$2], [$3], [$3], [$4])
1023])
1024
1025dnl #
1026dnl # ZFS_LINUX_REQUIRE_API
1027dnl # like ZFS_LINUX_TEST_ERROR, except only fails if the kernel is
1028dnl # at least some specified version.
1029dnl #
1030AC_DEFUN([ZFS_LINUX_REQUIRE_API], [
1031 AS_VERSION_COMPARE_LE([$2], [$kernsrcver], [
1032 AC_MSG_ERROR([
1033 *** None of the expected "$1" interfaces were detected. This
1034 *** interface is expected for kernels version "$2" and above.
1035 *** This may be because your kernel version is newer than what is
1036 *** supported, or you are using a patched custom kernel with
1037 *** incompatible modifications. Newer kernels may have incompatible
1038 *** APIs.
1039 ***
1040 *** ZFS Version: $ZFS_META_ALIAS
1041 *** Compatible Kernels: $ZFS_META_KVER_MIN - $ZFS_META_KVER_MAX
1042 ])
1043 ], [
1044 AC_MSG_RESULT(no)
1045 ])
1046])