2 dnl # Default ZFS kernel configuration
4 AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
5 dnl # Setup the kernel build environment.
9 dnl # Sanity checks for module building and CONFIG_* defines
10 ZFS_AC_KERNEL_TEST_MODULE
11 ZFS_AC_KERNEL_CONFIG_DEFINED
13 dnl # Sequential ZFS_LINUX_TRY_COMPILE tests
14 ZFS_AC_KERNEL_FPU_HEADER
15 ZFS_AC_KERNEL_WAIT_QUEUE_ENTRY_T
16 ZFS_AC_KERNEL_MISC_MINOR
17 ZFS_AC_KERNEL_DECLARE_EVENT_CLASS
19 dnl # Parallel ZFS_LINUX_TEST_SRC / ZFS_LINUX_TEST_RESULT tests
20 ZFS_AC_KERNEL_TEST_SRC
21 ZFS_AC_KERNEL_TEST_RESULT
23 AS_IF([test "$LINUX_OBJ" != "$LINUX"], [
24 KERNEL_MAKE="$KERNEL_MAKE O=$LINUX_OBJ"
31 dnl # Generate and compile all of the kernel API test cases to determine
32 dnl # which interfaces are available. By invoking the kernel build system
33 dnl # only once the compilation can be done in parallel significantly
34 dnl # speeding up the process.
36 AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [
37 ZFS_AC_KERNEL_SRC_OBJTOOL
38 ZFS_AC_KERNEL_SRC_GLOBAL_PAGE_STATE
39 ZFS_AC_KERNEL_SRC_ACCESS_OK_TYPE
40 ZFS_AC_KERNEL_SRC_CTL_NAME
41 ZFS_AC_KERNEL_SRC_PDE_DATA
42 ZFS_AC_KERNEL_SRC_FALLOCATE
43 ZFS_AC_KERNEL_SRC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
44 ZFS_AC_KERNEL_SRC_RWSEM
45 ZFS_AC_KERNEL_SRC_SCHED
46 ZFS_AC_KERNEL_SRC_USLEEP_RANGE
47 ZFS_AC_KERNEL_SRC_KMEM_CACHE
48 ZFS_AC_KERNEL_SRC_WAIT
49 ZFS_AC_KERNEL_SRC_INODE_TIMES
50 ZFS_AC_KERNEL_SRC_INODE_LOCK
51 ZFS_AC_KERNEL_SRC_GROUP_INFO_GID
53 ZFS_AC_KERNEL_SRC_TIMER_SETUP
54 ZFS_AC_KERNEL_SRC_CURRENT_BIO_TAIL
55 ZFS_AC_KERNEL_SRC_SUPER_USER_NS
56 ZFS_AC_KERNEL_SRC_SUBMIT_BIO
57 ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS
58 ZFS_AC_KERNEL_SRC_BLKDEV_GET_BY_PATH
59 ZFS_AC_KERNEL_SRC_BLKDEV_REREAD_PART
60 ZFS_AC_KERNEL_SRC_INVALIDATE_BDEV
61 ZFS_AC_KERNEL_SRC_LOOKUP_BDEV
62 ZFS_AC_KERNEL_SRC_BDEV_OPEN_EXCLUSIVE
63 ZFS_AC_KERNEL_SRC_BDEV_LOGICAL_BLOCK_SIZE
64 ZFS_AC_KERNEL_SRC_BDEV_PHYSICAL_BLOCK_SIZE
65 ZFS_AC_KERNEL_SRC_BIO_BVEC_ITER
66 ZFS_AC_KERNEL_SRC_BIO_FAILFAST
67 ZFS_AC_KERNEL_SRC_BIO_SET_DEV
68 ZFS_AC_KERNEL_SRC_BIO_OPS
69 ZFS_AC_KERNEL_SRC_BIO_END_IO_T_ARGS
70 ZFS_AC_KERNEL_SRC_BIO_BI_STATUS
71 ZFS_AC_KERNEL_SRC_BIO_RW_BARRIER
72 ZFS_AC_KERNEL_SRC_BIO_RW_DISCARD
73 ZFS_AC_KERNEL_SRC_BLK_QUEUE_BDI
74 ZFS_AC_KERNEL_SRC_BLK_QUEUE_DISCARD
75 ZFS_AC_KERNEL_SRC_BLK_QUEUE_SECURE_ERASE
76 ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLAGS
77 ZFS_AC_KERNEL_SRC_BLK_QUEUE_FLUSH
78 ZFS_AC_KERNEL_SRC_BLK_QUEUE_MAX_HW_SECTORS
79 ZFS_AC_KERNEL_SRC_BLK_QUEUE_MAX_SEGMENTS
80 ZFS_AC_KERNEL_SRC_BLK_QUEUE_PLUG
81 ZFS_AC_KERNEL_SRC_GET_DISK_AND_MODULE
82 ZFS_AC_KERNEL_SRC_GET_DISK_RO
83 ZFS_AC_KERNEL_SRC_GENERIC_READLINK_GLOBAL
84 ZFS_AC_KERNEL_SRC_DISCARD_GRANULARITY
85 ZFS_AC_KERNEL_SRC_INODE_OWNER_OR_CAPABLE
86 ZFS_AC_KERNEL_SRC_XATTR
88 ZFS_AC_KERNEL_SRC_INODE_GETATTR
89 ZFS_AC_KERNEL_SRC_INODE_SET_FLAGS
90 ZFS_AC_KERNEL_SRC_INODE_SET_IVERSION
91 ZFS_AC_KERNEL_SRC_SHOW_OPTIONS
92 ZFS_AC_KERNEL_SRC_FILE_INODE
93 ZFS_AC_KERNEL_SRC_FILE_DENTRY
94 ZFS_AC_KERNEL_SRC_FSYNC
95 ZFS_AC_KERNEL_SRC_AIO_FSYNC
96 ZFS_AC_KERNEL_SRC_EVICT_INODE
97 ZFS_AC_KERNEL_SRC_DIRTY_INODE
98 ZFS_AC_KERNEL_SRC_SHRINKER
99 ZFS_AC_KERNEL_SRC_MKDIR_UMODE_T
100 ZFS_AC_KERNEL_SRC_LOOKUP_NAMEIDATA
101 ZFS_AC_KERNEL_SRC_CREATE_NAMEIDATA
102 ZFS_AC_KERNEL_SRC_GET_LINK
103 ZFS_AC_KERNEL_SRC_PUT_LINK
104 ZFS_AC_KERNEL_SRC_TMPFILE
105 ZFS_AC_KERNEL_SRC_TRUNCATE_RANGE
106 ZFS_AC_KERNEL_SRC_AUTOMOUNT
107 ZFS_AC_KERNEL_SRC_ENCODE_FH_WITH_INODE
108 ZFS_AC_KERNEL_SRC_COMMIT_METADATA
109 ZFS_AC_KERNEL_SRC_CLEAR_INODE
110 ZFS_AC_KERNEL_SRC_SETATTR_PREPARE
111 ZFS_AC_KERNEL_SRC_INSERT_INODE_LOCKED
112 ZFS_AC_KERNEL_SRC_DENTRY
113 ZFS_AC_KERNEL_SRC_TRUNCATE_SETSIZE
114 ZFS_AC_KERNEL_SRC_SECURITY_INODE
115 ZFS_AC_KERNEL_SRC_FST_MOUNT
116 ZFS_AC_KERNEL_SRC_BDI
117 ZFS_AC_KERNEL_SRC_SET_NLINK
118 ZFS_AC_KERNEL_SRC_ELEVATOR_CHANGE
119 ZFS_AC_KERNEL_SRC_SGET
120 ZFS_AC_KERNEL_SRC_LSEEK_EXECUTE
121 ZFS_AC_KERNEL_SRC_VFS_GETATTR
122 ZFS_AC_KERNEL_SRC_VFS_FSYNC_2ARGS
123 ZFS_AC_KERNEL_SRC_VFS_ITERATE
124 ZFS_AC_KERNEL_SRC_VFS_DIRECT_IO
125 ZFS_AC_KERNEL_SRC_VFS_RW_ITERATE
126 ZFS_AC_KERNEL_SRC_VFS_GENERIC_WRITE_CHECKS
127 ZFS_AC_KERNEL_SRC_KMAP_ATOMIC_ARGS
128 ZFS_AC_KERNEL_SRC_FOLLOW_DOWN_ONE
129 ZFS_AC_KERNEL_SRC_MAKE_REQUEST_FN
130 ZFS_AC_KERNEL_SRC_GENERIC_IO_ACCT
131 ZFS_AC_KERNEL_SRC_FPU
132 ZFS_AC_KERNEL_SRC_FMODE_T
133 ZFS_AC_KERNEL_SRC_KUIDGID_T
134 ZFS_AC_KERNEL_SRC_KUID_HELPERS
135 ZFS_AC_KERNEL_SRC_MODULE_PARAM_CALL_CONST
136 ZFS_AC_KERNEL_SRC_RENAME_WANTS_FLAGS
137 ZFS_AC_KERNEL_SRC_CURRENT_TIME
138 ZFS_AC_KERNEL_SRC_USERNS_CAPABILITIES
139 ZFS_AC_KERNEL_SRC_IN_COMPAT_SYSCALL
140 ZFS_AC_KERNEL_SRC_KTIME_GET_COARSE_REAL_TS64
141 ZFS_AC_KERNEL_SRC_TOTALRAM_PAGES_FUNC
142 ZFS_AC_KERNEL_SRC_TOTALHIGH_PAGES
143 ZFS_AC_KERNEL_SRC_KSTRTOUL
145 AC_MSG_CHECKING([for available kernel interfaces])
146 ZFS_LINUX_TEST_COMPILE_ALL([kabi])
147 AC_MSG_RESULT([done])
151 dnl # Check results of kernel interface tests.
153 AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [
154 ZFS_AC_KERNEL_ACCESS_OK_TYPE
155 ZFS_AC_KERNEL_GLOBAL_PAGE_STATE
156 ZFS_AC_KERNEL_OBJTOOL
157 ZFS_AC_KERNEL_CTL_NAME
158 ZFS_AC_KERNEL_PDE_DATA
159 ZFS_AC_KERNEL_FALLOCATE
160 ZFS_AC_KERNEL_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
163 ZFS_AC_KERNEL_USLEEP_RANGE
164 ZFS_AC_KERNEL_KMEM_CACHE
166 ZFS_AC_KERNEL_INODE_TIMES
167 ZFS_AC_KERNEL_INODE_LOCK
168 ZFS_AC_KERNEL_GROUP_INFO_GID
170 ZFS_AC_KERNEL_TIMER_SETUP
171 ZFS_AC_KERNEL_CURRENT_BIO_TAIL
172 ZFS_AC_KERNEL_SUPER_USER_NS
173 ZFS_AC_KERNEL_SUBMIT_BIO
174 ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS
175 ZFS_AC_KERNEL_BLKDEV_GET_BY_PATH
176 ZFS_AC_KERNEL_BLKDEV_REREAD_PART
177 ZFS_AC_KERNEL_INVALIDATE_BDEV
178 ZFS_AC_KERNEL_LOOKUP_BDEV
179 ZFS_AC_KERNEL_BDEV_OPEN_EXCLUSIVE
180 ZFS_AC_KERNEL_BDEV_LOGICAL_BLOCK_SIZE
181 ZFS_AC_KERNEL_BDEV_PHYSICAL_BLOCK_SIZE
182 ZFS_AC_KERNEL_BIO_BVEC_ITER
183 ZFS_AC_KERNEL_BIO_FAILFAST
184 ZFS_AC_KERNEL_BIO_SET_DEV
185 ZFS_AC_KERNEL_BIO_OPS
186 ZFS_AC_KERNEL_BIO_END_IO_T_ARGS
187 ZFS_AC_KERNEL_BIO_BI_STATUS
188 ZFS_AC_KERNEL_BIO_RW_BARRIER
189 ZFS_AC_KERNEL_BIO_RW_DISCARD
190 ZFS_AC_KERNEL_BLK_QUEUE_BDI
191 ZFS_AC_KERNEL_BLK_QUEUE_DISCARD
192 ZFS_AC_KERNEL_BLK_QUEUE_SECURE_ERASE
193 ZFS_AC_KERNEL_BLK_QUEUE_FLAGS
194 ZFS_AC_KERNEL_BLK_QUEUE_FLUSH
195 ZFS_AC_KERNEL_BLK_QUEUE_MAX_HW_SECTORS
196 ZFS_AC_KERNEL_BLK_QUEUE_MAX_SEGMENTS
197 ZFS_AC_KERNEL_BLK_QUEUE_PLUG
198 ZFS_AC_KERNEL_GET_DISK_AND_MODULE
199 ZFS_AC_KERNEL_GET_DISK_RO
200 ZFS_AC_KERNEL_GENERIC_READLINK_GLOBAL
201 ZFS_AC_KERNEL_DISCARD_GRANULARITY
202 ZFS_AC_KERNEL_INODE_OWNER_OR_CAPABLE
205 ZFS_AC_KERNEL_INODE_GETATTR
206 ZFS_AC_KERNEL_INODE_SET_FLAGS
207 ZFS_AC_KERNEL_INODE_SET_IVERSION
208 ZFS_AC_KERNEL_SHOW_OPTIONS
209 ZFS_AC_KERNEL_FILE_INODE
210 ZFS_AC_KERNEL_FILE_DENTRY
212 ZFS_AC_KERNEL_AIO_FSYNC
213 ZFS_AC_KERNEL_EVICT_INODE
214 ZFS_AC_KERNEL_DIRTY_INODE
215 ZFS_AC_KERNEL_SHRINKER
216 ZFS_AC_KERNEL_MKDIR_UMODE_T
217 ZFS_AC_KERNEL_LOOKUP_NAMEIDATA
218 ZFS_AC_KERNEL_CREATE_NAMEIDATA
219 ZFS_AC_KERNEL_GET_LINK
220 ZFS_AC_KERNEL_PUT_LINK
221 ZFS_AC_KERNEL_TMPFILE
222 ZFS_AC_KERNEL_TRUNCATE_RANGE
223 ZFS_AC_KERNEL_AUTOMOUNT
224 ZFS_AC_KERNEL_ENCODE_FH_WITH_INODE
225 ZFS_AC_KERNEL_COMMIT_METADATA
226 ZFS_AC_KERNEL_CLEAR_INODE
227 ZFS_AC_KERNEL_SETATTR_PREPARE
228 ZFS_AC_KERNEL_INSERT_INODE_LOCKED
230 ZFS_AC_KERNEL_TRUNCATE_SETSIZE
231 ZFS_AC_KERNEL_SECURITY_INODE
232 ZFS_AC_KERNEL_FST_MOUNT
234 ZFS_AC_KERNEL_SET_NLINK
235 ZFS_AC_KERNEL_ELEVATOR_CHANGE
237 ZFS_AC_KERNEL_LSEEK_EXECUTE
238 ZFS_AC_KERNEL_VFS_GETATTR
239 ZFS_AC_KERNEL_VFS_FSYNC_2ARGS
240 ZFS_AC_KERNEL_VFS_ITERATE
241 ZFS_AC_KERNEL_VFS_DIRECT_IO
242 ZFS_AC_KERNEL_VFS_RW_ITERATE
243 ZFS_AC_KERNEL_VFS_GENERIC_WRITE_CHECKS
244 ZFS_AC_KERNEL_KMAP_ATOMIC_ARGS
245 ZFS_AC_KERNEL_FOLLOW_DOWN_ONE
246 ZFS_AC_KERNEL_MAKE_REQUEST_FN
247 ZFS_AC_KERNEL_GENERIC_IO_ACCT
249 ZFS_AC_KERNEL_FMODE_T
250 ZFS_AC_KERNEL_KUIDGID_T
251 ZFS_AC_KERNEL_KUID_HELPERS
252 ZFS_AC_KERNEL_MODULE_PARAM_CALL_CONST
253 ZFS_AC_KERNEL_RENAME_WANTS_FLAGS
254 ZFS_AC_KERNEL_CURRENT_TIME
255 ZFS_AC_KERNEL_USERNS_CAPABILITIES
256 ZFS_AC_KERNEL_IN_COMPAT_SYSCALL
257 ZFS_AC_KERNEL_KTIME_GET_COARSE_REAL_TS64
258 ZFS_AC_KERNEL_TOTALRAM_PAGES_FUNC
259 ZFS_AC_KERNEL_TOTALHIGH_PAGES
260 ZFS_AC_KERNEL_KSTRTOUL
264 dnl # Detect name used for Module.symvers file in kernel
266 AC_DEFUN([ZFS_AC_MODULE_SYMVERS], [
267 modpost=$LINUX/scripts/Makefile.modpost
268 AC_MSG_CHECKING([kernel file name for module symbols])
269 AS_IF([test "x$enable_linux_builtin" != xyes -a -f "$modpost"], [
270 AS_IF([grep -q Modules.symvers $modpost], [
271 LINUX_SYMBOLS=Modules.symvers
273 LINUX_SYMBOLS=Module.symvers
276 AS_IF([test ! -f "$LINUX_OBJ/$LINUX_SYMBOLS"], [
278 *** Please make sure the kernel devel package for your distribution
279 *** is installed. If you are building with a custom kernel, make sure
280 *** the kernel is configured, built, and the '--with-linux=PATH'
281 *** configure option refers to the location of the kernel source.
287 AC_MSG_RESULT($LINUX_SYMBOLS)
288 AC_SUBST(LINUX_SYMBOLS)
292 dnl # Detect the kernel to be built against
294 AC_DEFUN([ZFS_AC_KERNEL], [
296 AS_HELP_STRING([--with-linux=PATH],
297 [Path to kernel source]),
298 [kernelsrc="$withval"])
300 AC_ARG_WITH(linux-obj,
301 AS_HELP_STRING([--with-linux-obj=PATH],
302 [Path to kernel build objects]),
303 [kernelbuild="$withval"])
305 AC_MSG_CHECKING([kernel source directory])
306 AS_IF([test -z "$kernelsrc"], [
307 AS_IF([test -e "/lib/modules/$(uname -r)/source"], [
308 headersdir="/lib/modules/$(uname -r)/source"
309 sourcelink=$(readlink -f "$headersdir")
310 ], [test -e "/lib/modules/$(uname -r)/build"], [
311 headersdir="/lib/modules/$(uname -r)/build"
312 sourcelink=$(readlink -f "$headersdir")
314 sourcelink=$(ls -1d /usr/src/kernels/* \
316 2>/dev/null | grep -v obj | tail -1)
319 AS_IF([test -n "$sourcelink" && test -e ${sourcelink}], [
320 kernelsrc=`readlink -f ${sourcelink}`
322 kernelsrc="[Not found]"
325 AS_IF([test "$kernelsrc" = "NONE"], [
331 AC_MSG_RESULT([$kernelsrc])
332 AS_IF([test ! -d "$kernelsrc"], [
334 *** Please make sure the kernel devel package for your distribution
335 *** is installed and then try again. If that fails, you can specify the
336 *** location of the kernel source with the '--with-linux=PATH' option.])
339 AC_MSG_CHECKING([kernel build directory])
340 AS_IF([test -z "$kernelbuild"], [
341 AS_IF([test x$withlinux != xyes -a -e "/lib/modules/$(uname -r)/build"], [
342 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
343 ], [test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}], [
344 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
345 ], [test -d ${kernelsrc}-obj/${target_cpu}/default], [
346 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
347 ], [test -d `dirname ${kernelsrc}`/build-${target_cpu}], [
348 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
350 kernelbuild=${kernelsrc}
353 AC_MSG_RESULT([$kernelbuild])
355 AC_MSG_CHECKING([kernel source version])
356 utsrelease1=$kernelbuild/include/linux/version.h
357 utsrelease2=$kernelbuild/include/linux/utsrelease.h
358 utsrelease3=$kernelbuild/include/generated/utsrelease.h
359 AS_IF([test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1], [
360 utsrelease=linux/version.h
361 ], [test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2], [
362 utsrelease=linux/utsrelease.h
363 ], [test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3], [
364 utsrelease=generated/utsrelease.h
367 AS_IF([test "$utsrelease"], [
368 kernsrcver=`(echo "#include <$utsrelease>";
369 echo "kernsrcver=UTS_RELEASE") |
370 ${CPP} -I $kernelbuild/include - |
371 grep "^kernsrcver=" | cut -d \" -f 2`
373 AS_IF([test -z "$kernsrcver"], [
374 AC_MSG_RESULT([Not found])
376 *** Cannot determine kernel version.
380 AC_MSG_RESULT([Not found])
381 if test "x$enable_linux_builtin" != xyes; then
383 *** Cannot find UTS_RELEASE definition.
387 *** Cannot find UTS_RELEASE definition.
388 *** Please run 'make prepare' inside the kernel source tree.])
392 AC_MSG_RESULT([$kernsrcver])
395 LINUX_OBJ=${kernelbuild}
396 LINUX_VERSION=${kernsrcver}
400 AC_SUBST(LINUX_VERSION)
402 ZFS_AC_MODULE_SYMVERS
406 dnl # Detect the QAT module to be built against, QAT provides hardware
407 dnl # acceleration for data compression:
409 dnl # https://01.org/intel-quickassist-technology
411 dnl # 1) Download and install QAT driver from the above link
412 dnl # 2) Start QAT driver in your system:
413 dnl # service qat_service start
414 dnl # 3) Enable QAT in ZFS, e.g.:
415 dnl # ./configure --with-qat=<qat-driver-path>/QAT1.6
417 dnl # 4) Set GZIP compression in ZFS dataset:
418 dnl # zfs set compression = gzip <dataset>
420 dnl # Then the data written to this ZFS pool is compressed by QAT accelerator
421 dnl # automatically, and de-compressed by QAT when read from the pool.
423 dnl # 1) Get QAT hardware statistics with:
424 dnl # cat /proc/icp_dh895xcc_dev/qat
425 dnl # 2) To disable QAT:
426 dnl # insmod zfs.ko zfs_qat_disable=1
428 AC_DEFUN([ZFS_AC_QAT], [
430 AS_HELP_STRING([--with-qat=PATH],
431 [Path to qat source]),
432 AS_IF([test "$withval" = "yes"],
433 AC_MSG_ERROR([--with-qat=PATH requires a PATH]),
434 [qatsrc="$withval"]))
436 AC_ARG_WITH([qat-obj],
437 AS_HELP_STRING([--with-qat-obj=PATH],
438 [Path to qat build objects]),
439 [qatbuild="$withval"])
441 AS_IF([test ! -z "${qatsrc}"], [
442 AC_MSG_CHECKING([qat source directory])
443 AC_MSG_RESULT([$qatsrc])
444 QAT_SRC="${qatsrc}/quickassist"
445 AS_IF([ test ! -e "$QAT_SRC/include/cpa.h"], [
447 *** Please make sure the qat driver package is installed
448 *** and specify the location of the qat source with the
449 *** '--with-qat=PATH' option then try again. Failed to
455 AS_IF([test ! -z "${qatsrc}"], [
456 AC_MSG_CHECKING([qat build directory])
457 AS_IF([test -z "$qatbuild"], [
458 qatbuild="${qatsrc}/build"
461 AC_MSG_RESULT([$qatbuild])
463 AS_IF([ ! test -e "$QAT_OBJ/icp_qa_al.ko" && ! test -e "$QAT_OBJ/qat_api.ko"], [
465 *** Please make sure the qat driver is installed then try again.
466 *** Failed to find icp_qa_al.ko or qat_api.ko in:
473 AC_DEFINE(HAVE_QAT, 1,
474 [qat is enabled and existed])
478 dnl # Detect the name used for the QAT Module.symvers file.
480 AS_IF([test ! -z "${qatsrc}"], [
481 AC_MSG_CHECKING([qat file for module symbols])
482 QAT_SYMBOLS=$QAT_SRC/lookaside/access_layer/src/Module.symvers
484 AS_IF([test -r $QAT_SYMBOLS], [
485 AC_MSG_RESULT([$QAT_SYMBOLS])
486 AC_SUBST(QAT_SYMBOLS)
489 *** Please make sure the qat driver is installed then try again.
490 *** Failed to find Module.symvers in:
498 dnl # Basic toolchain sanity check.
500 AC_DEFUN([ZFS_AC_KERNEL_TEST_MODULE], [
501 AC_MSG_CHECKING([whether modules can be built])
502 ZFS_LINUX_TRY_COMPILE([], [], [
506 if test "x$enable_linux_builtin" != xyes; then
508 *** Unable to build an empty module.
512 *** Unable to build an empty module.
513 *** Please run 'make scripts' inside the kernel source tree.])
519 dnl # ZFS_LINUX_CONFTEST_H
521 AC_DEFUN([ZFS_LINUX_CONFTEST_H], [
522 test -d build/$2 || mkdir -p build/$2
523 cat - <<_ACEOF >build/$2/$2.h
529 dnl # ZFS_LINUX_CONFTEST_C
531 AC_DEFUN([ZFS_LINUX_CONFTEST_C], [
532 test -d build/$2 || mkdir -p build/$2
533 cat confdefs.h - <<_ACEOF >build/$2/$2.c
539 dnl # ZFS_LINUX_CONFTEST_MAKEFILE
541 dnl # $1 - test case name
542 dnl # $2 - add to top-level Makefile
543 dnl # $3 - additional build flags
545 AC_DEFUN([ZFS_LINUX_CONFTEST_MAKEFILE], [
546 test -d build || mkdir -p build
547 test -d build/$1 || mkdir -p build/$1
549 file=build/$1/Makefile
551 dnl # Example command line to manually build source.
552 cat - <<_ACEOF >$file
553 # Example command line to manually build source
554 # make modules -C $LINUX_OBJ $ARCH_UM M=$PWD/build/$1
556 ccflags-y := -Werror $FRAME_LARGER_THAN
559 dnl # Additional custom CFLAGS as requested.
560 m4_ifval($3, [echo "ccflags-y += $3" >>$file], [])
562 dnl # Test case source
563 echo "obj-m := $1.o" >>$file
565 AS_IF([test "x$2" = "xyes"], [echo "obj-m += $1/" >>build/Makefile], [])
569 dnl # ZFS_LINUX_TEST_PROGRAM(C)([PROLOGUE], [BODY])
571 m4_define([ZFS_LINUX_TEST_PROGRAM], [
583 dnl # ZFS_LINUX_TEST_REMOVE
585 dnl # Removes the specified test source and results.
587 AC_DEFUN([ZFS_LINUX_TEST_REMOVE], [
588 test -d build/$1 && rm -Rf build/$1
589 test -f build/Makefile && sed '/$1/d' build/Makefile
593 dnl # ZFS_LINUX_COMPILE
596 dnl # $2 - test command
597 dnl # $3 - pass command
598 dnl # $4 - fail command
599 dnl # $5 - set KBUILD_MODPOST_NOFINAL='yes'
600 dnl # $6 - set KBUILD_MODPOST_WARN='yes'
602 dnl # Used internally by ZFS_LINUX_TEST_{COMPILE,MODPOST}
604 AC_DEFUN([ZFS_LINUX_COMPILE], [
606 KBUILD_MODPOST_NOFINAL="$5" KBUILD_MODPOST_WARN="$6"
607 make modules -k -j$TEST_JOBS -C $LINUX_OBJ $ARCH_UM
608 M=$PWD/$1 &>$1/build.log])
609 AS_IF([AC_TRY_COMMAND([$2])], [$3], [$4])
613 dnl # ZFS_LINUX_TEST_COMPILE
615 dnl # Perform a full compile excluding the final modpost phase.
617 AC_DEFUN([ZFS_LINUX_TEST_COMPILE], [
618 ZFS_LINUX_COMPILE([$2], [test -f $2/build.log], [
619 mv $2/Makefile $2/Makefile.compile.$1
620 mv $2/build.log $2/build.log.$1
623 *** Unable to compile test source to determine kernel interfaces.])
628 dnl # ZFS_LINUX_TEST_MODPOST
630 dnl # Perform a full compile including the modpost phase. This may
631 dnl # be an incremental build if the objects have already been built.
633 AC_DEFUN([ZFS_LINUX_TEST_MODPOST], [
634 ZFS_LINUX_COMPILE([$2], [test -f $2/build.log], [
635 mv $2/Makefile $2/Makefile.modpost.$1
636 cat $2/build.log >>build/build.log.$1
639 *** Unable to modpost test source to determine kernel interfaces.])
644 dnl # Perform the compilation of the test cases in two phases.
646 dnl # Phase 1) attempt to build the object files for all of the tests
647 dnl # defined by the ZFS_LINUX_TEST_SRC macro. But do not
648 dnl # perform the final modpost stage.
650 dnl # Phase 2) disable all tests which failed the initial compilation,
651 dnl # then invoke the final modpost step for the remaining tests.
653 dnl # This allows us efficiently build the test cases in parallel while
654 dnl # remaining resilient to build failures which are expected when
655 dnl # detecting the available kernel interfaces.
657 dnl # The maximum allowed parallelism can be controlled by setting the
658 dnl # TEST_JOBS environment variable. Otherwise, it default to $(nproc).
660 AC_DEFUN([ZFS_LINUX_TEST_COMPILE_ALL], [
661 dnl # Phase 1 - Compilation only, final linking is skipped.
662 ZFS_LINUX_TEST_COMPILE([$1], [build])
665 dnl # Phase 2 - When building external modules disable test cases
666 dnl # which failed to compile and invoke modpost to verify the
669 dnl # Test names suffixed with '_license' call modpost independently
670 dnl # to ensure that a single incompatibility does not result in the
671 dnl # modpost phase exiting early. This check is not performed on
672 dnl # every symbol since the majority are compatible and doing so
673 dnl # would significantly slow down this phase.
675 dnl # When configuring for builtin (--enable-linux-builtin)
676 dnl # fake the linking step artificially create the expected .ko
677 dnl # files for tests which did compile. This is required for
678 dnl # kernels which do not have loadable module support or have
679 dnl # not yet been built.
681 AS_IF([test "x$enable_linux_builtin" = "xno"], [
682 for dir in $(awk '/^obj-m/ { print [$]3 }' \
683 build/Makefile.compile.$1); do
685 AS_IF([test -f build/$name/$name.o], [
686 AS_IF([test "${name##*_}" = "license"], [
687 ZFS_LINUX_TEST_MODPOST([$1],
689 echo "obj-n += $dir" >>build/Makefile
691 echo "obj-m += $dir" >>build/Makefile
694 echo "obj-n += $dir" >>build/Makefile
698 ZFS_LINUX_TEST_MODPOST([$1], [build])
700 for dir in $(awk '/^obj-m/ { print [$]3 }' \
701 build/Makefile.compile.$1); do
703 AS_IF([test -f build/$name/$name.o], [
704 touch build/$name/$name.ko
711 dnl # ZFS_LINUX_TEST_SRC
716 dnl # $4 - extra cflags
717 dnl # $5 - check license-compatibility
719 dnl # N.B because all of the test cases are compiled in parallel they
720 dnl # must never depend on the results of previous tests. Each test
721 dnl # needs to be entirely independent.
723 AC_DEFUN([ZFS_LINUX_TEST_SRC], [
724 ZFS_LINUX_CONFTEST_C([ZFS_LINUX_TEST_PROGRAM([[$2]], [[$3]])], [$1])
725 ZFS_LINUX_CONFTEST_MAKEFILE([$1], [yes], [$4])
727 AS_IF([ test -n "$5" ], [
728 ZFS_LINUX_CONFTEST_C([ZFS_LINUX_TEST_PROGRAM([[
729 #include <linux/module.h>
730 MODULE_LICENSE("$5");
731 $2]], [[$3]])], [$1_license])
732 ZFS_LINUX_CONFTEST_MAKEFILE([$1_license], [yes], [$4])
737 dnl # ZFS_LINUX_TEST_RESULT
739 dnl # $1 - name of a test source (ZFS_LINUX_TEST_SRC)
740 dnl # $2 - run on success (valid .ko generated)
741 dnl # $3 - run on failure (unable to compile)
743 AC_DEFUN([ZFS_LINUX_TEST_RESULT], [
744 AS_IF([test -d build/$1], [
745 AS_IF([test -f build/$1/$1.ko], [$2], [$3])
748 *** No matching source for the "$1" test, check that
749 *** both the test source and result macros refer to the same name.
755 dnl # ZFS_LINUX_TEST_ERROR
757 dnl # Generic error message which can be used when none of the expected
758 dnl # kernel interfaces were detected.
760 AC_DEFUN([ZFS_LINUX_TEST_ERROR], [
762 *** None of the expected "$1" interfaces were detected.
763 *** This may be because your kernel version is newer than what is
764 *** supported, or you are using a patched custom kernel with
765 *** incompatible modifications.
767 *** ZFS Version: $ZFS_META_ALIAS
768 *** Compatible Kernels: $ZFS_META_KVER_MIN - $ZFS_META_KVER_MAX
773 dnl # ZFS_LINUX_TEST_RESULT_SYMBOL
775 dnl # Like ZFS_LINUX_TEST_RESULT except ZFS_CHECK_SYMBOL_EXPORT is called to
776 dnl # verify symbol exports, unless --enable-linux-builtin was provided to
779 AC_DEFUN([ZFS_LINUX_TEST_RESULT_SYMBOL], [
780 AS_IF([ ! test -f build/$1/$1.ko], [
783 AS_IF([test "x$enable_linux_builtin" != "xyes"], [
784 ZFS_CHECK_SYMBOL_EXPORT([$2], [$3], [$4], [$5])
792 dnl # ZFS_LINUX_COMPILE_IFELSE
794 AC_DEFUN([ZFS_LINUX_COMPILE_IFELSE], [
795 ZFS_LINUX_TEST_REMOVE([conftest])
797 m4_ifvaln([$1], [ZFS_LINUX_CONFTEST_C([$1], [conftest])])
798 m4_ifvaln([$5], [ZFS_LINUX_CONFTEST_H([$5], [conftest])],
799 [ZFS_LINUX_CONFTEST_H([], [conftest])])
801 ZFS_LINUX_CONFTEST_MAKEFILE([conftest], [no],
802 [m4_ifvaln([$5], [-I$PWD/build/conftest], [])])
803 ZFS_LINUX_COMPILE([build/conftest], [$2], [$3], [$4], [], [])
807 dnl # ZFS_LINUX_TRY_COMPILE
811 dnl # $3 - run on success (valid .ko generated)
812 dnl # $4 - run on failure (unable to compile)
814 AC_DEFUN([ZFS_LINUX_TRY_COMPILE], [
815 ZFS_LINUX_COMPILE_IFELSE(
816 [ZFS_LINUX_TEST_PROGRAM([[$1]], [[$2]])],
817 [test -f build/conftest/conftest.ko],
822 dnl # ZFS_CHECK_SYMBOL_EXPORT
824 dnl # Check if a symbol is exported on not by consulting the symbols
825 dnl # file, or optionally the source code.
827 AC_DEFUN([ZFS_CHECK_SYMBOL_EXPORT], [
828 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
829 $LINUX_OBJ/$LINUX_SYMBOLS 2>/dev/null
831 if test $rc -ne 0; then
834 grep -q -E "EXPORT_SYMBOL.*($1)" \
835 "$LINUX/$file" 2>/dev/null
837 if test $rc -eq 0; then
842 if test $export -eq 0; then :
853 dnl # ZFS_LINUX_TRY_COMPILE_SYMBOL
855 dnl # Like ZFS_LINUX_TRY_COMPILER except ZFS_CHECK_SYMBOL_EXPORT is called
856 dnl # to verify symbol exports, unless --enable-linux-builtin was provided
859 AC_DEFUN([ZFS_LINUX_TRY_COMPILE_SYMBOL], [
860 ZFS_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
861 if test $rc -ne 0; then :
864 if test "x$enable_linux_builtin" != xyes; then
865 ZFS_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
867 if test $rc -ne 0; then :
876 dnl # ZFS_LINUX_TRY_COMPILE_HEADER
877 dnl # like ZFS_LINUX_TRY_COMPILE, except the contents conftest.h are
878 dnl # provided via the fifth parameter
880 AC_DEFUN([ZFS_LINUX_TRY_COMPILE_HEADER], [
881 ZFS_LINUX_COMPILE_IFELSE(
882 [ZFS_LINUX_TEST_PROGRAM([[$1]], [[$2]])],
883 [test -f build/conftest/conftest.ko],