1 ###############################################################################
2 # Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
3 # Copyright (C) 2007 The Regents of the University of California.
4 # Written by Brian Behlendorf <behlendorf1@llnl.gov>.
5 ###############################################################################
6 # SPL_AC_CONFIG_KERNEL: Default SPL kernel configuration.
7 ###############################################################################
9 AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
13 if test "${LINUX_OBJ}" != "${LINUX}"; then
14 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
16 AC_SUBST(KERNELMAKE_PARAMS)
18 KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes"
19 AC_SUBST(KERNELCPPFLAGS)
24 SPL_AC_DEBUG_KMEM_TRACKING
25 SPL_AC_ATOMIC_SPINLOCK
26 SPL_AC_TYPE_ATOMIC64_CMPXCHG
27 SPL_AC_TYPE_ATOMIC64_XCHG
29 SPL_AC_3ARGS_INIT_WORK
30 SPL_AC_2ARGS_REGISTER_SYSCTL
32 SPL_AC_3ARGS_SHRINKER_CALLBACK
33 SPL_AC_PATH_IN_NAMEIDATA
39 SPL_AC_5ARGS_DEVICE_CREATE
40 SPL_AC_CLASS_DEVICE_CREATE
41 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
42 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
49 SPL_AC_MONOTONIC_CLOCK
52 SPL_AC_MUTEX_OWNER_TASK_STRUCT
53 SPL_AC_MUTEX_LOCK_NESTED
54 SPL_AC_3ARGS_ON_EACH_CPU
55 SPL_AC_KALLSYMS_LOOKUP_NAME
56 SPL_AC_GET_VMALLOC_INFO
58 SPL_AC_FIRST_ONLINE_PGDAT
59 SPL_AC_NEXT_ONLINE_PGDAT
62 SPL_AC_GLOBAL_PAGE_STATE
63 SPL_AC_ZONE_STAT_ITEM_FREE
64 SPL_AC_ZONE_STAT_ITEM_INACTIVE
65 SPL_AC_ZONE_STAT_ITEM_ACTIVE
66 SPL_AC_GET_ZONE_COUNTS
69 SPL_AC_2ARGS_SET_FS_PWD
70 SPL_AC_2ARGS_VFS_UNLINK
71 SPL_AC_4ARGS_VFS_RENAME
73 SPL_AC_2ARGS_VFS_FSYNC
74 SPL_AC_FS_STRUCT_SPINLOCK
77 SPL_AC_PUT_TASK_STRUCT
78 SPL_AC_5ARGS_PROC_HANDLER
80 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
81 SPL_AC_KERNEL_INVALIDATE_INODES
82 SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES
83 SPL_AC_SHRINK_DCACHE_MEMORY
84 SPL_AC_SHRINK_ICACHE_MEMORY
85 SPL_AC_KERN_PATH_PARENT_HEADER
86 SPL_AC_KERN_PATH_PARENT_SYMBOL
87 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
88 SPL_AC_SHRINK_CONTROL_STRUCT
89 SPL_AC_RWSEM_SPINLOCK_IS_RAW
92 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
93 modpost=$LINUX/scripts/Makefile.modpost
94 AC_MSG_CHECKING([kernel file name for module symbols])
95 if test -f "$modpost"; then
96 if grep -q Modules.symvers $modpost; then
97 LINUX_SYMBOLS=Modules.symvers
99 LINUX_SYMBOLS=Module.symvers
102 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
104 *** Please make sure the kernel devel package for your distribution
105 *** is installed. If your building with a custom kernel make sure the
106 *** kernel is configured, built, and the '--with-linux=PATH' configure
107 *** option refers to the location of the kernel source.])
112 AC_MSG_RESULT($LINUX_SYMBOLS)
113 AC_SUBST(LINUX_SYMBOLS)
116 AC_DEFUN([SPL_AC_KERNEL], [
118 AS_HELP_STRING([--with-linux=PATH],
119 [Path to kernel source]),
120 [kernelsrc="$withval"])
122 AC_ARG_WITH([linux-obj],
123 AS_HELP_STRING([--with-linux-obj=PATH],
124 [Path to kernel build objects]),
125 [kernelbuild="$withval"])
127 AC_MSG_CHECKING([kernel source directory])
128 if test -z "$kernelsrc"; then
129 if test -e "/lib/modules/$(uname -r)/source"; then
130 headersdir="/lib/modules/$(uname -r)/source"
131 sourcelink=$(readlink -f "$headersdir")
132 elif test -e "/lib/modules/$(uname -r)/build"; then
133 headersdir="/lib/modules/$(uname -r)/build"
134 sourcelink=$(readlink -f "$headersdir")
136 sourcelink=$(ls -1d /usr/src/kernels/* \
138 2>/dev/null | grep -v obj | tail -1)
141 if test -n "$sourcelink" && test -e ${sourcelink}; then
142 kernelsrc=`readlink -f ${sourcelink}`
144 AC_MSG_RESULT([Not found])
146 *** Please make sure the kernel devel package for your distribution
147 *** is installed then try again. If that fails you can specify the
148 *** location of the kernel source with the '--with-linux=PATH' option.])
151 if test "$kernelsrc" = "NONE"; then
156 AC_MSG_RESULT([$kernelsrc])
157 AC_MSG_CHECKING([kernel build directory])
158 if test -z "$kernelbuild"; then
159 if test -e "/lib/modules/$(uname -r)/build"; then
160 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
161 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
162 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
163 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
164 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
165 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
166 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
168 kernelbuild=${kernelsrc}
171 AC_MSG_RESULT([$kernelbuild])
173 AC_MSG_CHECKING([kernel source version])
174 utsrelease1=$kernelbuild/include/linux/version.h
175 utsrelease2=$kernelbuild/include/linux/utsrelease.h
176 utsrelease3=$kernelbuild/include/generated/utsrelease.h
177 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
178 utsrelease=linux/version.h
179 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
180 utsrelease=linux/utsrelease.h
181 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
182 utsrelease=generated/utsrelease.h
185 if test "$utsrelease"; then
186 kernsrcver=`(echo "#include <$utsrelease>";
187 echo "kernsrcver=UTS_RELEASE") |
188 cpp -I $kernelbuild/include |
189 grep "^kernsrcver=" | cut -d \" -f 2`
191 if test -z "$kernsrcver"; then
192 AC_MSG_RESULT([Not found])
193 AC_MSG_ERROR([*** Cannot determine kernel version.])
196 AC_MSG_RESULT([Not found])
197 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
200 AC_MSG_RESULT([$kernsrcver])
203 LINUX_OBJ=${kernelbuild}
204 LINUX_VERSION=${kernsrcver}
208 AC_SUBST(LINUX_VERSION)
210 SPL_AC_MODULE_SYMVERS
213 AC_DEFUN([SPL_AC_KERNEL_CONFIG], [
214 SPL_LINUX_CONFIG([PREEMPT],
216 *** Kernel built with CONFIG_PREEMPT which is not supported.
217 ** You must rebuild your kernel without this option.]), [])
221 dnl # Default SPL user configuration
223 AC_DEFUN([SPL_AC_CONFIG_USER], [])
226 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
227 dnl # are missing it is non-fatal but you will not be able to build
228 dnl # RPM packages and will be warned if you try too.
230 AC_DEFUN([SPL_AC_RPM], [
234 AC_MSG_CHECKING([whether $RPM is available])
235 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
236 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
238 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
241 AC_MSG_RESULT([$HAVE_RPM])
244 AC_MSG_CHECKING([whether $RPMBUILD is available])
245 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
246 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
248 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
251 AC_MSG_RESULT([$HAVE_RPMBUILD])
256 AC_SUBST(RPM_VERSION)
258 AC_SUBST(HAVE_RPMBUILD)
260 AC_SUBST(RPMBUILD_VERSION)
264 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
265 dnl # tools are missing it is non-fatal but you will not be able to build
266 dnl # DEB packages and will be warned if you try too.
268 AC_DEFUN([SPL_AC_DPKG], [
270 DPKGBUILD=dpkg-buildpackage
272 AC_MSG_CHECKING([whether $DPKG is available])
273 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
274 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
276 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
279 AC_MSG_RESULT([$HAVE_DPKG])
282 AC_MSG_CHECKING([whether $DPKGBUILD is available])
283 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
284 DPKGBUILD_VERSION=$(echo $tmp | \
285 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
287 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
290 AC_MSG_RESULT([$HAVE_DPKGBUILD])
295 AC_SUBST(DPKG_VERSION)
297 AC_SUBST(HAVE_DPKGBUILD)
299 AC_SUBST(DPKGBUILD_VERSION)
303 dnl # Check for pacman+makepkg to build Arch Linux packages. If these
304 dnl # tools are missing it is non-fatal but you will not be able to
305 dnl # build Arch Linux packages and will be warned if you try too.
307 AC_DEFUN([SPL_AC_PACMAN], [
311 AC_MSG_CHECKING([whether $PACMAN is available])
312 tmp=$($PACMAN --version 2>/dev/null)
313 AS_IF([test -n "$tmp"], [
314 PACMAN_VERSION=$(echo $tmp |
315 $AWK '/Pacman/ { print $[3] }' |
318 AC_MSG_RESULT([$HAVE_PACMAN ($PACMAN_VERSION)])
321 AC_MSG_RESULT([$HAVE_PACMAN])
324 AC_MSG_CHECKING([whether $MAKEPKG is available])
325 tmp=$($MAKEPKG --version 2>/dev/null)
326 AS_IF([test -n "$tmp"], [
327 MAKEPKG_VERSION=$(echo $tmp | $AWK '/makepkg/ { print $[3] }')
329 AC_MSG_RESULT([$HAVE_MAKEPKG ($MAKEPKG_VERSION)])
332 AC_MSG_RESULT([$HAVE_MAKEPKG])
335 AC_SUBST(HAVE_PACMAN)
337 AC_SUBST(PACMAN_VERSION)
339 AC_SUBST(HAVE_MAKEPKG)
341 AC_SUBST(MAKEPKG_VERSION)
345 dnl # Until native packaging for various different packing systems
346 dnl # can be added the least we can do is attempt to use alien to
347 dnl # convert the RPM packages to the needed package type. This is
348 dnl # a hack but so far it has worked reasonable well.
350 AC_DEFUN([SPL_AC_ALIEN], [
353 AC_MSG_CHECKING([whether $ALIEN is available])
354 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
355 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
357 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
360 AC_MSG_RESULT([$HAVE_ALIEN])
365 AC_SUBST(ALIEN_VERSION)
369 dnl # Using the VENDOR tag from config.guess set the default
370 dnl # package type for 'make pkg': (rpm | deb | tgz)
372 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
373 AC_MSG_CHECKING([linux distribution])
374 if test -f /etc/redhat-release ; then
376 elif test -f /etc/fedora-release ; then
378 elif test -f /etc/arch-release ; then
380 elif test -f /etc/lsb-release ; then
382 elif test -f /etc/debian_version ; then
384 elif test -f /etc/SuSE-release ; then
386 elif test -f /etc/slackware-version ; then
388 elif test -f /etc/gentoo-release ; then
393 AC_MSG_RESULT([$VENDOR])
396 AC_MSG_CHECKING([default package type])
398 fedora) DEFAULT_PACKAGE=rpm ;;
399 redhat) DEFAULT_PACKAGE=rpm ;;
400 sles) DEFAULT_PACKAGE=rpm ;;
401 ubuntu) DEFAULT_PACKAGE=deb ;;
402 debian) DEFAULT_PACKAGE=deb ;;
403 slackware) DEFAULT_PACKAGE=tgz ;;
404 arch) DEFAULT_PACKAGE=arch;;
405 *) DEFAULT_PACKAGE=rpm ;;
408 AC_MSG_RESULT([$DEFAULT_PACKAGE])
409 AC_SUBST(DEFAULT_PACKAGE)
413 dnl # Default SPL user configuration
415 AC_DEFUN([SPL_AC_PACKAGE], [
416 SPL_AC_DEFAULT_PACKAGE
421 AS_IF([test "$VENDOR" = "arch"], [SPL_AC_PACMAN])
424 AC_DEFUN([SPL_AC_LICENSE], [
425 AC_MSG_CHECKING([spl license])
427 AC_MSG_RESULT([$LICENSE])
428 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
432 AC_DEFUN([SPL_AC_CONFIG], [
434 AC_ARG_WITH([config],
435 AS_HELP_STRING([--with-config=CONFIG],
436 [Config file 'kernel|user|all|srpm']),
437 [SPL_CONFIG="$withval"])
439 AC_MSG_CHECKING([spl config])
440 AC_MSG_RESULT([$SPL_CONFIG]);
443 case "$SPL_CONFIG" in
444 kernel) SPL_AC_CONFIG_KERNEL ;;
445 user) SPL_AC_CONFIG_USER ;;
446 all) SPL_AC_CONFIG_KERNEL
447 SPL_AC_CONFIG_USER ;;
450 AC_MSG_RESULT([Error!])
451 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
452 user kernel|user|all|srpm]) ;;
455 AM_CONDITIONAL([CONFIG_USER],
456 [test "$SPL_CONFIG" = user] ||
457 [test "$SPL_CONFIG" = all])
458 AM_CONDITIONAL([CONFIG_KERNEL],
459 [test "$SPL_CONFIG" = kernel] ||
460 [test "$SPL_CONFIG" = all])
464 dnl # Enable if the SPL should be compiled with internal debugging enabled.
465 dnl # By default this support is disabled.
467 AC_DEFUN([SPL_AC_DEBUG], [
468 AC_MSG_CHECKING([whether debugging is enabled])
469 AC_ARG_ENABLE([debug],
470 [AS_HELP_STRING([--enable-debug],
471 [Enable generic debug support @<:@default=no@:>@])],
475 AS_IF([test "x$enable_debug" = xyes],
477 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
478 DEBUG_CFLAGS="-DDEBUG -Werror"
479 DEBUG_SPL="_with_debug"
481 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
482 DEBUG_CFLAGS="-DNDEBUG"
483 DEBUG_SPL="_without_debug"
486 AC_SUBST(DEBUG_CFLAGS)
488 AC_MSG_RESULT([$enable_debug])
492 dnl # Enabled by default it provides a basic debug log infrastructure.
493 dnl # Each subsystem registers itself with a name and logs messages
494 dnl # using predefined types. If the debug mask it set to allow the
495 dnl # message type it will be written to the internal log. The log
496 dnl # can be dumped to a file by echoing 1 to the 'dump' proc entry,
497 dnl # after dumping the log it must be decoded using the spl utility.
499 dnl # echo 1 >/proc/sys/kernel/spl/debug/dump
500 dnl # spl /tmp/spl-log.xxx.yyy /tmp/spl-log.xxx.yyy.txt
502 AC_DEFUN([SPL_AC_DEBUG_LOG], [
503 AC_ARG_ENABLE([debug-log],
504 [AS_HELP_STRING([--enable-debug-log],
505 [Enable basic debug logging @<:@default=yes@:>@])],
507 [enable_debug_log=yes])
509 AS_IF([test "x$enable_debug_log" = xyes],
511 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG"
512 DEBUG_LOG="_with_debug_log"
513 AC_DEFINE([DEBUG_LOG], [1],
514 [Define to 1 to enable basic debug logging])
516 DEBUG_LOG="_without_debug_log"
520 AC_MSG_CHECKING([whether basic debug logging is enabled])
521 AC_MSG_RESULT([$enable_debug_log])
525 dnl # Enabled by default it provides a minimal level of memory tracking.
526 dnl # A total count of bytes allocated is kept for each alloc and free.
527 dnl # Then at module unload time a report to the console will be printed
528 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
529 dnl # and provide an easy way to inspect the kmem based slab.
531 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
532 AC_ARG_ENABLE([debug-kmem],
533 [AS_HELP_STRING([--enable-debug-kmem],
534 [Enable basic kmem accounting @<:@default=yes@:>@])],
536 [enable_debug_kmem=yes])
538 AS_IF([test "x$enable_debug_kmem" = xyes],
540 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
541 DEBUG_KMEM="_with_debug_kmem"
542 AC_DEFINE([DEBUG_KMEM], [1],
543 [Define to 1 to enable basic kmem accounting])
545 DEBUG_KMEM="_without_debug_kmem"
549 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
550 AC_MSG_RESULT([$enable_debug_kmem])
554 dnl # Disabled by default it provides detailed memory tracking. This
555 dnl # feature also requires --enable-debug-kmem to be set. When enabled
556 dnl # not only will total bytes be tracked but also the location of every
557 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
558 dnl # addresses and where they were allocated will be dumped to the console.
559 dnl # Enabling this feature has a significant impact on performance but it
560 dnl # makes finding memory leaks pretty straight forward.
562 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
563 AC_ARG_ENABLE([debug-kmem-tracking],
564 [AS_HELP_STRING([--enable-debug-kmem-tracking],
565 [Enable detailed kmem tracking @<:@default=no@:>@])],
567 [enable_debug_kmem_tracking=no])
569 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
571 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
572 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
573 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
574 [Define to 1 to enable detailed kmem tracking])
576 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
579 AC_SUBST(DEBUG_KMEM_TRACKING)
580 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
581 AC_MSG_RESULT([$enable_debug_kmem_tracking])
585 dnl # SPL_LINUX_CONFTEST
587 AC_DEFUN([SPL_LINUX_CONFTEST], [
588 cat confdefs.h - <<_ACEOF >conftest.c
594 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
596 m4_define([SPL_LANG_PROGRAM], [
601 dnl Do *not* indent the following line: there may be CPP directives.
602 dnl Don't move the `;' right after for the same reason.
610 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
612 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
613 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
614 rm -Rf build && mkdir -p build
615 echo "obj-m := conftest.o" >build/Makefile
617 [AC_TRY_COMMAND(cp conftest.c build && make [$2] -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build) >/dev/null && AC_TRY_COMMAND([$3])],
619 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
625 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
627 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
628 [SPL_LINUX_COMPILE_IFELSE(
629 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
631 [test -s build/conftest.o],
636 dnl # SPL_LINUX_CONFIG
638 AC_DEFUN([SPL_LINUX_CONFIG],
639 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
640 SPL_LINUX_TRY_COMPILE([
641 #include <linux/module.h>
644 #error CONFIG_$1 not #defined
656 dnl # SPL_CHECK_SYMBOL_EXPORT
657 dnl # check symbol exported or not
659 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
660 [AC_MSG_CHECKING([whether symbol $1 is exported])
661 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
662 $LINUX_OBJ/Module*.symvers 2>/dev/null
664 if test $rc -ne 0; then
667 grep -q -E "EXPORT_SYMBOL.*($1)" \
668 "$LINUX_OBJ/$file" 2>/dev/null
670 if test $rc -eq 0; then
675 if test $export -eq 0; then
689 dnl # SPL_CHECK_SYMBOL_HEADER
690 dnl # check if a symbol prototype is defined in listed headers.
692 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
693 AC_MSG_CHECKING([whether symbol $1 exists in header])
696 grep -q "$2" "$LINUX/$file" 2>/dev/null
698 if test $rc -eq 0; then
703 if test $header -eq 0; then
713 dnl # SPL_CHECK_HEADER
714 dnl # check whether header exists and define HAVE_$2_HEADER
716 AC_DEFUN([SPL_CHECK_HEADER],
717 [AC_MSG_CHECKING([whether header $1 exists])
718 SPL_LINUX_TRY_COMPILE([
723 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
733 dnl # Use the atomic implemenation based on global spinlocks. This
734 dnl # should only be needed by 32-bit kernels which do not provide
735 dnl # the atomic64_* API. It may be optionally enabled as a fallback
736 dnl # if problems are observed with the direct mapping to the native
737 dnl # Linux atomic operations. You may not disable atomic spinlocks
738 dnl # if you kernel does not an atomic64_* API.
740 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
741 AC_ARG_ENABLE([atomic-spinlocks],
742 [AS_HELP_STRING([--enable-atomic-spinlocks],
743 [Atomic types use spinlocks @<:@default=check@:>@])],
745 [enable_atomic_spinlocks=check])
747 SPL_LINUX_TRY_COMPILE([
748 #include <asm/atomic.h>
750 atomic64_t *ptr __attribute__ ((unused));
753 AC_DEFINE(HAVE_ATOMIC64_T, 1,
754 [kernel defines atomic64_t])
759 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
760 AS_IF([test "x$have_atomic64_t" = xyes], [
761 enable_atomic_spinlocks=no
763 enable_atomic_spinlocks=yes
767 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
768 AC_DEFINE([ATOMIC_SPINLOCK], [1],
769 [Atomic types use spinlocks])
771 AS_IF([test "x$have_atomic64_t" = xno], [
773 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
777 AC_MSG_CHECKING([whether atomic types use spinlocks])
778 AC_MSG_RESULT([$enable_atomic_spinlocks])
780 AC_MSG_CHECKING([whether kernel defines atomic64_t])
781 AC_MSG_RESULT([$have_atomic64_t])
785 dnl # 2.6.24 API change,
786 dnl # check if atomic64_cmpxchg is defined
788 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
789 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
790 SPL_LINUX_TRY_COMPILE([
791 #include <asm/atomic.h>
792 #include <asm/system.h>
794 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
797 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
798 [kernel defines atomic64_cmpxchg])
805 dnl # 2.6.24 API change,
806 dnl # check if atomic64_xchg is defined
808 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
809 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
810 SPL_LINUX_TRY_COMPILE([
811 #include <asm/atomic.h>
813 atomic64_xchg((atomic64_t *)NULL, 0);
816 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
817 [kernel defines atomic64_xchg])
824 dnl # 2.6.24 API change,
825 dnl # check if uintptr_t typedef is defined
827 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
828 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
829 SPL_LINUX_TRY_COMPILE([
830 #include <linux/types.h>
832 uintptr_t *ptr __attribute__ ((unused));
835 AC_DEFINE(HAVE_UINTPTR_T, 1,
836 [kernel defines uintptr_t])
843 dnl # 2.6.20 API change,
844 dnl # INIT_WORK use 2 args and not store data inside
846 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
847 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
848 SPL_LINUX_TRY_COMPILE([
849 #include <linux/workqueue.h>
851 struct work_struct work __attribute__ ((unused));
852 INIT_WORK(&work, NULL, NULL);
855 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
856 [INIT_WORK wants 3 args])
863 dnl # 2.6.21 API change,
864 dnl # 'register_sysctl_table' use only one argument instead of two
866 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
867 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
868 SPL_LINUX_TRY_COMPILE([
869 #include <linux/sysctl.h>
871 (void) register_sysctl_table(NULL, 0);
874 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
875 [register_sysctl_table() wants 2 args])
882 dnl # 2.6.23 API change
883 dnl # Old set_shrinker API replaced with register_shrinker
885 AC_DEFUN([SPL_AC_SET_SHRINKER], [
886 AC_MSG_CHECKING([whether set_shrinker() available])
887 SPL_LINUX_TRY_COMPILE([
888 #include <linux/mm.h>
890 return set_shrinker(DEFAULT_SEEKS, NULL);
893 AC_DEFINE(HAVE_SET_SHRINKER, 1,
894 [set_shrinker() available])
901 dnl # 2.6.35 API change,
902 dnl # Add context to shrinker callback
904 AC_DEFUN([SPL_AC_3ARGS_SHRINKER_CALLBACK],
905 [AC_MSG_CHECKING([whether shrinker callback wants 3 args])
906 tmp_flags="$EXTRA_KCFLAGS"
907 EXTRA_KCFLAGS="-Werror"
908 SPL_LINUX_TRY_COMPILE([
909 #include <linux/mm.h>
911 int shrinker_cb(struct shrinker *, int, unsigned int);
913 struct shrinker cache_shrinker = {
914 .shrink = shrinker_cb,
915 .seeks = DEFAULT_SEEKS,
917 register_shrinker(&cache_shrinker);
920 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
921 [shrinker callback wants 3 args])
925 EXTRA_KCFLAGS="$tmp_flags"
929 dnl # 2.6.25 API change,
930 dnl # struct path entry added to struct nameidata
932 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
933 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
934 SPL_LINUX_TRY_COMPILE([
935 #include <linux/namei.h>
937 struct nameidata nd __attribute__ ((unused));
940 nd.path.dentry = NULL;
943 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
944 [struct path used in struct nameidata])
951 dnl # Custom SPL patch may export this system it is not required
953 AC_DEFUN([SPL_AC_TASK_CURR], [
954 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
955 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
960 dnl # 2.6.19 API change,
961 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
963 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
964 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
965 SPL_LINUX_TRY_COMPILE([
966 #include <linux/sysctl.h>
968 #ifndef CTL_UNNUMBERED
969 #error CTL_UNNUMBERED undefined
973 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
974 [unnumbered sysctl support exists])
981 dnl # 2.6.33 API change,
982 dnl # Removed .ctl_name from struct ctl_table.
984 AC_DEFUN([SPL_AC_CTL_NAME], [
985 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
986 SPL_LINUX_TRY_COMPILE([
987 #include <linux/sysctl.h>
989 struct ctl_table ctl __attribute__ ((unused));
993 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
1000 dnl # 2.6.16 API change.
1001 dnl # Check if 'fls64()' is available
1003 AC_DEFUN([SPL_AC_FLS64],
1004 [AC_MSG_CHECKING([whether fls64() is available])
1005 SPL_LINUX_TRY_COMPILE([
1006 #include <linux/bitops.h>
1011 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
1018 dnl # 2.6.18 API change, check whether device_create() is available.
1019 dnl # Device_create() was introduced in 2.6.18 and depricated
1020 dnl # class_device_create() which was fully removed in 2.6.26.
1022 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
1023 SPL_CHECK_SYMBOL_EXPORT(
1025 [drivers/base/core.c],
1026 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
1027 [device_create() is available])],
1032 dnl # 2.6.27 API change,
1033 dnl # device_create() uses 5 args, new 'drvdata' argument.
1035 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
1036 AC_MSG_CHECKING([whether device_create() wants 5 args])
1037 tmp_flags="$EXTRA_KCFLAGS"
1038 EXTRA_KCFLAGS="-Werror"
1039 SPL_LINUX_TRY_COMPILE([
1040 #include <linux/device.h>
1042 device_create(NULL, NULL, 0, NULL, "%d", 1);
1045 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
1046 [device_create wants 5 args])
1050 EXTRA_KCFLAGS="$tmp_flags"
1054 dnl # 2.6.13 API change, check whether class_device_create() is available.
1055 dnl # Class_device_create() was introduced in 2.6.13 and depricated
1056 dnl # class_simple_device_add() which was fully removed in 2.6.13.
1058 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
1059 SPL_CHECK_SYMBOL_EXPORT(
1060 [class_device_create],
1061 [drivers/base/class.c],
1062 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
1063 [class_device_create() is available])],
1068 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
1070 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
1071 SPL_CHECK_SYMBOL_EXPORT(
1072 [set_normalized_timespec],
1074 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
1075 [set_normalized_timespec() is available as export])],
1080 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
1081 dnl # previously it was available in time.h as an inline.
1083 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
1084 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
1085 SPL_LINUX_TRY_COMPILE([
1086 #include <linux/time.h>
1087 void set_normalized_timespec(struct timespec *ts,
1088 time_t sec, long nsec) { }
1095 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
1096 [set_normalized_timespec() is available as inline])
1101 dnl # 2.6.18 API change,
1102 dnl # timespec_sub() inline function available in linux/time.h
1104 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
1105 AC_MSG_CHECKING([whether timespec_sub() is available])
1106 SPL_LINUX_TRY_COMPILE([
1107 #include <linux/time.h>
1109 struct timespec a = { 0 };
1110 struct timespec b = { 0 };
1111 struct timespec c __attribute__ ((unused));
1112 c = timespec_sub(a, b);
1115 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1122 dnl # 2.6.19 API change,
1123 dnl # check if init_utsname() is available in linux/utsname.h
1125 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
1126 AC_MSG_CHECKING([whether init_utsname() is available])
1127 SPL_LINUX_TRY_COMPILE([
1128 #include <linux/utsname.h>
1130 struct new_utsname *a __attribute__ ((unused));
1134 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1141 dnl # 2.6.26 API change,
1142 dnl # definition of struct fdtable relocated to linux/fdtable.h
1144 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
1145 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
1149 dnl # 2.6.14 API change,
1150 dnl # check whether 'files_fdtable()' exists
1152 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
1153 AC_MSG_CHECKING([whether files_fdtable() is available])
1154 SPL_LINUX_TRY_COMPILE([
1155 #include <linux/sched.h>
1156 #include <linux/file.h>
1157 #ifdef HAVE_FDTABLE_HEADER
1158 #include <linux/fdtable.h>
1161 struct files_struct *files = current->files;
1162 struct fdtable *fdt __attribute__ ((unused));
1163 fdt = files_fdtable(files);
1166 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
1173 dnl # 2.6.18 API change,
1174 dnl # added linux/uaccess.h
1176 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1177 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1181 dnl # 2.6.12 API change,
1182 dnl # check whether 'kmalloc_node()' is available.
1184 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1185 AC_MSG_CHECKING([whether kmalloc_node() is available])
1186 SPL_LINUX_TRY_COMPILE([
1187 #include <linux/slab.h>
1189 void *a __attribute__ ((unused));
1190 a = kmalloc_node(1, GFP_KERNEL, 0);
1193 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1200 dnl # 2.6.9 API change,
1201 dnl # check whether 'monotonic_clock()' is available it may
1202 dnl # be available for some archs but not others.
1204 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
1205 SPL_CHECK_SYMBOL_EXPORT(
1208 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1209 [monotonic_clock() is available])],
1214 dnl # 2.6.16 API change,
1215 dnl # check whether 'struct inode' has i_mutex
1217 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1218 AC_MSG_CHECKING([whether struct inode has i_mutex])
1219 SPL_LINUX_TRY_COMPILE([
1220 #include <linux/fs.h>
1221 #include <linux/mutex.h>
1224 mutex_init(&i.i_mutex);
1227 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1234 dnl # 2.6.29 API change,
1235 dnl # Adaptive mutexs introduced.
1237 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1238 AC_MSG_CHECKING([whether struct mutex has owner])
1239 SPL_LINUX_TRY_COMPILE([
1240 #include <linux/mutex.h>
1242 struct mutex mtx __attribute__ ((unused));
1246 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1253 dnl # 2.6.39 API change,
1254 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
1255 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
1256 dnl # was defined. As of 2.6.39 this was changed to a task_struct
1257 dnl # pointer which frankly makes a lot more sense.
1259 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
1260 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
1261 tmp_flags="$EXTRA_KCFLAGS"
1262 EXTRA_KCFLAGS="-Werror"
1263 SPL_LINUX_TRY_COMPILE([
1264 #include <linux/mutex.h>
1266 struct mutex mtx __attribute__ ((unused));
1267 mtx.owner = current;
1270 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
1271 [struct mutex owner is a task_struct])
1275 EXTRA_KCFLAGS="$tmp_flags"
1279 dnl # 2.6.18 API change,
1280 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1281 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1282 dnl # if the mutex validator is disabled or otherwise unavailable.
1284 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1285 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1286 SPL_LINUX_TRY_COMPILE([
1287 #include <linux/mutex.h>
1291 mutex_lock_nested(&mutex, 0);
1294 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1295 [mutex_lock_nested() is available])
1302 dnl # 2.6.27 API change,
1303 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1305 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1306 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1307 SPL_LINUX_TRY_COMPILE([
1308 #include <linux/smp.h>
1310 on_each_cpu(NULL, NULL, 0);
1313 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1314 [on_each_cpu wants 3 args])
1321 dnl # 2.6.18 API change,
1322 dnl # kallsyms_lookup_name no longer exported
1324 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
1325 SPL_CHECK_SYMBOL_EXPORT(
1326 [kallsyms_lookup_name],
1328 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1329 [kallsyms_lookup_name() is available])],
1334 dnl # Proposed API change,
1335 dnl # This symbol is not available in stock kernels. You may build a
1336 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1337 dnl # these symbols for use. If your already rolling a custom kernel for
1338 dnl # your environment this is recommended.
1340 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
1341 SPL_CHECK_SYMBOL_EXPORT(
1344 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1345 [get_vmalloc_info() is available])],
1350 dnl # 2.6.17 API change
1351 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1352 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1353 dnl # were exported in 2.6.17 for use by modules which was consistent with
1354 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1355 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1356 dnl # were dropped entirely leaving modules no way to directly iterate over
1357 dnl # the zone list. Because we need access to the zone helpers we check
1358 dnl # if the kernel contains the old or new implementation. Then we check
1359 dnl # to see if the symbols we need for each version are available. If they
1360 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1362 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1363 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1364 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1366 if test $rc -eq 0; then
1367 AC_MSG_RESULT([yes])
1368 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1375 dnl # Proposed API change,
1376 dnl # This symbol is not available in stock kernels. You may build a
1377 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1378 dnl # these symbols for use. If your already rolling a custom kernel for
1379 dnl # your environment this is recommended.
1381 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
1382 SPL_CHECK_SYMBOL_EXPORT(
1383 [first_online_pgdat],
1385 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1386 [first_online_pgdat() is available])],
1391 dnl # Proposed API change,
1392 dnl # This symbol is not available in stock kernels. You may build a
1393 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1394 dnl # these symbols for use. If your already rolling a custom kernel for
1395 dnl # your environment this is recommended.
1397 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
1398 SPL_CHECK_SYMBOL_EXPORT(
1399 [next_online_pgdat],
1401 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1402 [next_online_pgdat() is available])],
1407 dnl # Proposed API change,
1408 dnl # This symbol is not available in stock kernels. You may build a
1409 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1410 dnl # these symbols for use. If your already rolling a custom kernel for
1411 dnl # your environment this is recommended.
1413 AC_DEFUN([SPL_AC_NEXT_ZONE], [
1414 SPL_CHECK_SYMBOL_EXPORT(
1417 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1418 [next_zone() is available])],
1423 dnl # 2.6.17 API change,
1424 dnl # See SPL_AC_PGDAT_HELPERS for details.
1426 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1427 SPL_CHECK_SYMBOL_EXPORT(
1430 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1431 [pgdat_list is available])],
1436 dnl # 2.6.18 API change,
1437 dnl # First introduced global_page_state() support as an inline.
1439 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1440 AC_MSG_CHECKING([whether global_page_state() is available])
1441 SPL_LINUX_TRY_COMPILE([
1442 #include <linux/mm.h>
1444 unsigned long state __attribute__ ((unused));
1445 state = global_page_state(0);
1448 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1449 [global_page_state() is available])
1456 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1457 dnl # Public global zone stats now include a free page count. However
1458 dnl # the enumerated names of the counters have changed since this API
1459 dnl # was introduced. We need to deduce the corrent name to use. This
1460 dnl # replaces the priviate get_zone_counts() interface.
1462 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1463 dnl # is 2.6.30 as of when this was written.
1465 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1466 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1467 SPL_LINUX_TRY_COMPILE([
1468 #include <linux/mm.h>
1470 enum zone_stat_item zsi __attribute__ ((unused));
1471 zsi = NR_FREE_PAGES;
1474 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1475 [Page state NR_FREE_PAGES is available])
1482 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1483 dnl # Public global zone stats now include an inactive page count. However
1484 dnl # the enumerated names of the counters have changed since this API
1485 dnl # was introduced. We need to deduce the corrent name to use. This
1486 dnl # replaces the priviate get_zone_counts() interface.
1488 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1489 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1490 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1492 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1493 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1494 SPL_LINUX_TRY_COMPILE([
1495 #include <linux/mm.h>
1497 enum zone_stat_item zsi __attribute__ ((unused));
1501 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1502 [Page state NR_INACTIVE is available])
1507 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1508 SPL_LINUX_TRY_COMPILE([
1509 #include <linux/mm.h>
1511 enum zone_stat_item zsi __attribute__ ((unused));
1512 zsi = NR_INACTIVE_ANON;
1515 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1516 [Page state NR_INACTIVE_ANON is available])
1521 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1522 SPL_LINUX_TRY_COMPILE([
1523 #include <linux/mm.h>
1525 enum zone_stat_item zsi __attribute__ ((unused));
1526 zsi = NR_INACTIVE_FILE;
1529 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1530 [Page state NR_INACTIVE_FILE is available])
1537 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1538 dnl # Public global zone stats now include an active page count. However
1539 dnl # the enumerated names of the counters have changed since this API
1540 dnl # was introduced. We need to deduce the corrent name to use. This
1541 dnl # replaces the priviate get_zone_counts() interface.
1543 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1544 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1545 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1547 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1548 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1549 SPL_LINUX_TRY_COMPILE([
1550 #include <linux/mm.h>
1552 enum zone_stat_item zsi __attribute__ ((unused));
1556 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1557 [Page state NR_ACTIVE is available])
1562 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1563 SPL_LINUX_TRY_COMPILE([
1564 #include <linux/mm.h>
1566 enum zone_stat_item zsi __attribute__ ((unused));
1567 zsi = NR_ACTIVE_ANON;
1570 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1571 [Page state NR_ACTIVE_ANON is available])
1576 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1577 SPL_LINUX_TRY_COMPILE([
1578 #include <linux/mm.h>
1580 enum zone_stat_item zsi __attribute__ ((unused));
1581 zsi = NR_ACTIVE_FILE;
1584 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1585 [Page state NR_ACTIVE_FILE is available])
1592 dnl # Proposed API change for legacy kernels.
1593 dnl # This symbol is not available in older kernels. For kernels post
1594 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1595 dnl # page state information. This symbol is only used in legacy kernels
1596 dnl # any only as a last resort.
1598 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1599 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1600 SPL_LINUX_TRY_COMPILE([
1602 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1603 #error "global_page_state needs NR_FREE_PAGES"
1606 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1607 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1608 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1609 #error "global_page_state needs NR_ACTIVE*"
1612 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1613 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1614 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1615 #error "global_page_state needs NR_INACTIVE*"
1621 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1622 [get_zone_counts() is needed])
1624 SPL_CHECK_SYMBOL_EXPORT(
1627 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1628 [get_zone_counts() is available])],
1634 dnl # 2.6.27 API change,
1635 dnl # The user_path_dir() replaces __user_walk()
1637 AC_DEFUN([SPL_AC_USER_PATH_DIR], [
1638 SPL_CHECK_SYMBOL_EXPORT(
1641 [AC_DEFINE(HAVE_USER_PATH_DIR, 1,
1642 [user_path_dir() is available])],
1647 dnl # Symbol available in RHEL kernels not in stock kernels.
1649 AC_DEFUN([SPL_AC_SET_FS_PWD], [
1650 SPL_CHECK_SYMBOL_EXPORT(
1653 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1654 [set_fs_pwd() is available])],
1659 dnl # 2.6.25 API change,
1660 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1662 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1663 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1664 SPL_LINUX_TRY_COMPILE([
1665 #include <linux/sched.h>
1666 #include <linux/fs_struct.h>
1668 set_fs_pwd(NULL, NULL);
1671 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1672 [set_fs_pwd() wants 2 args])
1679 dnl # SLES API change, never adopted in mainline,
1680 dnl # Third 'struct vfsmount *' argument removed.
1682 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1683 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1684 SPL_LINUX_TRY_COMPILE([
1685 #include <linux/fs.h>
1687 vfs_unlink(NULL, NULL);
1690 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1691 [vfs_unlink() wants 2 args])
1698 dnl # SLES API change, never adopted in mainline,
1699 dnl # Third and sixth 'struct vfsmount *' argument removed.
1701 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1702 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1703 SPL_LINUX_TRY_COMPILE([
1704 #include <linux/fs.h>
1706 vfs_rename(NULL, NULL, NULL, NULL);
1709 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1710 [vfs_rename() wants 4 args])
1717 dnl # 2.6.36 API change,
1718 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1719 dnl # a spinlock_t to improve the fastpath performance.
1721 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1722 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1723 tmp_flags="$EXTRA_KCFLAGS"
1724 EXTRA_KCFLAGS="-Werror"
1725 SPL_LINUX_TRY_COMPILE([
1726 #include <linux/sched.h>
1727 #include <linux/fs_struct.h>
1729 struct fs_struct fs;
1730 spin_lock_init(&fs.lock);
1733 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1734 [struct fs_struct uses spinlock_t])
1738 EXTRA_KCFLAGS="$tmp_flags"
1742 dnl # 2.6.29 API change,
1743 dnl # check whether 'struct cred' exists
1745 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1746 AC_MSG_CHECKING([whether struct cred exists])
1747 SPL_LINUX_TRY_COMPILE([
1748 #include <linux/cred.h>
1750 struct cred *cr __attribute__ ((unused));
1754 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1761 dnl # Custom SPL patch may export this symbol.
1763 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1764 SPL_CHECK_SYMBOL_EXPORT(
1767 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1768 [groups_search() is available])],
1773 dnl # 2.6.x API change,
1774 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1776 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1777 SPL_CHECK_SYMBOL_EXPORT(
1778 [__put_task_struct],
1780 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1781 [__put_task_struct() is available])],
1786 dnl # 2.6.32 API change,
1787 dnl # Unused 'struct file *' removed from prototype.
1789 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1790 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1791 SPL_LINUX_TRY_COMPILE([
1792 #include <linux/sysctl.h>
1794 proc_dostring(NULL, 0, NULL, NULL, NULL);
1797 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1798 [proc_handler() wants 5 args])
1805 dnl # 2.6.x API change,
1806 dnl # kvasprintf() function added.
1808 AC_DEFUN([SPL_AC_KVASPRINTF], [
1809 SPL_CHECK_SYMBOL_EXPORT(
1812 [AC_DEFINE(HAVE_KVASPRINTF, 1,
1813 [kvasprintf() is available])],
1818 dnl # 2.6.29 API change,
1819 dnl # vfs_fsync() funcation added, prior to this use file_fsync().
1821 AC_DEFUN([SPL_AC_VFS_FSYNC], [
1822 SPL_CHECK_SYMBOL_EXPORT(
1825 [AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])],
1830 dnl # 2.6.35 API change,
1831 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
1833 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
1834 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
1835 SPL_LINUX_TRY_COMPILE([
1836 #include <linux/fs.h>
1841 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
1848 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
1849 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
1850 dnl # condition. The fixed version is exported as a symbol. The race
1851 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
1852 dnl # call that version while holding sem->wait_lock.
1854 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED], [
1855 SPL_CHECK_SYMBOL_EXPORT(
1857 [lib/rwsem-spinlock.c],
1858 [AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
1859 [rwsem_is_locked() acquires sem->wait_lock])],
1864 dnl # 2.6.37 API compat,
1865 dnl # The function invalidate_inodes() is no longer exported by the kernel.
1866 dnl # The prototype however is still available which means it is safe
1867 dnl # to acquire the symbol's address using spl_kallsyms_lookup_name().
1869 dnl # The Proxmox VE kernel contains a patch which renames the function
1870 dnl # invalidate_inodes() to invalidate_inodes_check(). In the process
1871 dnl # it adds a 'check' argument and a '#define invalidate_inodes(x)'
1872 dnl # compatibility wrapper for legacy callers. Therefore, if either
1873 dnl # of these functions are exported invalidate_inodes() can be
1876 AC_DEFUN([SPL_AC_KERNEL_INVALIDATE_INODES], [
1877 SPL_CHECK_SYMBOL_EXPORT(
1878 [invalidate_inodes],
1880 [AC_DEFINE(HAVE_INVALIDATE_INODES, 1,
1881 [invalidate_inodes() is available])],
1883 SPL_CHECK_SYMBOL_EXPORT(
1884 [invalidate_inodes_check],
1886 [AC_DEFINE(HAVE_INVALIDATE_INODES_CHECK, 1,
1887 [invalidate_inodes_check() is available])],
1892 dnl # 2.6.39 API compat,
1893 dnl # The function invalidate_inodes() now take 2 arguments. The second
1894 dnl # 'kill_dirty' argument describes how invalidate_inodes() should
1895 dnl # handle dirty inodes. Only when set will dirty inodes be discarded,
1896 dnl # otherwise they will be handled as busy.
1898 dnl # Unfortunately, we don't have access to the invalidate_inodes()
1899 dnl # prototype so it's not easy to check how many arguments it takes.
1900 dnl # However, this change was done for the benefit of invalidate_device()
1901 dnl # which also added an argument. The invalidate_device() symbol does
1902 dnl # exist in the development headers so if it takes two arguments we
1903 dnl # can fairly safely infer that invalidate_inodes() takes two arguments
1904 dnl # as well. See commit 93b270f76e7ef3b81001576860c2701931cdc78b.
1906 AC_DEFUN([SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES],
1907 [AC_MSG_CHECKING([whether invalidate_inodes() wants 2 args])
1908 SPL_LINUX_TRY_COMPILE([
1909 #include <linux/fs.h>
1911 return __invalidate_device(NULL, 0);
1914 AC_DEFINE(HAVE_2ARGS_INVALIDATE_INODES, 1,
1915 [invalidate_inodes() wants 2 args])
1922 dnl # 2.6.xx API compat,
1923 dnl # There currently exists no exposed API to partially shrink the dcache.
1924 dnl # The expected mechanism to shrink the cache is a registered shrinker
1925 dnl # which is called during memory pressure.
1927 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY], [
1928 SPL_CHECK_SYMBOL_EXPORT(
1929 [shrink_dcache_memory],
1931 [AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
1932 [shrink_dcache_memory() is available])],
1937 dnl # 2.6.xx API compat,
1938 dnl # There currently exists no exposed API to partially shrink the icache.
1939 dnl # The expected mechanism to shrink the cache is a registered shrinker
1940 dnl # which is called during memory pressure.
1942 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY], [
1943 SPL_CHECK_SYMBOL_EXPORT(
1944 [shrink_icache_memory],
1946 [AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
1947 [shrink_icache_memory() is available])],
1952 dnl # 2.6.39 API compat,
1953 dnl # The path_lookup() function has been renamed to kern_path_parent()
1954 dnl # and the flags argument has been removed. The only behavior now
1955 dnl # offered is that of LOOKUP_PARENT. The spl already always passed
1956 dnl # this flag so dropping the flag does not impact us.
1958 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_HEADER], [
1959 SPL_CHECK_SYMBOL_HEADER(
1961 [int kern_path_parent(const char \*, struct nameidata \*)],
1962 [include/linux/namei.h],
1963 [AC_DEFINE(HAVE_KERN_PATH_PARENT_HEADER, 1,
1964 [kern_path_parent() is available])],
1969 dnl # 3.1 API compat,
1970 dnl # The kern_path_parent() symbol is no longer exported by the kernel.
1971 dnl # However, it remains the prefered interface and since we still have
1972 dnl # access to the prototype we dynamically lookup the required address.
1974 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_SYMBOL], [
1975 SPL_CHECK_SYMBOL_EXPORT(
1978 [AC_DEFINE(HAVE_KERN_PATH_PARENT_SYMBOL, 1,
1979 [kern_path_parent() is available])],
1984 dnl # 2.6.39 API compat,
1985 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
1986 dnl # This was done to avoid always having to allocate the maximum size
1987 dnl # workspace (268K). The caller can now specific the windowBits and
1988 dnl # memLevel compression parameters to get a smaller workspace.
1990 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
1991 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
1992 SPL_LINUX_TRY_COMPILE([
1993 #include <linux/zlib.h>
1995 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
1998 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
1999 [zlib_deflate_workspacesize() wants 2 args])
2006 dnl # 2.6.39 API change,
2007 dnl # Shrinker adjust to use common shrink_control structure.
2009 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
2010 AC_MSG_CHECKING([whether struct shrink_control exists])
2011 SPL_LINUX_TRY_COMPILE([
2012 #include <linux/mm.h>
2014 struct shrink_control sc __attribute__ ((unused));
2017 sc.gfp_mask = GFP_KERNEL;
2020 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
2021 [struct shrink_control exists])
2028 dnl # 3.1 API Change
2030 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
2031 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
2033 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
2034 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
2035 tmp_flags="$EXTRA_KCFLAGS"
2036 EXTRA_KCFLAGS="-Werror"
2037 SPL_LINUX_TRY_COMPILE([
2038 #include <linux/rwsem.h>
2040 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
2041 raw_spinlock_t dummy_lock __attribute__ ((unused));
2042 dummy_semaphore.wait_lock = dummy_lock;
2045 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
2046 [struct rw_semaphore member wait_lock is raw_spinlock_t])
2050 EXTRA_KCFLAGS="$tmp_flags"