]> git.proxmox.com Git - mirror_zfs-debian.git/blame - config/kernel.m4
New upstream version 0.7.9
[mirror_zfs-debian.git] / config / kernel.m4
CommitLineData
c9c0d073 1dnl #
cae5b340 2dnl # Default ZFS kernel configuration
c9c0d073
BB
3dnl #
4AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
5 ZFS_AC_KERNEL
6 ZFS_AC_SPL
cae5b340 7 ZFS_AC_QAT
319a99a3 8 ZFS_AC_TEST_MODULE
cae5b340 9 ZFS_AC_KERNEL_OBJTOOL
c9c0d073 10 ZFS_AC_KERNEL_CONFIG
ea04106b 11 ZFS_AC_KERNEL_DECLARE_EVENT_CLASS
e10b0808 12 ZFS_AC_KERNEL_CURRENT_BIO_TAIL
cae5b340 13 ZFS_AC_KERNEL_SUPER_USER_NS
87dac73d 14 ZFS_AC_KERNEL_SUBMIT_BIO
c9c0d073 15 ZFS_AC_KERNEL_BDEV_BLOCK_DEVICE_OPERATIONS
c06d4368 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
ea04106b 25 ZFS_AC_KERNEL_BIO_BVEC_ITER
f4af6bb7 26 ZFS_AC_KERNEL_BIO_FAILFAST_DTD
cae5b340 27 ZFS_AC_KERNEL_BIO_SET_DEV
f4af6bb7 28 ZFS_AC_KERNEL_REQ_FAILFAST_MASK
87dac73d
AX
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
c9c0d073 33 ZFS_AC_KERNEL_BIO_END_IO_T_ARGS
cae5b340 34 ZFS_AC_KERNEL_BIO_BI_STATUS
e10b0808
AX
35 ZFS_AC_KERNEL_BIO_RW_BARRIER
36 ZFS_AC_KERNEL_BIO_RW_DISCARD
cae5b340 37 ZFS_AC_KERNEL_BLK_QUEUE_BDI
42f7b73b
AX
38 ZFS_AC_KERNEL_BLK_QUEUE_FLAG_CLEAR
39 ZFS_AC_KERNEL_BLK_QUEUE_FLAG_SET
b18019d2 40 ZFS_AC_KERNEL_BLK_QUEUE_FLUSH
34037afe
ED
41 ZFS_AC_KERNEL_BLK_QUEUE_MAX_HW_SECTORS
42 ZFS_AC_KERNEL_BLK_QUEUE_MAX_SEGMENTS
68d83c55
AX
43 ZFS_AC_KERNEL_BLK_QUEUE_HAVE_BIO_RW_UNPLUG
44 ZFS_AC_KERNEL_BLK_QUEUE_HAVE_BLK_PLUG
42f7b73b 45 ZFS_AC_KERNEL_GET_DISK_AND_MODULE
c9c0d073 46 ZFS_AC_KERNEL_GET_DISK_RO
b5a28807 47 ZFS_AC_KERNEL_GET_GENDISK
68d83c55
AX
48 ZFS_AC_KERNEL_HAVE_BIO_SET_OP_ATTRS
49 ZFS_AC_KERNEL_GENERIC_READLINK_GLOBAL
ee5fd0bb 50 ZFS_AC_KERNEL_DISCARD_GRANULARITY
777d4af8 51 ZFS_AC_KERNEL_CONST_XATTR_HANDLER
5eacc075 52 ZFS_AC_KERNEL_XATTR_HANDLER_NAME
f9637c6c
BB
53 ZFS_AC_KERNEL_XATTR_HANDLER_GET
54 ZFS_AC_KERNEL_XATTR_HANDLER_SET
a08ee875
LG
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
68d83c55 59 ZFS_AC_KERNEL_SET_CACHED_ACL_USABLE
a08ee875 60 ZFS_AC_KERNEL_POSIX_ACL_CHMOD
a08ee875 61 ZFS_AC_KERNEL_POSIX_ACL_EQUIV_MODE_WANTS_UMODE_T
87dac73d 62 ZFS_AC_KERNEL_POSIX_ACL_VALID_WITH_NS
a08ee875
LG
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
68d83c55 68 ZFS_AC_KERNEL_INODE_OPERATIONS_SET_ACL
22929307 69 ZFS_AC_KERNEL_INODE_OPERATIONS_GETATTR
cae5b340 70 ZFS_AC_KERNEL_INODE_SET_FLAGS
42f7b73b 71 ZFS_AC_KERNEL_INODE_SET_IVERSION
68d83c55 72 ZFS_AC_KERNEL_GET_ACL_HANDLE_CACHE
47621f3d 73 ZFS_AC_KERNEL_SHOW_OPTIONS
ea04106b 74 ZFS_AC_KERNEL_FILE_INODE
cae5b340 75 ZFS_AC_KERNEL_FILE_DENTRY
adcd70bd 76 ZFS_AC_KERNEL_FSYNC
2c395def 77 ZFS_AC_KERNEL_EVICT_INODE
8780c539 78 ZFS_AC_KERNEL_DIRTY_INODE_WITH_FLAGS
ab26409d
BB
79 ZFS_AC_KERNEL_NR_CACHED_OBJECTS
80 ZFS_AC_KERNEL_FREE_CACHED_OBJECTS
cb2d1901 81 ZFS_AC_KERNEL_FALLOCATE
68d83c55 82 ZFS_AC_KERNEL_AIO_FSYNC
95f5c63b 83 ZFS_AC_KERNEL_MKDIR_UMODE_T
8f195a90 84 ZFS_AC_KERNEL_LOOKUP_NAMEIDATA
558ef6d0 85 ZFS_AC_KERNEL_CREATE_NAMEIDATA
4d815aed 86 ZFS_AC_KERNEL_GET_LINK
e10b0808 87 ZFS_AC_KERNEL_PUT_LINK
cae5b340 88 ZFS_AC_KERNEL_TMPFILE
ea1fdf46 89 ZFS_AC_KERNEL_TRUNCATE_RANGE
ebe7e575 90 ZFS_AC_KERNEL_AUTOMOUNT
756c3e5a 91 ZFS_AC_KERNEL_ENCODE_FH_WITH_INODE
393b44c7 92 ZFS_AC_KERNEL_COMMIT_METADATA
739a1a82 93 ZFS_AC_KERNEL_CLEAR_INODE
68d83c55 94 ZFS_AC_KERNEL_SETATTR_PREPARE
bdf4328b 95 ZFS_AC_KERNEL_INSERT_INODE_LOCKED
6a0936ba 96 ZFS_AC_KERNEL_D_MAKE_ROOT
055656d4 97 ZFS_AC_KERNEL_D_OBTAIN_ALIAS
ea04106b 98 ZFS_AC_KERNEL_D_PRUNE_ALIASES
f1a05fa1
NB
99 ZFS_AC_KERNEL_D_SET_D_OP
100 ZFS_AC_KERNEL_D_REVALIDATE_NAMEIDATA
101 ZFS_AC_KERNEL_CONST_DENTRY_OPERATIONS
b3129792 102 ZFS_AC_KERNEL_TRUNCATE_SETSIZE
5c03efc3 103 ZFS_AC_KERNEL_6ARGS_SECURITY_INODE_INIT_SECURITY
166dd49d 104 ZFS_AC_KERNEL_CALLBACK_SECURITY_INODE_INIT_SECURITY
42f7b73b 105 ZFS_AC_KERNEL_FST_MOUNT
ab26409d 106 ZFS_AC_KERNEL_SHRINK
ea04106b 107 ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID
c06d4368 108 ZFS_AC_KERNEL_S_INSTANCES_LIST_HEAD
ee930353 109 ZFS_AC_KERNEL_S_D_OP
22929307 110 ZFS_AC_KERNEL_BDI
28eb9213 111 ZFS_AC_KERNEL_SET_NLINK
6d1d976b 112 ZFS_AC_KERNEL_ELEVATOR_CHANGE
3c203610 113 ZFS_AC_KERNEL_5ARG_SGET
c06d4368
AX
114 ZFS_AC_KERNEL_LSEEK_EXECUTE
115 ZFS_AC_KERNEL_VFS_ITERATE
ea04106b 116 ZFS_AC_KERNEL_VFS_RW_ITERATE
68d83c55 117 ZFS_AC_KERNEL_GENERIC_WRITE_CHECKS
e10b0808
AX
118 ZFS_AC_KERNEL_KMAP_ATOMIC_ARGS
119 ZFS_AC_KERNEL_FOLLOW_DOWN_ONE
120 ZFS_AC_KERNEL_MAKE_REQUEST_FN
cae5b340
AX
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
68d83c55
AX
126 ZFS_AC_KERNEL_RENAME_WANTS_FLAGS
127 ZFS_AC_KERNEL_HAVE_GENERIC_SETXATTR
22929307 128 ZFS_AC_KERNEL_CURRENT_TIME
42f7b73b
AX
129 ZFS_AC_KERNEL_GLOBAL_PAGE_STATE
130 ZFS_AC_KERNEL_ACL_HAS_REFCOUNT
131 ZFS_AC_KERNEL_USERNS_CAPABILITIES
c9c0d073 132
8366cd6a 133 AS_IF([test "$LINUX_OBJ" != "$LINUX"], [
6283f55e 134 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
8366cd6a 135 ])
6283f55e
BB
136 AC_SUBST(KERNELMAKE_PARAMS)
137
138
c9c0d073
BB
139 dnl # -Wall -fno-strict-aliasing -Wstrict-prototypes and other
140 dnl # compiler options are added by the kernel build system.
cae5b340
AX
141 KERNELCPPFLAGS="$KERNELCPPFLAGS -std=gnu99"
142 KERNELCPPFLAGS="$KERNELCPPFLAGS -Wno-declaration-after-statement"
8a7e1cee 143 KERNELCPPFLAGS="$KERNELCPPFLAGS $NO_UNUSED_BUT_SET_VARIABLE"
e10b0808 144 KERNELCPPFLAGS="$KERNELCPPFLAGS $NO_BOOL_COMPARE"
c9c0d073
BB
145 KERNELCPPFLAGS="$KERNELCPPFLAGS -DHAVE_SPL -D_KERNEL"
146 KERNELCPPFLAGS="$KERNELCPPFLAGS -DTEXT_DOMAIN=\\\"zfs-linux-kernel\\\""
c9c0d073 147
c9c0d073
BB
148 AC_SUBST(KERNELCPPFLAGS)
149])
150
151dnl #
152dnl # Detect name used for Module.symvers file in kernel
153dnl #
154AC_DEFUN([ZFS_AC_MODULE_SYMVERS], [
155 modpost=$LINUX/scripts/Makefile.modpost
156 AC_MSG_CHECKING([kernel file name for module symbols])
319a99a3 157 AS_IF([test "x$enable_linux_builtin" != xyes -a -f "$modpost"], [
8366cd6a 158 AS_IF([grep -q Modules.symvers $modpost], [
c9c0d073 159 LINUX_SYMBOLS=Modules.symvers
8366cd6a 160 ], [
c9c0d073 161 LINUX_SYMBOLS=Module.symvers
8366cd6a 162 ])
a60b1c0a 163
8366cd6a 164 AS_IF([test ! -f "$LINUX_OBJ/$LINUX_SYMBOLS"], [
a60b1c0a
BB
165 AC_MSG_ERROR([
166 *** Please make sure the kernel devel package for your distribution
c06d4368 167 *** is installed. If you are building with a custom kernel, make sure the
a60b1c0a
BB
168 *** kernel is configured, built, and the '--with-linux=PATH' configure
169 *** option refers to the location of the kernel source.])
8366cd6a
PS
170 ])
171 ], [
c9c0d073 172 LINUX_SYMBOLS=NONE
8366cd6a 173 ])
c9c0d073
BB
174 AC_MSG_RESULT($LINUX_SYMBOLS)
175 AC_SUBST(LINUX_SYMBOLS)
176])
177
178dnl #
179dnl # Detect the kernel to be built against
180dnl #
181AC_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])
8366cd6a
PS
193 AS_IF([test -z "$kernelsrc"], [
194 AS_IF([test -e "/lib/modules/$(uname -r)/source"], [
1b94c25c
BB
195 headersdir="/lib/modules/$(uname -r)/source"
196 sourcelink=$(readlink -f "$headersdir")
8366cd6a 197 ], [test -e "/lib/modules/$(uname -r)/build"], [
1b94c25c 198 headersdir="/lib/modules/$(uname -r)/build"
c9c0d073 199 sourcelink=$(readlink -f "$headersdir")
8366cd6a 200 ], [
c9c0d073 201 sourcelink=$(ls -1d /usr/src/kernels/* \
8366cd6a 202 /usr/src/linux-* \
c9c0d073 203 2>/dev/null | grep -v obj | tail -1)
8366cd6a 204 ])
c9c0d073 205
8366cd6a 206 AS_IF([test -n "$sourcelink" && test -e ${sourcelink}], [
c9c0d073 207 kernelsrc=`readlink -f ${sourcelink}`
8366cd6a 208 ], [
56a517ae 209 kernelsrc="[Not found]"
8366cd6a
PS
210 ])
211 ], [
212 AS_IF([test "$kernelsrc" = "NONE"], [
c9c0d073 213 kernsrcver=NONE
8366cd6a 214 ])
cae5b340 215 withlinux=yes
8366cd6a 216 ])
c9c0d073
BB
217
218 AC_MSG_RESULT([$kernelsrc])
56a517ae
BB
219 AS_IF([test ! -d "$kernelsrc"], [
220 AC_MSG_ERROR([
221 *** Please make sure the kernel devel package for your distribution
c06d4368 222 *** is installed and then try again. If that fails, you can specify the
56a517ae
BB
223 *** location of the kernel source with the '--with-linux=PATH' option.])
224 ])
225
c9c0d073 226 AC_MSG_CHECKING([kernel build directory])
8366cd6a 227 AS_IF([test -z "$kernelbuild"], [
cae5b340 228 AS_IF([test x$withlinux != xyes -a -e "/lib/modules/$(uname -r)/build"], [
1b94c25c 229 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
8366cd6a 230 ], [test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}], [
c9c0d073 231 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
8366cd6a 232 ], [test -d ${kernelsrc}-obj/${target_cpu}/default], [
70574182 233 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
8366cd6a 234 ], [test -d `dirname ${kernelsrc}`/build-${target_cpu}], [
c9c0d073 235 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
8366cd6a 236 ], [
c9c0d073 237 kernelbuild=${kernelsrc}
8366cd6a
PS
238 ])
239 ])
c9c0d073
BB
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
8366cd6a 246 AS_IF([test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1], [
c9c0d073 247 utsrelease=linux/version.h
8366cd6a 248 ], [test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2], [
c9c0d073 249 utsrelease=linux/utsrelease.h
8366cd6a 250 ], [test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3], [
c9c0d073 251 utsrelease=generated/utsrelease.h
8366cd6a 252 ])
c9c0d073 253
8366cd6a 254 AS_IF([test "$utsrelease"], [
c9c0d073
BB
255 kernsrcver=`(echo "#include <$utsrelease>";
256 echo "kernsrcver=UTS_RELEASE") |
257 cpp -I $kernelbuild/include |
258 grep "^kernsrcver=" | cut -d \" -f 2`
259
8366cd6a 260 AS_IF([test -z "$kernsrcver"], [
c9c0d073
BB
261 AC_MSG_RESULT([Not found])
262 AC_MSG_ERROR([*** Cannot determine kernel version.])
8366cd6a
PS
263 ])
264 ], [
c9c0d073 265 AC_MSG_RESULT([Not found])
319a99a3
ED
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
8366cd6a 273 ])
c9c0d073
BB
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
c9c0d073
BB
288
289dnl #
290dnl # Detect the SPL module to be built against
291dnl #
292AC_DEFUN([ZFS_AC_SPL], [
293 AC_ARG_WITH([spl],
294 AS_HELP_STRING([--with-spl=PATH],
295 [Path to spl source]),
cae5b340
AX
296 AS_IF([test "$withval" = "yes"],
297 AC_MSG_ERROR([--with-spl=PATH requires a PATH]),
298 [splsrc="$withval"]))
c9c0d073
BB
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
c06d4368
AX
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
9b2af9a0
BB
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"
ea04106b
AX
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"
c9c0d073
BB
321
322 AC_MSG_CHECKING([spl source directory])
9b2af9a0 323 AS_IF([test -z "${splsrc}"], [
cae5b340
AX
324 [all_spl_sources="
325 ${splsrc0}
326 ${splsrc1}
327 ${splsrc2}
328 ${splsrc3}
329 ${splsrc4}
330 ${splsrc5}
331 ${splsrc6}"],
9b2af9a0
BB
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}
ea04106b
AX
342 ], [ test -e "${splsrc5}/spl.release.in"], [
343 splsrc=$(readlink -f "${splsrc5}")
344 ], [ test -e "${splsrc6}/spl.release.in" ], [
345 splsrc=${splsrc6}
8366cd6a 346 ], [
9b2af9a0 347 splsrc="[Not found]"
8366cd6a
PS
348 ])
349 ], [
cae5b340 350 [all_spl_sources="$withval"],
8366cd6a 351 AS_IF([test "$splsrc" = "NONE"], [
c9c0d073
BB
352 splbuild=NONE
353 splsrcver=NONE
8366cd6a
PS
354 ])
355 ])
c9c0d073
BB
356
357 AC_MSG_RESULT([$splsrc])
9b2af9a0
BB
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
cae5b340
AX
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])
9b2af9a0
BB
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 #
c06d4368
AX
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 #
c9c0d073 380 AC_MSG_CHECKING([spl build directory])
cae5b340
AX
381
382 all_spl_config_locs="${splsrc}/${LINUX_VERSION}
383 ${splsrc}"
384
c06d4368
AX
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}"
e10b0808
AX
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,,')
c06d4368
AX
393 ], [
394 splbuild="[Not found]"
395 ])
396 ])
397 AS_IF([test -e "$splbuild/spl_config.h" -o $timeout -le 0], [
398 break;
9b2af9a0 399 ], [
c06d4368
AX
400 sleep 1
401 timeout=$((timeout-1))
9b2af9a0 402 ])
c06d4368 403 done
9b2af9a0 404
c9c0d073 405 AC_MSG_RESULT([$splbuild])
9b2af9a0
BB
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
cae5b340
AX
411 *** '--with-spl-obj=PATH' option. Failed to find spl_config.h in
412 *** any of the following:
413 $all_spl_config_locs])
9b2af9a0 414 ])
c9c0d073
BB
415
416 AC_MSG_CHECKING([spl source version])
8366cd6a
PS
417 AS_IF([test -r $splbuild/spl_config.h &&
418 fgrep -q SPL_META_VERSION $splbuild/spl_config.h], [
c9c0d073
BB
419
420 splsrcver=`(echo "#include <spl_config.h>";
b40a77ae 421 echo "splsrcver=SPL_META_VERSION-SPL_META_RELEASE") |
5e612145 422 cpp -I $splbuild |
b40a77ae 423 grep "^splsrcver=" | tr -d \" | cut -d= -f2`
8366cd6a 424 ])
c9c0d073 425
8366cd6a 426 AS_IF([test -z "$splsrcver"], [
c9c0d073
BB
427 AC_MSG_RESULT([Not found])
428 AC_MSG_ERROR([
2984e0bb
PS
429 *** Cannot determine the version of the spl source.
430 *** Please prepare the spl source before running this script])
8366cd6a 431 ])
c9c0d073
BB
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
c06d4368
AX
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)
c9c0d073
BB
484])
485
cae5b340
AX
486dnl #
487dnl # Detect the QAT module to be built against
488dnl # QAT provides hardware acceleration for data compression:
489dnl # https://01.org/intel-quickassist-technology
490dnl # * Download and install QAT driver from the above link
491dnl # * Start QAT driver in your system:
492dnl # service qat_service start
493dnl # * Enable QAT in ZFS, e.g.:
494dnl # ./configure --with-qat=<qat-driver-path>/QAT1.6
495dnl # make
496dnl # * Set GZIP compression in ZFS dataset:
497dnl # zfs set compression = gzip <dataset>
498dnl # Then the data written to this ZFS pool is compressed
499dnl # by QAT accelerator automatically, and de-compressed by
500dnl # QAT when read from the pool.
501dnl # * Get QAT hardware statistics by:
502dnl # cat /proc/icp_dh895xcc_dev/qat
503dnl # * To disable QAT:
504dnl # insmod zfs.ko zfs_qat_disable=1
505dnl #
506AC_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}
41d74433 541 AS_IF([ ! test -e "$QAT_OBJ/icp_qa_al.ko" && ! test -e "$QAT_OBJ/qat_api.ko"], [
cae5b340
AX
542 AC_MSG_ERROR([
543 *** Please make sure the qat driver is installed then try again.
41d74433 544 *** Failed to find icp_qa_al.ko or qat_api.ko in:
cae5b340
AX
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
319a99a3
ED
575dnl #
576dnl # Basic toolchain sanity check.
577dnl #
ea04106b
AX
578AC_DEFUN([ZFS_AC_TEST_MODULE], [
579 AC_MSG_CHECKING([whether modules can be built])
319a99a3
ED
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
15805c77
BB
594dnl #
595dnl # Certain kernel build options are not supported. These must be
596dnl # detected at configure time and cause a build failure. Otherwise
597dnl # modules may be successfully built that behave incorrectly.
598dnl #
e5b85622 599AC_DEFUN([ZFS_AC_KERNEL_CONFIG], [
94a40997
AX
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])
ea04106b 610 ], [
ea04106b 611 ])
e5b85622
BB
612 ])
613
68d83c55 614 ZFS_AC_KERNEL_CONFIG_THREAD_SIZE
e5b85622
BB
615 ZFS_AC_KERNEL_CONFIG_DEBUG_LOCK_ALLOC
616])
617
68d83c55
AX
618dnl #
619dnl # Check configured THREAD_SIZE
620dnl #
621dnl # The stack size will vary by architecture, but as of Linux 3.15 on x86_64
622dnl # the default thread stack size was increased to 16K from 8K. Therefore,
623dnl # on newer kernels and some architectures stack usage optimizations can be
624dnl # conditionally applied to improve performance without negatively impacting
625dnl # stability.
626dnl #
627AC_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
e5b85622
BB
643dnl #
644dnl # Check CONFIG_DEBUG_LOCK_ALLOC
645dnl #
646dnl # This is typically only set for debug kernels because it comes with
647dnl # a performance penalty. However, when it is set it maps the non-GPL
648dnl # symbol mutex_lock() to the GPL-only mutex_lock_nested() symbol.
649dnl # This will cause a failure at link time which we'd rather know about
650dnl # at compile time.
651dnl #
652dnl # Since we plan to pursue making mutex_lock_nested() a non-GPL symbol
653dnl # with the upstream community we add a check to detect this case.
654dnl #
655AC_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
cac1f230
NB
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.])
e5b85622
BB
680 ])
681 EXTRA_KCFLAGS="$tmp_flags"
682 ], [])
c9c0d073
BB
683])
684
685dnl #
ea04106b
AX
686dnl # ZFS_LINUX_CONFTEST_H
687dnl #
688AC_DEFUN([ZFS_LINUX_CONFTEST_H], [
689cat - <<_ACEOF >conftest.h
690$1
691_ACEOF
692])
693
c9c0d073 694dnl #
ea04106b
AX
695dnl # ZFS_LINUX_CONFTEST_C
696dnl #
697AC_DEFUN([ZFS_LINUX_CONFTEST_C], [
c9c0d073
BB
698cat confdefs.h - <<_ACEOF >conftest.c
699$1
700_ACEOF
701])
702
703dnl #
704dnl # ZFS_LANG_PROGRAM(C)([PROLOGUE], [BODY])
705dnl #
706m4_define([ZFS_LANG_PROGRAM], [
707$1
708int
709main (void)
710{
711dnl Do *not* indent the following line: there may be CPP directives.
712dnl Don't move the `;' right after for the same reason.
713$2
714 ;
715 return 0;
716}
717])
718
719dnl #
720dnl # ZFS_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
721dnl #
722AC_DEFUN([ZFS_LINUX_COMPILE_IFELSE], [
ea04106b
AX
723 m4_ifvaln([$1], [ZFS_LINUX_CONFTEST_C([$1])])
724 m4_ifvaln([$6], [ZFS_LINUX_CONFTEST_H([$6])], [ZFS_LINUX_CONFTEST_H([])])
fc88a6dd 725 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
c9c0d073 726 echo "obj-m := conftest.o" >build/Makefile
fc88a6dd
ED
727 modpost_flag=''
728 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
c9c0d073 729 AS_IF(
42f7b73b 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])],
c9c0d073
BB
731 [$4],
732 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
733 )
734 rm -Rf build
735])
736
737dnl #
738dnl # ZFS_LINUX_TRY_COMPILE like AC_TRY_COMPILE
739dnl #
740AC_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
748dnl #
749dnl # ZFS_LINUX_CONFIG
750dnl #
751AC_DEFUN([ZFS_LINUX_CONFIG],
68d83c55 752 [AC_MSG_CHECKING([whether kernel was built with CONFIG_$1])
c9c0d073 753 ZFS_LINUX_TRY_COMPILE([
0da78696 754 #include <linux/module.h>
c9c0d073
BB
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
768dnl #
769dnl # ZFS_CHECK_SYMBOL_EXPORT
770dnl # check symbol exported or not
771dnl #
70574182 772AC_DEFUN([ZFS_CHECK_SYMBOL_EXPORT], [
c9c0d073
BB
773 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
774 $LINUX_OBJ/$LINUX_SYMBOLS 2>/dev/null
775 rc=$?
70574182 776 if test $rc -ne 0; then
c9c0d073
BB
777 export=0
778 for file in $2; do
70574182
ED
779 grep -q -E "EXPORT_SYMBOL.*($1)" \
780 "$LINUX/$file" 2>/dev/null
c9c0d073 781 rc=$?
70574182 782 if test $rc -eq 0; then
8366cd6a
PS
783 export=1
784 break;
70574182 785 fi
c9c0d073 786 done
70574182 787 if test $export -eq 0; then :
c9c0d073 788 $4
70574182 789 else :
c9c0d073 790 $3
70574182
ED
791 fi
792 else :
c9c0d073 793 $3
70574182
ED
794 fi
795])
796
797dnl #
798dnl # ZFS_LINUX_TRY_COMPILE_SYMBOL
799dnl # like ZFS_LINUX_TRY_COMPILE, except ZFS_CHECK_SYMBOL_EXPORT
800dnl # is called if not compiling for builtin
801dnl #
802AC_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
c9c0d073 816])
ea04106b
AX
817
818dnl #
819dnl # ZFS_LINUX_TRY_COMPILE_HEADER
820dnl # like ZFS_LINUX_TRY_COMPILE, except the contents conftest.h are
821dnl # provided via the fifth parameter
822dnl #
823AC_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])