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