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