]> git.proxmox.com Git - mirror_zfs.git/blob - config/kernel.m4
acd7f96189e6ea98780e56d0c16b1a7c4461be2e
[mirror_zfs.git] / config / kernel.m4
1 dnl #
2 dnl # Default ZFS kernel configuration
3 dnl #
4 AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
5 ZFS_AC_KERNEL
6 ZFS_AC_SPL
7 ZFS_AC_QAT
8 ZFS_AC_TEST_MODULE
9 ZFS_AC_KERNEL_OBJTOOL
10 ZFS_AC_KERNEL_CONFIG
11 ZFS_AC_KERNEL_DECLARE_EVENT_CLASS
12 ZFS_AC_KERNEL_CURRENT_BIO_TAIL
13 ZFS_AC_KERNEL_SUPER_USER_NS
14 ZFS_AC_KERNEL_SUBMIT_BIO
15 ZFS_AC_KERNEL_BDEV_BLOCK_DEVICE_OPERATIONS
16 ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS_RELEASE_VOID
17 ZFS_AC_KERNEL_TYPE_FMODE_T
18 ZFS_AC_KERNEL_3ARG_BLKDEV_GET
19 ZFS_AC_KERNEL_BLKDEV_GET_BY_PATH
20 ZFS_AC_KERNEL_OPEN_BDEV_EXCLUSIVE
21 ZFS_AC_KERNEL_LOOKUP_BDEV
22 ZFS_AC_KERNEL_INVALIDATE_BDEV_ARGS
23 ZFS_AC_KERNEL_BDEV_LOGICAL_BLOCK_SIZE
24 ZFS_AC_KERNEL_BDEV_PHYSICAL_BLOCK_SIZE
25 ZFS_AC_KERNEL_BIO_BVEC_ITER
26 ZFS_AC_KERNEL_BIO_FAILFAST_DTD
27 ZFS_AC_KERNEL_BIO_SET_DEV
28 ZFS_AC_KERNEL_REQ_FAILFAST_MASK
29 ZFS_AC_KERNEL_REQ_OP_DISCARD
30 ZFS_AC_KERNEL_REQ_OP_SECURE_ERASE
31 ZFS_AC_KERNEL_REQ_OP_FLUSH
32 ZFS_AC_KERNEL_BIO_BI_OPF
33 ZFS_AC_KERNEL_BIO_END_IO_T_ARGS
34 ZFS_AC_KERNEL_BIO_BI_STATUS
35 ZFS_AC_KERNEL_BIO_RW_BARRIER
36 ZFS_AC_KERNEL_BIO_RW_DISCARD
37 ZFS_AC_KERNEL_BLK_QUEUE_BDI
38 ZFS_AC_KERNEL_BLK_QUEUE_FLUSH
39 ZFS_AC_KERNEL_BLK_QUEUE_MAX_HW_SECTORS
40 ZFS_AC_KERNEL_BLK_QUEUE_MAX_SEGMENTS
41 ZFS_AC_KERNEL_BLK_QUEUE_HAVE_BIO_RW_UNPLUG
42 ZFS_AC_KERNEL_BLK_QUEUE_HAVE_BLK_PLUG
43 ZFS_AC_KERNEL_GET_DISK_AND_MODULE
44 ZFS_AC_KERNEL_GET_DISK_RO
45 ZFS_AC_KERNEL_GET_GENDISK
46 ZFS_AC_KERNEL_HAVE_BIO_SET_OP_ATTRS
47 ZFS_AC_KERNEL_GENERIC_READLINK_GLOBAL
48 ZFS_AC_KERNEL_DISCARD_GRANULARITY
49 ZFS_AC_KERNEL_CONST_XATTR_HANDLER
50 ZFS_AC_KERNEL_XATTR_HANDLER_NAME
51 ZFS_AC_KERNEL_XATTR_HANDLER_GET
52 ZFS_AC_KERNEL_XATTR_HANDLER_SET
53 ZFS_AC_KERNEL_XATTR_HANDLER_LIST
54 ZFS_AC_KERNEL_INODE_OWNER_OR_CAPABLE
55 ZFS_AC_KERNEL_POSIX_ACL_FROM_XATTR_USERNS
56 ZFS_AC_KERNEL_POSIX_ACL_RELEASE
57 ZFS_AC_KERNEL_SET_CACHED_ACL_USABLE
58 ZFS_AC_KERNEL_POSIX_ACL_CHMOD
59 ZFS_AC_KERNEL_POSIX_ACL_EQUIV_MODE_WANTS_UMODE_T
60 ZFS_AC_KERNEL_POSIX_ACL_VALID_WITH_NS
61 ZFS_AC_KERNEL_INODE_OPERATIONS_PERMISSION
62 ZFS_AC_KERNEL_INODE_OPERATIONS_PERMISSION_WITH_NAMEIDATA
63 ZFS_AC_KERNEL_INODE_OPERATIONS_CHECK_ACL
64 ZFS_AC_KERNEL_INODE_OPERATIONS_CHECK_ACL_WITH_FLAGS
65 ZFS_AC_KERNEL_INODE_OPERATIONS_GET_ACL
66 ZFS_AC_KERNEL_INODE_OPERATIONS_SET_ACL
67 ZFS_AC_KERNEL_INODE_OPERATIONS_GETATTR
68 ZFS_AC_KERNEL_INODE_SET_FLAGS
69 ZFS_AC_KERNEL_INODE_SET_IVERSION
70 ZFS_AC_KERNEL_GET_ACL_HANDLE_CACHE
71 ZFS_AC_KERNEL_SHOW_OPTIONS
72 ZFS_AC_KERNEL_FILE_INODE
73 ZFS_AC_KERNEL_FILE_DENTRY
74 ZFS_AC_KERNEL_FSYNC
75 ZFS_AC_KERNEL_EVICT_INODE
76 ZFS_AC_KERNEL_DIRTY_INODE_WITH_FLAGS
77 ZFS_AC_KERNEL_NR_CACHED_OBJECTS
78 ZFS_AC_KERNEL_FREE_CACHED_OBJECTS
79 ZFS_AC_KERNEL_FALLOCATE
80 ZFS_AC_KERNEL_AIO_FSYNC
81 ZFS_AC_KERNEL_MKDIR_UMODE_T
82 ZFS_AC_KERNEL_LOOKUP_NAMEIDATA
83 ZFS_AC_KERNEL_CREATE_NAMEIDATA
84 ZFS_AC_KERNEL_GET_LINK
85 ZFS_AC_KERNEL_PUT_LINK
86 ZFS_AC_KERNEL_TMPFILE
87 ZFS_AC_KERNEL_TRUNCATE_RANGE
88 ZFS_AC_KERNEL_AUTOMOUNT
89 ZFS_AC_KERNEL_ENCODE_FH_WITH_INODE
90 ZFS_AC_KERNEL_COMMIT_METADATA
91 ZFS_AC_KERNEL_CLEAR_INODE
92 ZFS_AC_KERNEL_SETATTR_PREPARE
93 ZFS_AC_KERNEL_INSERT_INODE_LOCKED
94 ZFS_AC_KERNEL_D_MAKE_ROOT
95 ZFS_AC_KERNEL_D_OBTAIN_ALIAS
96 ZFS_AC_KERNEL_D_PRUNE_ALIASES
97 ZFS_AC_KERNEL_D_SET_D_OP
98 ZFS_AC_KERNEL_D_REVALIDATE_NAMEIDATA
99 ZFS_AC_KERNEL_CONST_DENTRY_OPERATIONS
100 ZFS_AC_KERNEL_TRUNCATE_SETSIZE
101 ZFS_AC_KERNEL_6ARGS_SECURITY_INODE_INIT_SECURITY
102 ZFS_AC_KERNEL_CALLBACK_SECURITY_INODE_INIT_SECURITY
103 ZFS_AC_KERNEL_MOUNT_NODEV
104 ZFS_AC_KERNEL_SHRINK
105 ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID
106 ZFS_AC_KERNEL_S_INSTANCES_LIST_HEAD
107 ZFS_AC_KERNEL_S_D_OP
108 ZFS_AC_KERNEL_BDI
109 ZFS_AC_KERNEL_SET_NLINK
110 ZFS_AC_KERNEL_ELEVATOR_CHANGE
111 ZFS_AC_KERNEL_5ARG_SGET
112 ZFS_AC_KERNEL_LSEEK_EXECUTE
113 ZFS_AC_KERNEL_VFS_ITERATE
114 ZFS_AC_KERNEL_VFS_RW_ITERATE
115 ZFS_AC_KERNEL_GENERIC_WRITE_CHECKS
116 ZFS_AC_KERNEL_KMAP_ATOMIC_ARGS
117 ZFS_AC_KERNEL_FOLLOW_DOWN_ONE
118 ZFS_AC_KERNEL_MAKE_REQUEST_FN
119 ZFS_AC_KERNEL_GENERIC_IO_ACCT_3ARG
120 ZFS_AC_KERNEL_GENERIC_IO_ACCT_4ARG
121 ZFS_AC_KERNEL_FPU
122 ZFS_AC_KERNEL_KUID_HELPERS
123 ZFS_AC_KERNEL_MODULE_PARAM_CALL_CONST
124 ZFS_AC_KERNEL_RENAME_WANTS_FLAGS
125 ZFS_AC_KERNEL_HAVE_GENERIC_SETXATTR
126 ZFS_AC_KERNEL_CURRENT_TIME
127 ZFS_AC_KERNEL_GLOBAL_PAGE_STATE
128 ZFS_AC_KERNEL_ACL_HAS_REFCOUNT
129
130 AS_IF([test "$LINUX_OBJ" != "$LINUX"], [
131 KERNEL_MAKE="$KERNEL_MAKE O=$LINUX_OBJ"
132 ])
133
134 AC_SUBST(KERNEL_MAKE)
135 ])
136
137 dnl #
138 dnl # Detect name used for Module.symvers file in kernel
139 dnl #
140 AC_DEFUN([ZFS_AC_MODULE_SYMVERS], [
141 modpost=$LINUX/scripts/Makefile.modpost
142 AC_MSG_CHECKING([kernel file name for module symbols])
143 AS_IF([test "x$enable_linux_builtin" != xyes -a -f "$modpost"], [
144 AS_IF([grep -q Modules.symvers $modpost], [
145 LINUX_SYMBOLS=Modules.symvers
146 ], [
147 LINUX_SYMBOLS=Module.symvers
148 ])
149
150 AS_IF([test ! -f "$LINUX_OBJ/$LINUX_SYMBOLS"], [
151 AC_MSG_ERROR([
152 *** Please make sure the kernel devel package for your distribution
153 *** is installed. If you are building with a custom kernel, make sure the
154 *** kernel is configured, built, and the '--with-linux=PATH' configure
155 *** option refers to the location of the kernel source.])
156 ])
157 ], [
158 LINUX_SYMBOLS=NONE
159 ])
160 AC_MSG_RESULT($LINUX_SYMBOLS)
161 AC_SUBST(LINUX_SYMBOLS)
162 ])
163
164 dnl #
165 dnl # Detect the kernel to be built against
166 dnl #
167 AC_DEFUN([ZFS_AC_KERNEL], [
168 AC_ARG_WITH([linux],
169 AS_HELP_STRING([--with-linux=PATH],
170 [Path to kernel source]),
171 [kernelsrc="$withval"])
172
173 AC_ARG_WITH(linux-obj,
174 AS_HELP_STRING([--with-linux-obj=PATH],
175 [Path to kernel build objects]),
176 [kernelbuild="$withval"])
177
178 AC_MSG_CHECKING([kernel source directory])
179 AS_IF([test -z "$kernelsrc"], [
180 AS_IF([test -e "/lib/modules/$(uname -r)/source"], [
181 headersdir="/lib/modules/$(uname -r)/source"
182 sourcelink=$(readlink -f "$headersdir")
183 ], [test -e "/lib/modules/$(uname -r)/build"], [
184 headersdir="/lib/modules/$(uname -r)/build"
185 sourcelink=$(readlink -f "$headersdir")
186 ], [
187 sourcelink=$(ls -1d /usr/src/kernels/* \
188 /usr/src/linux-* \
189 2>/dev/null | grep -v obj | tail -1)
190 ])
191
192 AS_IF([test -n "$sourcelink" && test -e ${sourcelink}], [
193 kernelsrc=`readlink -f ${sourcelink}`
194 ], [
195 kernelsrc="[Not found]"
196 ])
197 ], [
198 AS_IF([test "$kernelsrc" = "NONE"], [
199 kernsrcver=NONE
200 ])
201 withlinux=yes
202 ])
203
204 AC_MSG_RESULT([$kernelsrc])
205 AS_IF([test ! -d "$kernelsrc"], [
206 AC_MSG_ERROR([
207 *** Please make sure the kernel devel package for your distribution
208 *** is installed and then try again. If that fails, you can specify the
209 *** location of the kernel source with the '--with-linux=PATH' option.])
210 ])
211
212 AC_MSG_CHECKING([kernel build directory])
213 AS_IF([test -z "$kernelbuild"], [
214 AS_IF([test x$withlinux != xyes -a -e "/lib/modules/$(uname -r)/build"], [
215 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
216 ], [test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}], [
217 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
218 ], [test -d ${kernelsrc}-obj/${target_cpu}/default], [
219 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
220 ], [test -d `dirname ${kernelsrc}`/build-${target_cpu}], [
221 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
222 ], [
223 kernelbuild=${kernelsrc}
224 ])
225 ])
226 AC_MSG_RESULT([$kernelbuild])
227
228 AC_MSG_CHECKING([kernel source version])
229 utsrelease1=$kernelbuild/include/linux/version.h
230 utsrelease2=$kernelbuild/include/linux/utsrelease.h
231 utsrelease3=$kernelbuild/include/generated/utsrelease.h
232 AS_IF([test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1], [
233 utsrelease=linux/version.h
234 ], [test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2], [
235 utsrelease=linux/utsrelease.h
236 ], [test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3], [
237 utsrelease=generated/utsrelease.h
238 ])
239
240 AS_IF([test "$utsrelease"], [
241 kernsrcver=`(echo "#include <$utsrelease>";
242 echo "kernsrcver=UTS_RELEASE") |
243 cpp -I $kernelbuild/include |
244 grep "^kernsrcver=" | cut -d \" -f 2`
245
246 AS_IF([test -z "$kernsrcver"], [
247 AC_MSG_RESULT([Not found])
248 AC_MSG_ERROR([*** Cannot determine kernel version.])
249 ])
250 ], [
251 AC_MSG_RESULT([Not found])
252 if test "x$enable_linux_builtin" != xyes; then
253 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
254 else
255 AC_MSG_ERROR([
256 *** Cannot find UTS_RELEASE definition.
257 *** Please run 'make prepare' inside the kernel source tree.])
258 fi
259 ])
260
261 AC_MSG_RESULT([$kernsrcver])
262
263 LINUX=${kernelsrc}
264 LINUX_OBJ=${kernelbuild}
265 LINUX_VERSION=${kernsrcver}
266
267 AC_SUBST(LINUX)
268 AC_SUBST(LINUX_OBJ)
269 AC_SUBST(LINUX_VERSION)
270
271 ZFS_AC_MODULE_SYMVERS
272 ])
273
274
275 dnl #
276 dnl # Detect the SPL module to be built against
277 dnl #
278 AC_DEFUN([ZFS_AC_SPL], [
279 AC_ARG_WITH([spl],
280 AS_HELP_STRING([--with-spl=PATH],
281 [Path to spl source]),
282 AS_IF([test "$withval" = "yes"],
283 AC_MSG_ERROR([--with-spl=PATH requires a PATH]),
284 [splsrc="$withval"]))
285
286 AC_ARG_WITH([spl-obj],
287 AS_HELP_STRING([--with-spl-obj=PATH],
288 [Path to spl build objects]),
289 [splbuild="$withval"])
290
291 AC_ARG_WITH([spl-timeout],
292 AS_HELP_STRING([--with-spl-timeout=SECS],
293 [Wait SECS for SPL header and symver file @<:@default=0@:>@]),
294 [timeout="$withval"], [timeout=0])
295
296 dnl #
297 dnl # The existence of spl.release.in is used to identify a valid
298 dnl # source directory. In order of preference:
299 dnl #
300 splsrc0="/var/lib/dkms/spl/${VERSION}/build"
301 splsrc1="/usr/local/src/spl-${VERSION}/${LINUX_VERSION}"
302 splsrc2="/usr/local/src/spl-${VERSION}"
303 splsrc3="/usr/src/spl-${VERSION}/${LINUX_VERSION}"
304 splsrc4="/usr/src/spl-${VERSION}"
305 splsrc5="../spl/"
306 splsrc6="$LINUX"
307
308 AC_MSG_CHECKING([spl source directory])
309 AS_IF([test -z "${splsrc}"], [
310 [all_spl_sources="
311 ${splsrc0}
312 ${splsrc1}
313 ${splsrc2}
314 ${splsrc3}
315 ${splsrc4}
316 ${splsrc5}
317 ${splsrc6}"],
318 AS_IF([ test -e "${splsrc0}/spl.release.in"], [
319 splsrc=${splsrc0}
320 ], [ test -e "${splsrc1}/spl.release.in"], [
321 splsrc=${splsrc1}
322 ], [ test -e "${splsrc2}/spl.release.in"], [
323 splsrc=${splsrc2}
324 ], [ test -e "${splsrc3}/spl.release.in"], [
325 splsrc=$(readlink -f "${splsrc3}")
326 ], [ test -e "${splsrc4}/spl.release.in" ], [
327 splsrc=${splsrc4}
328 ], [ test -e "${splsrc5}/spl.release.in"], [
329 splsrc=$(readlink -f "${splsrc5}")
330 ], [ test -e "${splsrc6}/spl.release.in" ], [
331 splsrc=${splsrc6}
332 ], [
333 splsrc="[Not found]"
334 ])
335 ], [
336 [all_spl_sources="$withval"],
337 AS_IF([test "$splsrc" = "NONE"], [
338 splbuild=NONE
339 splsrcver=NONE
340 ])
341 ])
342
343 AC_MSG_RESULT([$splsrc])
344 AS_IF([ test ! -e "$splsrc/spl.release.in"], [
345 AC_MSG_ERROR([
346 *** Please make sure the kmod spl devel package for your distribution
347 *** is installed then try again. If that fails you can specify the
348 *** location of the spl source with the '--with-spl=PATH' option.
349 *** The spl version must match the version of ZFS you are building,
350 *** ${VERSION}. Failed to find spl.release.in in the following:
351 $all_spl_sources])
352 ])
353
354 dnl #
355 dnl # The existence of the spl_config.h is used to identify a valid
356 dnl # spl object directory. In many cases the object and source
357 dnl # directory are the same, however the objects may also reside
358 dnl # is a subdirectory named after the kernel version.
359 dnl #
360 dnl # This file is supposed to be available after DKMS finishes
361 dnl # building the SPL kernel module for the target kernel. The
362 dnl # '--with-spl-timeout' option can be passed to pause here,
363 dnl # waiting for the file to appear from a concurrently building
364 dnl # SPL package.
365 dnl #
366 AC_MSG_CHECKING([spl build directory])
367
368 all_spl_config_locs="${splsrc}/${LINUX_VERSION}
369 ${splsrc}"
370
371 while true; do
372 AS_IF([test -z "$splbuild"], [
373 AS_IF([ test -e "${splsrc}/${LINUX_VERSION}/spl_config.h" ], [
374 splbuild="${splsrc}/${LINUX_VERSION}"
375 ], [ test -e "${splsrc}/spl_config.h" ], [
376 splbuild="${splsrc}"
377 ], [ find -L "${splsrc}" -name spl_config.h 2> /dev/null | grep -wq spl_config.h ], [
378 splbuild=$(find -L "${splsrc}" -name spl_config.h | sed 's,/spl_config.h,,')
379 ], [
380 splbuild="[Not found]"
381 ])
382 ])
383 AS_IF([test -e "$splbuild/spl_config.h" -o $timeout -le 0], [
384 break;
385 ], [
386 sleep 1
387 timeout=$((timeout-1))
388 ])
389 done
390
391 AC_MSG_RESULT([$splbuild])
392 AS_IF([ ! test -e "$splbuild/spl_config.h"], [
393 AC_MSG_ERROR([
394 *** Please make sure the kmod spl devel <kernel> package for your
395 *** distribution is installed then try again. If that fails you
396 *** can specify the location of the spl objects with the
397 *** '--with-spl-obj=PATH' option. Failed to find spl_config.h in
398 *** any of the following:
399 $all_spl_config_locs])
400 ])
401
402 AC_MSG_CHECKING([spl source version])
403 AS_IF([test -r $splbuild/spl_config.h &&
404 fgrep -q SPL_META_VERSION $splbuild/spl_config.h], [
405
406 splsrcver=`(echo "#include <spl_config.h>";
407 echo "splsrcver=SPL_META_VERSION-SPL_META_RELEASE") |
408 cpp -I $splbuild |
409 grep "^splsrcver=" | tr -d \" | cut -d= -f2`
410 ])
411
412 AS_IF([test -z "$splsrcver"], [
413 AC_MSG_RESULT([Not found])
414 AC_MSG_ERROR([
415 *** Cannot determine the version of the spl source.
416 *** Please prepare the spl source before running this script])
417 ])
418
419 AC_MSG_RESULT([$splsrcver])
420
421 SPL=${splsrc}
422 SPL_OBJ=${splbuild}
423 SPL_VERSION=${splsrcver}
424
425 AC_SUBST(SPL)
426 AC_SUBST(SPL_OBJ)
427 AC_SUBST(SPL_VERSION)
428
429 dnl #
430 dnl # Detect the name used for the SPL Module.symvers file. If one
431 dnl # does not exist this is likely because the SPL has been configured
432 dnl # but not built. The '--with-spl-timeout' option can be passed
433 dnl # to pause here, waiting for the file to appear from a concurrently
434 dnl # building SPL package. If the file does not appear in time, a good
435 dnl # guess is made as to what this file will be named based on what it
436 dnl # is named in the kernel build products. This file will first be
437 dnl # used at link time so if the guess is wrong the build will fail
438 dnl # then. This unfortunately means the ZFS package does not contain a
439 dnl # reliable mechanism to detect symbols exported by the SPL at
440 dnl # configure time.
441 dnl #
442 AC_MSG_CHECKING([spl file name for module symbols])
443 SPL_SYMBOLS=NONE
444
445 while true; do
446 AS_IF([test -r $SPL_OBJ/Module.symvers], [
447 SPL_SYMBOLS=Module.symvers
448 ], [test -r $SPL_OBJ/Modules.symvers], [
449 SPL_SYMBOLS=Modules.symvers
450 ], [test -r $SPL_OBJ/module/Module.symvers], [
451 SPL_SYMBOLS=Module.symvers
452 ], [test -r $SPL_OBJ/module/Modules.symvers], [
453 SPL_SYMBOLS=Modules.symvers
454 ])
455
456 AS_IF([test $SPL_SYMBOLS != NONE -o $timeout -le 0], [
457 break;
458 ], [
459 sleep 1
460 timeout=$((timeout-1))
461 ])
462 done
463
464 AS_IF([test "$SPL_SYMBOLS" = NONE], [
465 SPL_SYMBOLS=$LINUX_SYMBOLS
466 ])
467
468 AC_MSG_RESULT([$SPL_SYMBOLS])
469 AC_SUBST(SPL_SYMBOLS)
470 ])
471
472 dnl #
473 dnl # Detect the QAT module to be built against
474 dnl # QAT provides hardware acceleration for data compression:
475 dnl # https://01.org/intel-quickassist-technology
476 dnl # * Download and install QAT driver from the above link
477 dnl # * Start QAT driver in your system:
478 dnl # service qat_service start
479 dnl # * Enable QAT in ZFS, e.g.:
480 dnl # ./configure --with-qat=<qat-driver-path>/QAT1.6
481 dnl # make
482 dnl # * Set GZIP compression in ZFS dataset:
483 dnl # zfs set compression = gzip <dataset>
484 dnl # Then the data written to this ZFS pool is compressed
485 dnl # by QAT accelerator automatically, and de-compressed by
486 dnl # QAT when read from the pool.
487 dnl # * Get QAT hardware statistics by:
488 dnl # cat /proc/icp_dh895xcc_dev/qat
489 dnl # * To disable QAT:
490 dnl # insmod zfs.ko zfs_qat_disable=1
491 dnl #
492 AC_DEFUN([ZFS_AC_QAT], [
493 AC_ARG_WITH([qat],
494 AS_HELP_STRING([--with-qat=PATH],
495 [Path to qat source]),
496 AS_IF([test "$withval" = "yes"],
497 AC_MSG_ERROR([--with-qat=PATH requires a PATH]),
498 [qatsrc="$withval"]))
499
500 AC_ARG_WITH([qat-obj],
501 AS_HELP_STRING([--with-qat-obj=PATH],
502 [Path to qat build objects]),
503 [qatbuild="$withval"])
504
505 AS_IF([test ! -z "${qatsrc}"], [
506 AC_MSG_CHECKING([qat source directory])
507 AC_MSG_RESULT([$qatsrc])
508 QAT_SRC="${qatsrc}/quickassist"
509 AS_IF([ test ! -e "$QAT_SRC/include/cpa.h"], [
510 AC_MSG_ERROR([
511 *** Please make sure the qat driver package is installed
512 *** and specify the location of the qat source with the
513 *** '--with-qat=PATH' option then try again. Failed to
514 *** find cpa.h in:
515 ${QAT_SRC}/include])
516 ])
517 ])
518
519 AS_IF([test ! -z "${qatsrc}"], [
520 AC_MSG_CHECKING([qat build directory])
521 AS_IF([test -z "$qatbuild"], [
522 qatbuild="${qatsrc}/build"
523 ])
524
525 AC_MSG_RESULT([$qatbuild])
526 QAT_OBJ=${qatbuild}
527 AS_IF([ ! test -e "$QAT_OBJ/icp_qa_al.ko" && ! test -e "$QAT_OBJ/qat_api.ko"], [
528 AC_MSG_ERROR([
529 *** Please make sure the qat driver is installed then try again.
530 *** Failed to find icp_qa_al.ko or qat_api.ko in:
531 $QAT_OBJ])
532 ])
533
534 AC_SUBST(QAT_SRC)
535 AC_SUBST(QAT_OBJ)
536
537 AC_DEFINE(HAVE_QAT, 1,
538 [qat is enabled and existed])
539 ])
540
541 dnl #
542 dnl # Detect the name used for the QAT Module.symvers file.
543 dnl #
544 AS_IF([test ! -z "${qatsrc}"], [
545 AC_MSG_CHECKING([qat file for module symbols])
546 QAT_SYMBOLS=$QAT_SRC/lookaside/access_layer/src/Module.symvers
547
548 AS_IF([test -r $QAT_SYMBOLS], [
549 AC_MSG_RESULT([$QAT_SYMBOLS])
550 AC_SUBST(QAT_SYMBOLS)
551 ],[
552 AC_MSG_ERROR([
553 *** Please make sure the qat driver is installed then try again.
554 *** Failed to find Module.symvers in:
555 $QAT_SYMBOLS])
556 ])
557 ])
558 ])
559 ])
560
561 dnl #
562 dnl # Basic toolchain sanity check.
563 dnl #
564 AC_DEFUN([ZFS_AC_TEST_MODULE], [
565 AC_MSG_CHECKING([whether modules can be built])
566 ZFS_LINUX_TRY_COMPILE([],[],[
567 AC_MSG_RESULT([yes])
568 ],[
569 AC_MSG_RESULT([no])
570 if test "x$enable_linux_builtin" != xyes; then
571 AC_MSG_ERROR([*** Unable to build an empty module.])
572 else
573 AC_MSG_ERROR([
574 *** Unable to build an empty module.
575 *** Please run 'make scripts' inside the kernel source tree.])
576 fi
577 ])
578 ])
579
580 dnl #
581 dnl # Certain kernel build options are not supported. These must be
582 dnl # detected at configure time and cause a build failure. Otherwise
583 dnl # modules may be successfully built that behave incorrectly.
584 dnl #
585 AC_DEFUN([ZFS_AC_KERNEL_CONFIG], [
586 AS_IF([test "x$cross_compiling" != xyes], [
587 AC_RUN_IFELSE([
588 AC_LANG_PROGRAM([
589 #include "$LINUX/include/linux/license.h"
590 ], [
591 return !license_is_gpl_compatible("$ZFS_META_LICENSE");
592 ])
593 ], [
594 AC_DEFINE([ZFS_IS_GPL_COMPATIBLE], [1],
595 [Define to 1 if GPL-only symbols can be used])
596 ], [
597 ])
598 ])
599
600 ZFS_AC_KERNEL_CONFIG_THREAD_SIZE
601 ZFS_AC_KERNEL_CONFIG_DEBUG_LOCK_ALLOC
602 ])
603
604 dnl #
605 dnl # Check configured THREAD_SIZE
606 dnl #
607 dnl # The stack size will vary by architecture, but as of Linux 3.15 on x86_64
608 dnl # the default thread stack size was increased to 16K from 8K. Therefore,
609 dnl # on newer kernels and some architectures stack usage optimizations can be
610 dnl # conditionally applied to improve performance without negatively impacting
611 dnl # stability.
612 dnl #
613 AC_DEFUN([ZFS_AC_KERNEL_CONFIG_THREAD_SIZE], [
614 AC_MSG_CHECKING([whether kernel was built with 16K or larger stacks])
615 ZFS_LINUX_TRY_COMPILE([
616 #include <linux/module.h>
617 ],[
618 #if (THREAD_SIZE < 16384)
619 #error "THREAD_SIZE is less than 16K"
620 #endif
621 ],[
622 AC_MSG_RESULT([yes])
623 AC_DEFINE(HAVE_LARGE_STACKS, 1, [kernel has large stacks])
624 ],[
625 AC_MSG_RESULT([no])
626 ])
627 ])
628
629 dnl #
630 dnl # Check CONFIG_DEBUG_LOCK_ALLOC
631 dnl #
632 dnl # This is typically only set for debug kernels because it comes with
633 dnl # a performance penalty. However, when it is set it maps the non-GPL
634 dnl # symbol mutex_lock() to the GPL-only mutex_lock_nested() symbol.
635 dnl # This will cause a failure at link time which we'd rather know about
636 dnl # at compile time.
637 dnl #
638 dnl # Since we plan to pursue making mutex_lock_nested() a non-GPL symbol
639 dnl # with the upstream community we add a check to detect this case.
640 dnl #
641 AC_DEFUN([ZFS_AC_KERNEL_CONFIG_DEBUG_LOCK_ALLOC], [
642
643 ZFS_LINUX_CONFIG([DEBUG_LOCK_ALLOC], [
644 AC_MSG_CHECKING([whether mutex_lock() is GPL-only])
645 tmp_flags="$EXTRA_KCFLAGS"
646 ZFS_LINUX_TRY_COMPILE([
647 #include <linux/module.h>
648 #include <linux/mutex.h>
649
650 MODULE_LICENSE("$ZFS_META_LICENSE");
651 ],[
652 struct mutex lock;
653
654 mutex_init(&lock);
655 mutex_lock(&lock);
656 mutex_unlock(&lock);
657 ],[
658 AC_MSG_RESULT(no)
659 ],[
660 AC_MSG_RESULT(yes)
661 AC_MSG_ERROR([
662 *** Kernel built with CONFIG_DEBUG_LOCK_ALLOC which is incompatible
663 *** with the CDDL license and will prevent the module linking stage
664 *** from succeeding. You must rebuild your kernel without this
665 *** option enabled.])
666 ])
667 EXTRA_KCFLAGS="$tmp_flags"
668 ], [])
669 ])
670
671 dnl #
672 dnl # ZFS_LINUX_CONFTEST_H
673 dnl #
674 AC_DEFUN([ZFS_LINUX_CONFTEST_H], [
675 cat - <<_ACEOF >conftest.h
676 $1
677 _ACEOF
678 ])
679
680 dnl #
681 dnl # ZFS_LINUX_CONFTEST_C
682 dnl #
683 AC_DEFUN([ZFS_LINUX_CONFTEST_C], [
684 cat confdefs.h - <<_ACEOF >conftest.c
685 $1
686 _ACEOF
687 ])
688
689 dnl #
690 dnl # ZFS_LANG_PROGRAM(C)([PROLOGUE], [BODY])
691 dnl #
692 m4_define([ZFS_LANG_PROGRAM], [
693 $1
694 int
695 main (void)
696 {
697 dnl Do *not* indent the following line: there may be CPP directives.
698 dnl Don't move the `;' right after for the same reason.
699 $2
700 ;
701 return 0;
702 }
703 ])
704
705 dnl #
706 dnl # ZFS_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
707 dnl #
708 AC_DEFUN([ZFS_LINUX_COMPILE_IFELSE], [
709 m4_ifvaln([$1], [ZFS_LINUX_CONFTEST_C([$1])])
710 m4_ifvaln([$6], [ZFS_LINUX_CONFTEST_H([$6])], [ZFS_LINUX_CONFTEST_H([])])
711 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
712 echo "obj-m := conftest.o" >build/Makefile
713 modpost_flag=''
714 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
715 AS_IF(
716 [AC_TRY_COMMAND(cp conftest.c conftest.h build && make [$2] -C $LINUX_OBJ EXTRA_CFLAGS="-Werror $FRAME_LARGER_THAN $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build $modpost_flag) >/dev/null && AC_TRY_COMMAND([$3])],
717 [$4],
718 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
719 )
720 rm -Rf build
721 ])
722
723 dnl #
724 dnl # ZFS_LINUX_TRY_COMPILE like AC_TRY_COMPILE
725 dnl #
726 AC_DEFUN([ZFS_LINUX_TRY_COMPILE],
727 [ZFS_LINUX_COMPILE_IFELSE(
728 [AC_LANG_SOURCE([ZFS_LANG_PROGRAM([[$1]], [[$2]])])],
729 [modules],
730 [test -s build/conftest.o],
731 [$3], [$4])
732 ])
733
734 dnl #
735 dnl # ZFS_LINUX_CONFIG
736 dnl #
737 AC_DEFUN([ZFS_LINUX_CONFIG],
738 [AC_MSG_CHECKING([whether kernel was built with CONFIG_$1])
739 ZFS_LINUX_TRY_COMPILE([
740 #include <linux/module.h>
741 ],[
742 #ifndef CONFIG_$1
743 #error CONFIG_$1 not #defined
744 #endif
745 ],[
746 AC_MSG_RESULT([yes])
747 $2
748 ],[
749 AC_MSG_RESULT([no])
750 $3
751 ])
752 ])
753
754 dnl #
755 dnl # ZFS_CHECK_SYMBOL_EXPORT
756 dnl # check symbol exported or not
757 dnl #
758 AC_DEFUN([ZFS_CHECK_SYMBOL_EXPORT], [
759 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
760 $LINUX_OBJ/$LINUX_SYMBOLS 2>/dev/null
761 rc=$?
762 if test $rc -ne 0; then
763 export=0
764 for file in $2; do
765 grep -q -E "EXPORT_SYMBOL.*($1)" \
766 "$LINUX/$file" 2>/dev/null
767 rc=$?
768 if test $rc -eq 0; then
769 export=1
770 break;
771 fi
772 done
773 if test $export -eq 0; then :
774 $4
775 else :
776 $3
777 fi
778 else :
779 $3
780 fi
781 ])
782
783 dnl #
784 dnl # ZFS_LINUX_TRY_COMPILE_SYMBOL
785 dnl # like ZFS_LINUX_TRY_COMPILE, except ZFS_CHECK_SYMBOL_EXPORT
786 dnl # is called if not compiling for builtin
787 dnl #
788 AC_DEFUN([ZFS_LINUX_TRY_COMPILE_SYMBOL], [
789 ZFS_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
790 if test $rc -ne 0; then :
791 $6
792 else
793 if test "x$enable_linux_builtin" != xyes; then
794 ZFS_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
795 fi
796 if test $rc -ne 0; then :
797 $6
798 else :
799 $5
800 fi
801 fi
802 ])
803
804 dnl #
805 dnl # ZFS_LINUX_TRY_COMPILE_HEADER
806 dnl # like ZFS_LINUX_TRY_COMPILE, except the contents conftest.h are
807 dnl # provided via the fifth parameter
808 dnl #
809 AC_DEFUN([ZFS_LINUX_TRY_COMPILE_HEADER],
810 [ZFS_LINUX_COMPILE_IFELSE(
811 [AC_LANG_SOURCE([ZFS_LANG_PROGRAM([[$1]], [[$2]])])],
812 [modules],
813 [test -s build/conftest.o],
814 [$3], [$4], [$5])
815 ])