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