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/toss-release ; then
376 elif test -f /etc/fedora-release ; then
378 elif test -f /etc/redhat-release ; then
380 elif test -f /etc/gentoo-release ; then
382 elif test -f /etc/arch-release ; then
384 elif test -f /etc/SuSE-release ; then
386 elif test -f /etc/slackware-version ; then
388 elif test -f /etc/lunar.release ; then
390 elif test -f /etc/lsb-release ; then
392 elif test -f /etc/debian_version ; then
397 AC_MSG_RESULT([$VENDOR])
400 AC_MSG_CHECKING([default package type])
402 toss) DEFAULT_PACKAGE=rpm ;;
403 redhat) DEFAULT_PACKAGE=rpm ;;
404 fedora) DEFAULT_PACKAGE=rpm ;;
405 gentoo) DEFAULT_PACKAGE=tgz ;;
406 arch) DEFAULT_PACKAGE=arch ;;
407 sles) DEFAULT_PACKAGE=rpm ;;
408 slackware) DEFAULT_PACKAGE=tgz ;;
409 lunar) DEFAULT_PACKAGE=tgz ;;
410 ubuntu) DEFAULT_PACKAGE=deb ;;
411 debian) DEFAULT_PACKAGE=deb ;;
412 *) DEFAULT_PACKAGE=rpm ;;
415 AC_MSG_RESULT([$DEFAULT_PACKAGE])
416 AC_SUBST(DEFAULT_PACKAGE)
420 dnl # Default SPL user configuration
422 AC_DEFUN([SPL_AC_PACKAGE], [
423 SPL_AC_DEFAULT_PACKAGE
428 AS_IF([test "$VENDOR" = "arch"], [SPL_AC_PACMAN])
431 AC_DEFUN([SPL_AC_LICENSE], [
432 AC_MSG_CHECKING([spl license])
434 AC_MSG_RESULT([$LICENSE])
435 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
439 AC_DEFUN([SPL_AC_CONFIG], [
441 AC_ARG_WITH([config],
442 AS_HELP_STRING([--with-config=CONFIG],
443 [Config file 'kernel|user|all|srpm']),
444 [SPL_CONFIG="$withval"])
446 AC_MSG_CHECKING([spl config])
447 AC_MSG_RESULT([$SPL_CONFIG]);
450 case "$SPL_CONFIG" in
451 kernel) SPL_AC_CONFIG_KERNEL ;;
452 user) SPL_AC_CONFIG_USER ;;
453 all) SPL_AC_CONFIG_KERNEL
454 SPL_AC_CONFIG_USER ;;
457 AC_MSG_RESULT([Error!])
458 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
459 user kernel|user|all|srpm]) ;;
462 AM_CONDITIONAL([CONFIG_USER],
463 [test "$SPL_CONFIG" = user] ||
464 [test "$SPL_CONFIG" = all])
465 AM_CONDITIONAL([CONFIG_KERNEL],
466 [test "$SPL_CONFIG" = kernel] ||
467 [test "$SPL_CONFIG" = all])
471 dnl # Enable if the SPL should be compiled with internal debugging enabled.
472 dnl # By default this support is disabled.
474 AC_DEFUN([SPL_AC_DEBUG], [
475 AC_MSG_CHECKING([whether debugging is enabled])
476 AC_ARG_ENABLE([debug],
477 [AS_HELP_STRING([--enable-debug],
478 [Enable generic debug support @<:@default=no@:>@])],
482 AS_IF([test "x$enable_debug" = xyes],
484 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
485 DEBUG_CFLAGS="-DDEBUG -Werror"
486 DEBUG_SPL="_with_debug"
488 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
489 DEBUG_CFLAGS="-DNDEBUG"
490 DEBUG_SPL="_without_debug"
493 AC_SUBST(DEBUG_CFLAGS)
495 AC_MSG_RESULT([$enable_debug])
499 dnl # Enabled by default it provides a basic debug log infrastructure.
500 dnl # Each subsystem registers itself with a name and logs messages
501 dnl # using predefined types. If the debug mask it set to allow the
502 dnl # message type it will be written to the internal log. The log
503 dnl # can be dumped to a file by echoing 1 to the 'dump' proc entry,
504 dnl # after dumping the log it must be decoded using the spl utility.
506 dnl # echo 1 >/proc/sys/kernel/spl/debug/dump
507 dnl # spl /tmp/spl-log.xxx.yyy /tmp/spl-log.xxx.yyy.txt
509 AC_DEFUN([SPL_AC_DEBUG_LOG], [
510 AC_ARG_ENABLE([debug-log],
511 [AS_HELP_STRING([--enable-debug-log],
512 [Enable basic debug logging @<:@default=yes@:>@])],
514 [enable_debug_log=yes])
516 AS_IF([test "x$enable_debug_log" = xyes],
518 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG"
519 DEBUG_LOG="_with_debug_log"
520 AC_DEFINE([DEBUG_LOG], [1],
521 [Define to 1 to enable basic debug logging])
523 DEBUG_LOG="_without_debug_log"
527 AC_MSG_CHECKING([whether basic debug logging is enabled])
528 AC_MSG_RESULT([$enable_debug_log])
532 dnl # Enabled by default it provides a minimal level of memory tracking.
533 dnl # A total count of bytes allocated is kept for each alloc and free.
534 dnl # Then at module unload time a report to the console will be printed
535 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
536 dnl # and provide an easy way to inspect the kmem based slab.
538 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
539 AC_ARG_ENABLE([debug-kmem],
540 [AS_HELP_STRING([--enable-debug-kmem],
541 [Enable basic kmem accounting @<:@default=yes@:>@])],
543 [enable_debug_kmem=yes])
545 AS_IF([test "x$enable_debug_kmem" = xyes],
547 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
548 DEBUG_KMEM="_with_debug_kmem"
549 AC_DEFINE([DEBUG_KMEM], [1],
550 [Define to 1 to enable basic kmem accounting])
552 DEBUG_KMEM="_without_debug_kmem"
556 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
557 AC_MSG_RESULT([$enable_debug_kmem])
561 dnl # Disabled by default it provides detailed memory tracking. This
562 dnl # feature also requires --enable-debug-kmem to be set. When enabled
563 dnl # not only will total bytes be tracked but also the location of every
564 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
565 dnl # addresses and where they were allocated will be dumped to the console.
566 dnl # Enabling this feature has a significant impact on performance but it
567 dnl # makes finding memory leaks pretty straight forward.
569 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
570 AC_ARG_ENABLE([debug-kmem-tracking],
571 [AS_HELP_STRING([--enable-debug-kmem-tracking],
572 [Enable detailed kmem tracking @<:@default=no@:>@])],
574 [enable_debug_kmem_tracking=no])
576 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
578 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
579 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
580 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
581 [Define to 1 to enable detailed kmem tracking])
583 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
586 AC_SUBST(DEBUG_KMEM_TRACKING)
587 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
588 AC_MSG_RESULT([$enable_debug_kmem_tracking])
592 dnl # SPL_LINUX_CONFTEST
594 AC_DEFUN([SPL_LINUX_CONFTEST], [
595 cat confdefs.h - <<_ACEOF >conftest.c
601 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
603 m4_define([SPL_LANG_PROGRAM], [
608 dnl Do *not* indent the following line: there may be CPP directives.
609 dnl Don't move the `;' right after for the same reason.
617 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
619 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
620 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
621 rm -Rf build && mkdir -p build
622 echo "obj-m := conftest.o" >build/Makefile
624 [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])],
626 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
632 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
634 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
635 [SPL_LINUX_COMPILE_IFELSE(
636 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
638 [test -s build/conftest.o],
643 dnl # SPL_LINUX_CONFIG
645 AC_DEFUN([SPL_LINUX_CONFIG],
646 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
647 SPL_LINUX_TRY_COMPILE([
648 #include <linux/module.h>
651 #error CONFIG_$1 not #defined
663 dnl # SPL_CHECK_SYMBOL_EXPORT
664 dnl # check symbol exported or not
666 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
667 [AC_MSG_CHECKING([whether symbol $1 is exported])
668 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
669 $LINUX_OBJ/Module*.symvers 2>/dev/null
671 if test $rc -ne 0; then
674 grep -q -E "EXPORT_SYMBOL.*($1)" \
675 "$LINUX_OBJ/$file" 2>/dev/null
677 if test $rc -eq 0; then
682 if test $export -eq 0; then
696 dnl # SPL_CHECK_SYMBOL_HEADER
697 dnl # check if a symbol prototype is defined in listed headers.
699 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
700 AC_MSG_CHECKING([whether symbol $1 exists in header])
703 grep -q "$2" "$LINUX/$file" 2>/dev/null
705 if test $rc -eq 0; then
710 if test $header -eq 0; then
720 dnl # SPL_CHECK_HEADER
721 dnl # check whether header exists and define HAVE_$2_HEADER
723 AC_DEFUN([SPL_CHECK_HEADER],
724 [AC_MSG_CHECKING([whether header $1 exists])
725 SPL_LINUX_TRY_COMPILE([
730 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
740 dnl # Use the atomic implemenation based on global spinlocks. This
741 dnl # should only be needed by 32-bit kernels which do not provide
742 dnl # the atomic64_* API. It may be optionally enabled as a fallback
743 dnl # if problems are observed with the direct mapping to the native
744 dnl # Linux atomic operations. You may not disable atomic spinlocks
745 dnl # if you kernel does not an atomic64_* API.
747 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
748 AC_ARG_ENABLE([atomic-spinlocks],
749 [AS_HELP_STRING([--enable-atomic-spinlocks],
750 [Atomic types use spinlocks @<:@default=check@:>@])],
752 [enable_atomic_spinlocks=check])
754 SPL_LINUX_TRY_COMPILE([
755 #include <asm/atomic.h>
757 atomic64_t *ptr __attribute__ ((unused));
760 AC_DEFINE(HAVE_ATOMIC64_T, 1,
761 [kernel defines atomic64_t])
766 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
767 AS_IF([test "x$have_atomic64_t" = xyes], [
768 enable_atomic_spinlocks=no
770 enable_atomic_spinlocks=yes
774 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
775 AC_DEFINE([ATOMIC_SPINLOCK], [1],
776 [Atomic types use spinlocks])
778 AS_IF([test "x$have_atomic64_t" = xno], [
780 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
784 AC_MSG_CHECKING([whether atomic types use spinlocks])
785 AC_MSG_RESULT([$enable_atomic_spinlocks])
787 AC_MSG_CHECKING([whether kernel defines atomic64_t])
788 AC_MSG_RESULT([$have_atomic64_t])
792 dnl # 2.6.24 API change,
793 dnl # check if atomic64_cmpxchg is defined
795 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
796 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
797 SPL_LINUX_TRY_COMPILE([
798 #include <asm/atomic.h>
799 #include <asm/system.h>
801 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
804 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
805 [kernel defines atomic64_cmpxchg])
812 dnl # 2.6.24 API change,
813 dnl # check if atomic64_xchg is defined
815 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
816 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
817 SPL_LINUX_TRY_COMPILE([
818 #include <asm/atomic.h>
820 atomic64_xchg((atomic64_t *)NULL, 0);
823 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
824 [kernel defines atomic64_xchg])
831 dnl # 2.6.24 API change,
832 dnl # check if uintptr_t typedef is defined
834 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
835 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
836 SPL_LINUX_TRY_COMPILE([
837 #include <linux/types.h>
839 uintptr_t *ptr __attribute__ ((unused));
842 AC_DEFINE(HAVE_UINTPTR_T, 1,
843 [kernel defines uintptr_t])
850 dnl # 2.6.20 API change,
851 dnl # INIT_WORK use 2 args and not store data inside
853 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
854 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
855 SPL_LINUX_TRY_COMPILE([
856 #include <linux/workqueue.h>
858 struct work_struct work __attribute__ ((unused));
859 INIT_WORK(&work, NULL, NULL);
862 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
863 [INIT_WORK wants 3 args])
870 dnl # 2.6.21 API change,
871 dnl # 'register_sysctl_table' use only one argument instead of two
873 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
874 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
875 SPL_LINUX_TRY_COMPILE([
876 #include <linux/sysctl.h>
878 (void) register_sysctl_table(NULL, 0);
881 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
882 [register_sysctl_table() wants 2 args])
889 dnl # 2.6.23 API change
890 dnl # Old set_shrinker API replaced with register_shrinker
892 AC_DEFUN([SPL_AC_SET_SHRINKER], [
893 AC_MSG_CHECKING([whether set_shrinker() available])
894 SPL_LINUX_TRY_COMPILE([
895 #include <linux/mm.h>
897 return set_shrinker(DEFAULT_SEEKS, NULL);
900 AC_DEFINE(HAVE_SET_SHRINKER, 1,
901 [set_shrinker() available])
908 dnl # 2.6.35 API change,
909 dnl # Add context to shrinker callback
911 AC_DEFUN([SPL_AC_3ARGS_SHRINKER_CALLBACK],
912 [AC_MSG_CHECKING([whether shrinker callback wants 3 args])
913 tmp_flags="$EXTRA_KCFLAGS"
914 EXTRA_KCFLAGS="-Werror"
915 SPL_LINUX_TRY_COMPILE([
916 #include <linux/mm.h>
918 int shrinker_cb(struct shrinker *, int, unsigned int);
920 struct shrinker cache_shrinker = {
921 .shrink = shrinker_cb,
922 .seeks = DEFAULT_SEEKS,
924 register_shrinker(&cache_shrinker);
927 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
928 [shrinker callback wants 3 args])
932 EXTRA_KCFLAGS="$tmp_flags"
936 dnl # 2.6.25 API change,
937 dnl # struct path entry added to struct nameidata
939 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
940 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
941 SPL_LINUX_TRY_COMPILE([
942 #include <linux/namei.h>
944 struct nameidata nd __attribute__ ((unused));
947 nd.path.dentry = NULL;
950 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
951 [struct path used in struct nameidata])
958 dnl # Custom SPL patch may export this system it is not required
960 AC_DEFUN([SPL_AC_TASK_CURR], [
961 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
962 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
967 dnl # 2.6.19 API change,
968 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
970 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
971 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
972 SPL_LINUX_TRY_COMPILE([
973 #include <linux/sysctl.h>
975 #ifndef CTL_UNNUMBERED
976 #error CTL_UNNUMBERED undefined
980 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
981 [unnumbered sysctl support exists])
988 dnl # 2.6.33 API change,
989 dnl # Removed .ctl_name from struct ctl_table.
991 AC_DEFUN([SPL_AC_CTL_NAME], [
992 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
993 SPL_LINUX_TRY_COMPILE([
994 #include <linux/sysctl.h>
996 struct ctl_table ctl __attribute__ ((unused));
1000 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
1007 dnl # 2.6.16 API change.
1008 dnl # Check if 'fls64()' is available
1010 AC_DEFUN([SPL_AC_FLS64],
1011 [AC_MSG_CHECKING([whether fls64() is available])
1012 SPL_LINUX_TRY_COMPILE([
1013 #include <linux/bitops.h>
1018 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
1025 dnl # 2.6.18 API change, check whether device_create() is available.
1026 dnl # Device_create() was introduced in 2.6.18 and depricated
1027 dnl # class_device_create() which was fully removed in 2.6.26.
1029 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
1030 SPL_CHECK_SYMBOL_EXPORT(
1032 [drivers/base/core.c],
1033 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
1034 [device_create() is available])],
1039 dnl # 2.6.27 API change,
1040 dnl # device_create() uses 5 args, new 'drvdata' argument.
1042 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
1043 AC_MSG_CHECKING([whether device_create() wants 5 args])
1044 tmp_flags="$EXTRA_KCFLAGS"
1045 EXTRA_KCFLAGS="-Werror"
1046 SPL_LINUX_TRY_COMPILE([
1047 #include <linux/device.h>
1049 device_create(NULL, NULL, 0, NULL, "%d", 1);
1052 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
1053 [device_create wants 5 args])
1057 EXTRA_KCFLAGS="$tmp_flags"
1061 dnl # 2.6.13 API change, check whether class_device_create() is available.
1062 dnl # Class_device_create() was introduced in 2.6.13 and depricated
1063 dnl # class_simple_device_add() which was fully removed in 2.6.13.
1065 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
1066 SPL_CHECK_SYMBOL_EXPORT(
1067 [class_device_create],
1068 [drivers/base/class.c],
1069 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
1070 [class_device_create() is available])],
1075 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
1077 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
1078 SPL_CHECK_SYMBOL_EXPORT(
1079 [set_normalized_timespec],
1081 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
1082 [set_normalized_timespec() is available as export])],
1087 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
1088 dnl # previously it was available in time.h as an inline.
1090 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
1091 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
1092 SPL_LINUX_TRY_COMPILE([
1093 #include <linux/time.h>
1094 void set_normalized_timespec(struct timespec *ts,
1095 time_t sec, long nsec) { }
1102 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
1103 [set_normalized_timespec() is available as inline])
1108 dnl # 2.6.18 API change,
1109 dnl # timespec_sub() inline function available in linux/time.h
1111 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
1112 AC_MSG_CHECKING([whether timespec_sub() is available])
1113 SPL_LINUX_TRY_COMPILE([
1114 #include <linux/time.h>
1116 struct timespec a = { 0 };
1117 struct timespec b = { 0 };
1118 struct timespec c __attribute__ ((unused));
1119 c = timespec_sub(a, b);
1122 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1129 dnl # 2.6.19 API change,
1130 dnl # check if init_utsname() is available in linux/utsname.h
1132 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
1133 AC_MSG_CHECKING([whether init_utsname() is available])
1134 SPL_LINUX_TRY_COMPILE([
1135 #include <linux/utsname.h>
1137 struct new_utsname *a __attribute__ ((unused));
1141 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1148 dnl # 2.6.26 API change,
1149 dnl # definition of struct fdtable relocated to linux/fdtable.h
1151 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
1152 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
1156 dnl # 2.6.14 API change,
1157 dnl # check whether 'files_fdtable()' exists
1159 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
1160 AC_MSG_CHECKING([whether files_fdtable() is available])
1161 SPL_LINUX_TRY_COMPILE([
1162 #include <linux/sched.h>
1163 #include <linux/file.h>
1164 #ifdef HAVE_FDTABLE_HEADER
1165 #include <linux/fdtable.h>
1168 struct files_struct *files = current->files;
1169 struct fdtable *fdt __attribute__ ((unused));
1170 fdt = files_fdtable(files);
1173 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
1180 dnl # 2.6.18 API change,
1181 dnl # added linux/uaccess.h
1183 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1184 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1188 dnl # 2.6.12 API change,
1189 dnl # check whether 'kmalloc_node()' is available.
1191 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1192 AC_MSG_CHECKING([whether kmalloc_node() is available])
1193 SPL_LINUX_TRY_COMPILE([
1194 #include <linux/slab.h>
1196 void *a __attribute__ ((unused));
1197 a = kmalloc_node(1, GFP_KERNEL, 0);
1200 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1207 dnl # 2.6.9 API change,
1208 dnl # check whether 'monotonic_clock()' is available it may
1209 dnl # be available for some archs but not others.
1211 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
1212 SPL_CHECK_SYMBOL_EXPORT(
1215 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1216 [monotonic_clock() is available])],
1221 dnl # 2.6.16 API change,
1222 dnl # check whether 'struct inode' has i_mutex
1224 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1225 AC_MSG_CHECKING([whether struct inode has i_mutex])
1226 SPL_LINUX_TRY_COMPILE([
1227 #include <linux/fs.h>
1228 #include <linux/mutex.h>
1231 mutex_init(&i.i_mutex);
1234 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1241 dnl # 2.6.29 API change,
1242 dnl # Adaptive mutexs introduced.
1244 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1245 AC_MSG_CHECKING([whether struct mutex has owner])
1246 SPL_LINUX_TRY_COMPILE([
1247 #include <linux/mutex.h>
1249 struct mutex mtx __attribute__ ((unused));
1253 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1260 dnl # 2.6.39 API change,
1261 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
1262 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
1263 dnl # was defined. As of 2.6.39 this was changed to a task_struct
1264 dnl # pointer which frankly makes a lot more sense.
1266 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
1267 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
1268 tmp_flags="$EXTRA_KCFLAGS"
1269 EXTRA_KCFLAGS="-Werror"
1270 SPL_LINUX_TRY_COMPILE([
1271 #include <linux/mutex.h>
1273 struct mutex mtx __attribute__ ((unused));
1274 mtx.owner = current;
1277 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
1278 [struct mutex owner is a task_struct])
1282 EXTRA_KCFLAGS="$tmp_flags"
1286 dnl # 2.6.18 API change,
1287 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1288 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1289 dnl # if the mutex validator is disabled or otherwise unavailable.
1291 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1292 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1293 SPL_LINUX_TRY_COMPILE([
1294 #include <linux/mutex.h>
1298 mutex_lock_nested(&mutex, 0);
1301 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1302 [mutex_lock_nested() is available])
1309 dnl # 2.6.27 API change,
1310 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1312 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1313 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1314 SPL_LINUX_TRY_COMPILE([
1315 #include <linux/smp.h>
1317 on_each_cpu(NULL, NULL, 0);
1320 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1321 [on_each_cpu wants 3 args])
1328 dnl # 2.6.18 API change,
1329 dnl # kallsyms_lookup_name no longer exported
1331 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
1332 SPL_CHECK_SYMBOL_EXPORT(
1333 [kallsyms_lookup_name],
1335 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1336 [kallsyms_lookup_name() is available])],
1341 dnl # Proposed API change,
1342 dnl # This symbol is not available in stock kernels. You may build a
1343 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1344 dnl # these symbols for use. If your already rolling a custom kernel for
1345 dnl # your environment this is recommended.
1347 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
1348 SPL_CHECK_SYMBOL_EXPORT(
1351 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1352 [get_vmalloc_info() is available])],
1357 dnl # 2.6.17 API change
1358 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1359 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1360 dnl # were exported in 2.6.17 for use by modules which was consistent with
1361 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1362 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1363 dnl # were dropped entirely leaving modules no way to directly iterate over
1364 dnl # the zone list. Because we need access to the zone helpers we check
1365 dnl # if the kernel contains the old or new implementation. Then we check
1366 dnl # to see if the symbols we need for each version are available. If they
1367 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1369 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1370 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1371 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1373 if test $rc -eq 0; then
1374 AC_MSG_RESULT([yes])
1375 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1382 dnl # Proposed API change,
1383 dnl # This symbol is not available in stock kernels. You may build a
1384 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1385 dnl # these symbols for use. If your already rolling a custom kernel for
1386 dnl # your environment this is recommended.
1388 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
1389 SPL_CHECK_SYMBOL_EXPORT(
1390 [first_online_pgdat],
1392 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1393 [first_online_pgdat() is available])],
1398 dnl # Proposed API change,
1399 dnl # This symbol is not available in stock kernels. You may build a
1400 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1401 dnl # these symbols for use. If your already rolling a custom kernel for
1402 dnl # your environment this is recommended.
1404 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
1405 SPL_CHECK_SYMBOL_EXPORT(
1406 [next_online_pgdat],
1408 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1409 [next_online_pgdat() is available])],
1414 dnl # Proposed API change,
1415 dnl # This symbol is not available in stock kernels. You may build a
1416 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1417 dnl # these symbols for use. If your already rolling a custom kernel for
1418 dnl # your environment this is recommended.
1420 AC_DEFUN([SPL_AC_NEXT_ZONE], [
1421 SPL_CHECK_SYMBOL_EXPORT(
1424 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1425 [next_zone() is available])],
1430 dnl # 2.6.17 API change,
1431 dnl # See SPL_AC_PGDAT_HELPERS for details.
1433 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1434 SPL_CHECK_SYMBOL_EXPORT(
1437 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1438 [pgdat_list is available])],
1443 dnl # 2.6.18 API change,
1444 dnl # First introduced global_page_state() support as an inline.
1446 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1447 AC_MSG_CHECKING([whether global_page_state() is available])
1448 SPL_LINUX_TRY_COMPILE([
1449 #include <linux/mm.h>
1451 unsigned long state __attribute__ ((unused));
1452 state = global_page_state(0);
1455 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1456 [global_page_state() is available])
1463 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1464 dnl # Public global zone stats now include a free page count. However
1465 dnl # the enumerated names of the counters have changed since this API
1466 dnl # was introduced. We need to deduce the corrent name to use. This
1467 dnl # replaces the priviate get_zone_counts() interface.
1469 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1470 dnl # is 2.6.30 as of when this was written.
1472 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1473 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1474 SPL_LINUX_TRY_COMPILE([
1475 #include <linux/mm.h>
1477 enum zone_stat_item zsi __attribute__ ((unused));
1478 zsi = NR_FREE_PAGES;
1481 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1482 [Page state NR_FREE_PAGES is available])
1489 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1490 dnl # Public global zone stats now include an inactive page count. However
1491 dnl # the enumerated names of the counters have changed since this API
1492 dnl # was introduced. We need to deduce the corrent name to use. This
1493 dnl # replaces the priviate get_zone_counts() interface.
1495 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1496 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1497 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1499 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1500 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1501 SPL_LINUX_TRY_COMPILE([
1502 #include <linux/mm.h>
1504 enum zone_stat_item zsi __attribute__ ((unused));
1508 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1509 [Page state NR_INACTIVE is available])
1514 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1515 SPL_LINUX_TRY_COMPILE([
1516 #include <linux/mm.h>
1518 enum zone_stat_item zsi __attribute__ ((unused));
1519 zsi = NR_INACTIVE_ANON;
1522 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1523 [Page state NR_INACTIVE_ANON is available])
1528 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1529 SPL_LINUX_TRY_COMPILE([
1530 #include <linux/mm.h>
1532 enum zone_stat_item zsi __attribute__ ((unused));
1533 zsi = NR_INACTIVE_FILE;
1536 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1537 [Page state NR_INACTIVE_FILE is available])
1544 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1545 dnl # Public global zone stats now include an active page count. However
1546 dnl # the enumerated names of the counters have changed since this API
1547 dnl # was introduced. We need to deduce the corrent name to use. This
1548 dnl # replaces the priviate get_zone_counts() interface.
1550 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1551 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1552 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1554 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1555 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1556 SPL_LINUX_TRY_COMPILE([
1557 #include <linux/mm.h>
1559 enum zone_stat_item zsi __attribute__ ((unused));
1563 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1564 [Page state NR_ACTIVE is available])
1569 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1570 SPL_LINUX_TRY_COMPILE([
1571 #include <linux/mm.h>
1573 enum zone_stat_item zsi __attribute__ ((unused));
1574 zsi = NR_ACTIVE_ANON;
1577 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1578 [Page state NR_ACTIVE_ANON is available])
1583 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1584 SPL_LINUX_TRY_COMPILE([
1585 #include <linux/mm.h>
1587 enum zone_stat_item zsi __attribute__ ((unused));
1588 zsi = NR_ACTIVE_FILE;
1591 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1592 [Page state NR_ACTIVE_FILE is available])
1599 dnl # Proposed API change for legacy kernels.
1600 dnl # This symbol is not available in older kernels. For kernels post
1601 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1602 dnl # page state information. This symbol is only used in legacy kernels
1603 dnl # any only as a last resort.
1605 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1606 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1607 SPL_LINUX_TRY_COMPILE([
1609 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1610 #error "global_page_state needs NR_FREE_PAGES"
1613 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1614 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1615 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1616 #error "global_page_state needs NR_ACTIVE*"
1619 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1620 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1621 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1622 #error "global_page_state needs NR_INACTIVE*"
1628 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1629 [get_zone_counts() is needed])
1631 SPL_CHECK_SYMBOL_EXPORT(
1634 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1635 [get_zone_counts() is available])],
1641 dnl # 2.6.27 API change,
1642 dnl # The user_path_dir() replaces __user_walk()
1644 AC_DEFUN([SPL_AC_USER_PATH_DIR], [
1645 SPL_CHECK_SYMBOL_EXPORT(
1648 [AC_DEFINE(HAVE_USER_PATH_DIR, 1,
1649 [user_path_dir() is available])],
1654 dnl # Symbol available in RHEL kernels not in stock kernels.
1656 AC_DEFUN([SPL_AC_SET_FS_PWD], [
1657 SPL_CHECK_SYMBOL_EXPORT(
1660 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1661 [set_fs_pwd() is available])],
1666 dnl # 2.6.25 API change,
1667 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1669 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1670 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1671 SPL_LINUX_TRY_COMPILE([
1672 #include <linux/sched.h>
1673 #include <linux/fs_struct.h>
1675 set_fs_pwd(NULL, NULL);
1678 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1679 [set_fs_pwd() wants 2 args])
1686 dnl # SLES API change, never adopted in mainline,
1687 dnl # Third 'struct vfsmount *' argument removed.
1689 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1690 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1691 SPL_LINUX_TRY_COMPILE([
1692 #include <linux/fs.h>
1694 vfs_unlink(NULL, NULL);
1697 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1698 [vfs_unlink() wants 2 args])
1705 dnl # SLES API change, never adopted in mainline,
1706 dnl # Third and sixth 'struct vfsmount *' argument removed.
1708 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1709 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1710 SPL_LINUX_TRY_COMPILE([
1711 #include <linux/fs.h>
1713 vfs_rename(NULL, NULL, NULL, NULL);
1716 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1717 [vfs_rename() wants 4 args])
1724 dnl # 2.6.36 API change,
1725 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1726 dnl # a spinlock_t to improve the fastpath performance.
1728 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1729 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1730 tmp_flags="$EXTRA_KCFLAGS"
1731 EXTRA_KCFLAGS="-Werror"
1732 SPL_LINUX_TRY_COMPILE([
1733 #include <linux/sched.h>
1734 #include <linux/fs_struct.h>
1736 struct fs_struct fs;
1737 spin_lock_init(&fs.lock);
1740 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1741 [struct fs_struct uses spinlock_t])
1745 EXTRA_KCFLAGS="$tmp_flags"
1749 dnl # 2.6.29 API change,
1750 dnl # check whether 'struct cred' exists
1752 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1753 AC_MSG_CHECKING([whether struct cred exists])
1754 SPL_LINUX_TRY_COMPILE([
1755 #include <linux/cred.h>
1757 struct cred *cr __attribute__ ((unused));
1761 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1768 dnl # Custom SPL patch may export this symbol.
1770 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1771 SPL_CHECK_SYMBOL_EXPORT(
1774 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1775 [groups_search() is available])],
1780 dnl # 2.6.x API change,
1781 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1783 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1784 SPL_CHECK_SYMBOL_EXPORT(
1785 [__put_task_struct],
1787 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1788 [__put_task_struct() is available])],
1793 dnl # 2.6.32 API change,
1794 dnl # Unused 'struct file *' removed from prototype.
1796 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1797 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1798 SPL_LINUX_TRY_COMPILE([
1799 #include <linux/sysctl.h>
1801 proc_dostring(NULL, 0, NULL, NULL, NULL);
1804 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1805 [proc_handler() wants 5 args])
1812 dnl # 2.6.x API change,
1813 dnl # kvasprintf() function added.
1815 AC_DEFUN([SPL_AC_KVASPRINTF], [
1816 SPL_CHECK_SYMBOL_EXPORT(
1819 [AC_DEFINE(HAVE_KVASPRINTF, 1,
1820 [kvasprintf() is available])],
1825 dnl # 2.6.29 API change,
1826 dnl # vfs_fsync() funcation added, prior to this use file_fsync().
1828 AC_DEFUN([SPL_AC_VFS_FSYNC], [
1829 SPL_CHECK_SYMBOL_EXPORT(
1832 [AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])],
1837 dnl # 2.6.35 API change,
1838 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
1840 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
1841 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
1842 SPL_LINUX_TRY_COMPILE([
1843 #include <linux/fs.h>
1848 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
1855 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
1856 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
1857 dnl # condition. The fixed version is exported as a symbol. The race
1858 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
1859 dnl # call that version while holding sem->wait_lock.
1861 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED], [
1862 SPL_CHECK_SYMBOL_EXPORT(
1864 [lib/rwsem-spinlock.c],
1865 [AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
1866 [rwsem_is_locked() acquires sem->wait_lock])],
1871 dnl # 2.6.37 API compat,
1872 dnl # The function invalidate_inodes() is no longer exported by the kernel.
1873 dnl # The prototype however is still available which means it is safe
1874 dnl # to acquire the symbol's address using spl_kallsyms_lookup_name().
1876 dnl # The Proxmox VE kernel contains a patch which renames the function
1877 dnl # invalidate_inodes() to invalidate_inodes_check(). In the process
1878 dnl # it adds a 'check' argument and a '#define invalidate_inodes(x)'
1879 dnl # compatibility wrapper for legacy callers. Therefore, if either
1880 dnl # of these functions are exported invalidate_inodes() can be
1883 AC_DEFUN([SPL_AC_KERNEL_INVALIDATE_INODES], [
1884 SPL_CHECK_SYMBOL_EXPORT(
1885 [invalidate_inodes],
1887 [AC_DEFINE(HAVE_INVALIDATE_INODES, 1,
1888 [invalidate_inodes() is available])],
1890 SPL_CHECK_SYMBOL_EXPORT(
1891 [invalidate_inodes_check],
1893 [AC_DEFINE(HAVE_INVALIDATE_INODES_CHECK, 1,
1894 [invalidate_inodes_check() is available])],
1899 dnl # 2.6.39 API compat,
1900 dnl # The function invalidate_inodes() now take 2 arguments. The second
1901 dnl # 'kill_dirty' argument describes how invalidate_inodes() should
1902 dnl # handle dirty inodes. Only when set will dirty inodes be discarded,
1903 dnl # otherwise they will be handled as busy.
1905 dnl # Unfortunately, we don't have access to the invalidate_inodes()
1906 dnl # prototype so it's not easy to check how many arguments it takes.
1907 dnl # However, this change was done for the benefit of invalidate_device()
1908 dnl # which also added an argument. The invalidate_device() symbol does
1909 dnl # exist in the development headers so if it takes two arguments we
1910 dnl # can fairly safely infer that invalidate_inodes() takes two arguments
1911 dnl # as well. See commit 93b270f76e7ef3b81001576860c2701931cdc78b.
1913 AC_DEFUN([SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES],
1914 [AC_MSG_CHECKING([whether invalidate_inodes() wants 2 args])
1915 SPL_LINUX_TRY_COMPILE([
1916 #include <linux/fs.h>
1918 return __invalidate_device(NULL, 0);
1921 AC_DEFINE(HAVE_2ARGS_INVALIDATE_INODES, 1,
1922 [invalidate_inodes() wants 2 args])
1929 dnl # 2.6.xx API compat,
1930 dnl # There currently exists no exposed API to partially shrink the dcache.
1931 dnl # The expected mechanism to shrink the cache is a registered shrinker
1932 dnl # which is called during memory pressure.
1934 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY], [
1935 SPL_CHECK_SYMBOL_EXPORT(
1936 [shrink_dcache_memory],
1938 [AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
1939 [shrink_dcache_memory() is available])],
1944 dnl # 2.6.xx API compat,
1945 dnl # There currently exists no exposed API to partially shrink the icache.
1946 dnl # The expected mechanism to shrink the cache is a registered shrinker
1947 dnl # which is called during memory pressure.
1949 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY], [
1950 SPL_CHECK_SYMBOL_EXPORT(
1951 [shrink_icache_memory],
1953 [AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
1954 [shrink_icache_memory() is available])],
1959 dnl # 2.6.39 API compat,
1960 dnl # The path_lookup() function has been renamed to kern_path_parent()
1961 dnl # and the flags argument has been removed. The only behavior now
1962 dnl # offered is that of LOOKUP_PARENT. The spl already always passed
1963 dnl # this flag so dropping the flag does not impact us.
1965 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_HEADER], [
1966 SPL_CHECK_SYMBOL_HEADER(
1968 [int kern_path_parent(const char \*, struct nameidata \*)],
1969 [include/linux/namei.h],
1970 [AC_DEFINE(HAVE_KERN_PATH_PARENT_HEADER, 1,
1971 [kern_path_parent() is available])],
1976 dnl # 3.1 API compat,
1977 dnl # The kern_path_parent() symbol is no longer exported by the kernel.
1978 dnl # However, it remains the prefered interface and since we still have
1979 dnl # access to the prototype we dynamically lookup the required address.
1981 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_SYMBOL], [
1982 SPL_CHECK_SYMBOL_EXPORT(
1985 [AC_DEFINE(HAVE_KERN_PATH_PARENT_SYMBOL, 1,
1986 [kern_path_parent() is available])],
1991 dnl # 2.6.39 API compat,
1992 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
1993 dnl # This was done to avoid always having to allocate the maximum size
1994 dnl # workspace (268K). The caller can now specific the windowBits and
1995 dnl # memLevel compression parameters to get a smaller workspace.
1997 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
1998 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
1999 SPL_LINUX_TRY_COMPILE([
2000 #include <linux/zlib.h>
2002 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
2005 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
2006 [zlib_deflate_workspacesize() wants 2 args])
2013 dnl # 2.6.39 API change,
2014 dnl # Shrinker adjust to use common shrink_control structure.
2016 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
2017 AC_MSG_CHECKING([whether struct shrink_control exists])
2018 SPL_LINUX_TRY_COMPILE([
2019 #include <linux/mm.h>
2021 struct shrink_control sc __attribute__ ((unused));
2024 sc.gfp_mask = GFP_KERNEL;
2027 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
2028 [struct shrink_control exists])
2035 dnl # 3.1 API Change
2037 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
2038 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
2040 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
2041 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
2042 tmp_flags="$EXTRA_KCFLAGS"
2043 EXTRA_KCFLAGS="-Werror"
2044 SPL_LINUX_TRY_COMPILE([
2045 #include <linux/rwsem.h>
2047 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
2048 raw_spinlock_t dummy_lock __attribute__ ((unused));
2049 dummy_semaphore.wait_lock = dummy_lock;
2052 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
2053 [struct rw_semaphore member wait_lock is raw_spinlock_t])
2057 EXTRA_KCFLAGS="$tmp_flags"