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)
23 SPL_AC_DEBUG_KMEM_TRACKING
24 SPL_AC_ATOMIC_SPINLOCK
25 SPL_AC_TYPE_ATOMIC64_CMPXCHG
26 SPL_AC_TYPE_ATOMIC64_XCHG
28 SPL_AC_3ARGS_INIT_WORK
29 SPL_AC_2ARGS_REGISTER_SYSCTL
31 SPL_AC_3ARGS_SHRINKER_CALLBACK
32 SPL_AC_PATH_IN_NAMEIDATA
38 SPL_AC_5ARGS_DEVICE_CREATE
39 SPL_AC_CLASS_DEVICE_CREATE
40 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
41 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
48 SPL_AC_MONOTONIC_CLOCK
51 SPL_AC_MUTEX_OWNER_TASK_STRUCT
52 SPL_AC_MUTEX_LOCK_NESTED
53 SPL_AC_3ARGS_ON_EACH_CPU
54 SPL_AC_KALLSYMS_LOOKUP_NAME
55 SPL_AC_GET_VMALLOC_INFO
57 SPL_AC_FIRST_ONLINE_PGDAT
58 SPL_AC_NEXT_ONLINE_PGDAT
61 SPL_AC_GLOBAL_PAGE_STATE
62 SPL_AC_ZONE_STAT_ITEM_FREE
63 SPL_AC_ZONE_STAT_ITEM_INACTIVE
64 SPL_AC_ZONE_STAT_ITEM_ACTIVE
65 SPL_AC_GET_ZONE_COUNTS
68 SPL_AC_2ARGS_SET_FS_PWD
69 SPL_AC_2ARGS_VFS_UNLINK
70 SPL_AC_4ARGS_VFS_RENAME
72 SPL_AC_2ARGS_VFS_FSYNC
73 SPL_AC_FS_STRUCT_SPINLOCK
76 SPL_AC_PUT_TASK_STRUCT
77 SPL_AC_5ARGS_PROC_HANDLER
79 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
80 SPL_AC_KERNEL_INVALIDATE_INODES
81 SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES
82 SPL_AC_SHRINK_DCACHE_MEMORY
83 SPL_AC_SHRINK_ICACHE_MEMORY
84 SPL_AC_KERN_PATH_PARENT_HEADER
85 SPL_AC_KERN_PATH_PARENT_SYMBOL
86 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
87 SPL_AC_SHRINK_CONTROL_STRUCT
90 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
91 modpost=$LINUX/scripts/Makefile.modpost
92 AC_MSG_CHECKING([kernel file name for module symbols])
93 if test -f "$modpost"; then
94 if grep -q Modules.symvers $modpost; then
95 LINUX_SYMBOLS=Modules.symvers
97 LINUX_SYMBOLS=Module.symvers
100 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
102 *** Please make sure the kernel devel package for your distribution
103 *** is installed. If your building with a custom kernel make sure the
104 *** kernel is configured, built, and the '--with-linux=PATH' configure
105 *** option refers to the location of the kernel source.])
110 AC_MSG_RESULT($LINUX_SYMBOLS)
111 AC_SUBST(LINUX_SYMBOLS)
114 AC_DEFUN([SPL_AC_KERNEL], [
116 AS_HELP_STRING([--with-linux=PATH],
117 [Path to kernel source]),
118 [kernelsrc="$withval"])
120 AC_ARG_WITH([linux-obj],
121 AS_HELP_STRING([--with-linux-obj=PATH],
122 [Path to kernel build objects]),
123 [kernelbuild="$withval"])
125 AC_MSG_CHECKING([kernel source directory])
126 if test -z "$kernelsrc"; then
127 if test -e "/lib/modules/$(uname -r)/source"; then
128 headersdir="/lib/modules/$(uname -r)/source"
129 sourcelink=$(readlink -f "$headersdir")
130 elif test -e "/lib/modules/$(uname -r)/build"; then
131 headersdir="/lib/modules/$(uname -r)/build"
132 sourcelink=$(readlink -f "$headersdir")
134 sourcelink=$(ls -1d /usr/src/kernels/* \
136 2>/dev/null | grep -v obj | tail -1)
139 if test -n "$sourcelink" && test -e ${sourcelink}; then
140 kernelsrc=`readlink -f ${sourcelink}`
142 AC_MSG_RESULT([Not found])
144 *** Please make sure the kernel devel package for your distribution
145 *** is installed then try again. If that fails you can specify the
146 *** location of the kernel source with the '--with-linux=PATH' option.])
149 if test "$kernelsrc" = "NONE"; then
154 AC_MSG_RESULT([$kernelsrc])
155 AC_MSG_CHECKING([kernel build directory])
156 if test -z "$kernelbuild"; then
157 if test -e "/lib/modules/$(uname -r)/build"; then
158 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
159 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
160 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
161 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
162 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
163 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
164 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
166 kernelbuild=${kernelsrc}
169 AC_MSG_RESULT([$kernelbuild])
171 AC_MSG_CHECKING([kernel source version])
172 utsrelease1=$kernelbuild/include/linux/version.h
173 utsrelease2=$kernelbuild/include/linux/utsrelease.h
174 utsrelease3=$kernelbuild/include/generated/utsrelease.h
175 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
176 utsrelease=linux/version.h
177 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
178 utsrelease=linux/utsrelease.h
179 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
180 utsrelease=generated/utsrelease.h
183 if test "$utsrelease"; then
184 kernsrcver=`(echo "#include <$utsrelease>";
185 echo "kernsrcver=UTS_RELEASE") |
186 cpp -I $kernelbuild/include |
187 grep "^kernsrcver=" | cut -d \" -f 2`
189 if test -z "$kernsrcver"; then
190 AC_MSG_RESULT([Not found])
191 AC_MSG_ERROR([*** Cannot determine kernel version.])
194 AC_MSG_RESULT([Not found])
195 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
198 AC_MSG_RESULT([$kernsrcver])
201 LINUX_OBJ=${kernelbuild}
202 LINUX_VERSION=${kernsrcver}
206 AC_SUBST(LINUX_VERSION)
208 SPL_AC_MODULE_SYMVERS
211 AC_DEFUN([SPL_AC_KERNEL_CONFIG], [
212 SPL_LINUX_CONFIG([PREEMPT],
214 *** Kernel built with CONFIG_PREEMPT which is not supported.
215 ** You must rebuild your kernel without this option.]), [])
219 dnl # Default SPL user configuration
221 AC_DEFUN([SPL_AC_CONFIG_USER], [])
224 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
225 dnl # are missing it is non-fatal but you will not be able to build
226 dnl # RPM packages and will be warned if you try too.
228 AC_DEFUN([SPL_AC_RPM], [
232 AC_MSG_CHECKING([whether $RPM is available])
233 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
234 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
236 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
239 AC_MSG_RESULT([$HAVE_RPM])
242 AC_MSG_CHECKING([whether $RPMBUILD is available])
243 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
244 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
246 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
249 AC_MSG_RESULT([$HAVE_RPMBUILD])
254 AC_SUBST(RPM_VERSION)
256 AC_SUBST(HAVE_RPMBUILD)
258 AC_SUBST(RPMBUILD_VERSION)
262 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
263 dnl # tools are missing it is non-fatal but you will not be able to build
264 dnl # DEB packages and will be warned if you try too.
266 AC_DEFUN([SPL_AC_DPKG], [
268 DPKGBUILD=dpkg-buildpackage
270 AC_MSG_CHECKING([whether $DPKG is available])
271 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
272 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
274 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
277 AC_MSG_RESULT([$HAVE_DPKG])
280 AC_MSG_CHECKING([whether $DPKGBUILD is available])
281 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
282 DPKGBUILD_VERSION=$(echo $tmp | \
283 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
285 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
288 AC_MSG_RESULT([$HAVE_DPKGBUILD])
293 AC_SUBST(DPKG_VERSION)
295 AC_SUBST(HAVE_DPKGBUILD)
297 AC_SUBST(DPKGBUILD_VERSION)
301 dnl # Check for pacman+makepkg to build Arch Linux packages. If these
302 dnl # tools are missing it is non-fatal but you will not be able to
303 dnl # build Arch Linux packages and will be warned if you try too.
305 AC_DEFUN([SPL_AC_PACMAN], [
309 AC_MSG_CHECKING([whether $PACMAN is available])
310 tmp=$($PACMAN --version 2>/dev/null)
311 AS_IF([test -n "$tmp"], [
312 PACMAN_VERSION=$(echo $tmp |
313 $AWK '/Pacman/ { print $[3] }' |
316 AC_MSG_RESULT([$HAVE_PACMAN ($PACMAN_VERSION)])
319 AC_MSG_RESULT([$HAVE_PACMAN])
322 AC_MSG_CHECKING([whether $MAKEPKG is available])
323 tmp=$($MAKEPKG --version 2>/dev/null)
324 AS_IF([test -n "$tmp"], [
325 MAKEPKG_VERSION=$(echo $tmp | $AWK '/makepkg/ { print $[3] }')
327 AC_MSG_RESULT([$HAVE_MAKEPKG ($MAKEPKG_VERSION)])
330 AC_MSG_RESULT([$HAVE_MAKEPKG])
333 AC_SUBST(HAVE_PACMAN)
335 AC_SUBST(PACMAN_VERSION)
337 AC_SUBST(HAVE_MAKEPKG)
339 AC_SUBST(MAKEPKG_VERSION)
343 dnl # Until native packaging for various different packing systems
344 dnl # can be added the least we can do is attempt to use alien to
345 dnl # convert the RPM packages to the needed package type. This is
346 dnl # a hack but so far it has worked reasonable well.
348 AC_DEFUN([SPL_AC_ALIEN], [
351 AC_MSG_CHECKING([whether $ALIEN is available])
352 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
353 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
355 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
358 AC_MSG_RESULT([$HAVE_ALIEN])
363 AC_SUBST(ALIEN_VERSION)
367 dnl # Using the VENDOR tag from config.guess set the default
368 dnl # package type for 'make pkg': (rpm | deb | tgz)
370 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
371 AC_MSG_CHECKING([linux distribution])
372 if test -f /etc/redhat-release ; then
374 elif test -f /etc/fedora-release ; then
376 elif test -f /etc/arch-release ; then
378 elif test -f /etc/lsb-release ; then
380 elif test -f /etc/debian_version ; then
382 elif test -f /etc/SuSE-release ; then
384 elif test -f /etc/slackware-version ; then
386 elif test -f /etc/gentoo-release ; then
391 AC_MSG_RESULT([$VENDOR])
394 AC_MSG_CHECKING([default package type])
396 fedora) DEFAULT_PACKAGE=rpm ;;
397 redhat) DEFAULT_PACKAGE=rpm ;;
398 sles) DEFAULT_PACKAGE=rpm ;;
399 ubuntu) DEFAULT_PACKAGE=deb ;;
400 debian) DEFAULT_PACKAGE=deb ;;
401 slackware) DEFAULT_PACKAGE=tgz ;;
402 arch) DEFAULT_PACKAGE=arch;;
403 *) DEFAULT_PACKAGE=rpm ;;
406 AC_MSG_RESULT([$DEFAULT_PACKAGE])
407 AC_SUBST(DEFAULT_PACKAGE)
411 dnl # Default SPL user configuration
413 AC_DEFUN([SPL_AC_PACKAGE], [
418 SPL_AC_DEFAULT_PACKAGE
421 AC_DEFUN([SPL_AC_LICENSE], [
422 AC_MSG_CHECKING([spl license])
424 AC_MSG_RESULT([$LICENSE])
425 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
429 AC_DEFUN([SPL_AC_CONFIG], [
431 AC_ARG_WITH([config],
432 AS_HELP_STRING([--with-config=CONFIG],
433 [Config file 'kernel|user|all|srpm']),
434 [SPL_CONFIG="$withval"])
436 AC_MSG_CHECKING([spl config])
437 AC_MSG_RESULT([$SPL_CONFIG]);
440 case "$SPL_CONFIG" in
441 kernel) SPL_AC_CONFIG_KERNEL ;;
442 user) SPL_AC_CONFIG_USER ;;
443 all) SPL_AC_CONFIG_KERNEL
444 SPL_AC_CONFIG_USER ;;
447 AC_MSG_RESULT([Error!])
448 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
449 user kernel|user|all|srpm]) ;;
452 AM_CONDITIONAL([CONFIG_USER],
453 [test "$SPL_CONFIG" = user] ||
454 [test "$SPL_CONFIG" = all])
455 AM_CONDITIONAL([CONFIG_KERNEL],
456 [test "$SPL_CONFIG" = kernel] ||
457 [test "$SPL_CONFIG" = all])
461 dnl # Enable if the SPL should be compiled with internal debugging enabled.
462 dnl # By default this support is disabled.
464 AC_DEFUN([SPL_AC_DEBUG], [
465 AC_MSG_CHECKING([whether debugging is enabled])
466 AC_ARG_ENABLE([debug],
467 [AS_HELP_STRING([--enable-debug],
468 [Enable generic debug support @<:@default=no@:>@])],
472 AS_IF([test "x$enable_debug" = xyes],
474 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
475 DEBUG_CFLAGS="-DDEBUG -Werror"
478 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
479 DEBUG_CFLAGS="-DNDEBUG"
482 AC_SUBST(DEBUG_CFLAGS)
483 AC_MSG_RESULT([$enable_debug])
487 dnl # Enabled by default it provides a minimal level of memory tracking.
488 dnl # A total count of bytes allocated is kept for each alloc and free.
489 dnl # Then at module unload time a report to the console will be printed
490 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
491 dnl # and provide an easy way to inspect the kmem based slab.
493 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
494 AC_ARG_ENABLE([debug-kmem],
495 [AS_HELP_STRING([--enable-debug-kmem],
496 [Enable basic kmem accounting @<:@default=yes@:>@])],
498 [enable_debug_kmem=yes])
500 AS_IF([test "x$enable_debug_kmem" = xyes],
501 [AC_DEFINE([DEBUG_KMEM], [1],
502 [Define to 1 to enable basic kmem accounting])
503 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"])
505 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
506 AC_MSG_RESULT([$enable_debug_kmem])
510 dnl # Disabled by default it provides detailed memory tracking. This
511 dnl # feature also requires --enable-debug-kmem to be set. When enabled
512 dnl # not only will total bytes be tracked but also the location of every
513 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
514 dnl # addresses and where they were allocated will be dumped to the console.
515 dnl # Enabling this feature has a significant impact on performance but it
516 dnl # makes finding memory leaks pretty straight forward.
518 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
519 AC_ARG_ENABLE([debug-kmem-tracking],
520 [AS_HELP_STRING([--enable-debug-kmem-tracking],
521 [Enable detailed kmem tracking @<:@default=no@:>@])],
523 [enable_debug_kmem_tracking=no])
525 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
526 [AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
527 [Define to 1 to enable detailed kmem tracking])
528 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"])
530 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
531 AC_MSG_RESULT([$enable_debug_kmem_tracking])
535 dnl # SPL_LINUX_CONFTEST
537 AC_DEFUN([SPL_LINUX_CONFTEST], [
538 cat confdefs.h - <<_ACEOF >conftest.c
544 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
546 m4_define([SPL_LANG_PROGRAM], [
551 dnl Do *not* indent the following line: there may be CPP directives.
552 dnl Don't move the `;' right after for the same reason.
560 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
562 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
563 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
564 rm -Rf build && mkdir -p build
565 echo "obj-m := conftest.o" >build/Makefile
567 [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])],
569 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
575 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
577 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
578 [SPL_LINUX_COMPILE_IFELSE(
579 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
581 [test -s build/conftest.o],
586 dnl # SPL_LINUX_CONFIG
588 AC_DEFUN([SPL_LINUX_CONFIG],
589 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
590 SPL_LINUX_TRY_COMPILE([
591 #include <linux/module.h>
594 #error CONFIG_$1 not #defined
606 dnl # SPL_CHECK_SYMBOL_EXPORT
607 dnl # check symbol exported or not
609 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
610 [AC_MSG_CHECKING([whether symbol $1 is exported])
611 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
612 $LINUX_OBJ/Module*.symvers 2>/dev/null
614 if test $rc -ne 0; then
617 grep -q -E "EXPORT_SYMBOL.*($1)" \
618 "$LINUX_OBJ/$file" 2>/dev/null
620 if test $rc -eq 0; then
625 if test $export -eq 0; then
639 dnl # SPL_CHECK_SYMBOL_HEADER
640 dnl # check if a symbol prototype is defined in listed headers.
642 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
643 AC_MSG_CHECKING([whether symbol $1 exists in header])
646 grep -q "$2" "$LINUX/$file" 2>/dev/null
648 if test $rc -eq 0; then
653 if test $header -eq 0; then
663 dnl # SPL_CHECK_HEADER
664 dnl # check whether header exists and define HAVE_$2_HEADER
666 AC_DEFUN([SPL_CHECK_HEADER],
667 [AC_MSG_CHECKING([whether header $1 exists])
668 SPL_LINUX_TRY_COMPILE([
673 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
683 dnl # Use the atomic implemenation based on global spinlocks. This
684 dnl # should only be needed by 32-bit kernels which do not provide
685 dnl # the atomic64_* API. It may be optionally enabled as a fallback
686 dnl # if problems are observed with the direct mapping to the native
687 dnl # Linux atomic operations. You may not disable atomic spinlocks
688 dnl # if you kernel does not an atomic64_* API.
690 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
691 AC_ARG_ENABLE([atomic-spinlocks],
692 [AS_HELP_STRING([--enable-atomic-spinlocks],
693 [Atomic types use spinlocks @<:@default=check@:>@])],
695 [enable_atomic_spinlocks=check])
697 SPL_LINUX_TRY_COMPILE([
698 #include <asm/atomic.h>
700 atomic64_t *ptr __attribute__ ((unused));
703 AC_DEFINE(HAVE_ATOMIC64_T, 1,
704 [kernel defines atomic64_t])
709 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
710 AS_IF([test "x$have_atomic64_t" = xyes], [
711 enable_atomic_spinlocks=no
713 enable_atomic_spinlocks=yes
717 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
718 AC_DEFINE([ATOMIC_SPINLOCK], [1],
719 [Atomic types use spinlocks])
721 AS_IF([test "x$have_atomic64_t" = xno], [
723 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
727 AC_MSG_CHECKING([whether atomic types use spinlocks])
728 AC_MSG_RESULT([$enable_atomic_spinlocks])
730 AC_MSG_CHECKING([whether kernel defines atomic64_t])
731 AC_MSG_RESULT([$have_atomic64_t])
735 dnl # 2.6.24 API change,
736 dnl # check if atomic64_cmpxchg is defined
738 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
739 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
740 SPL_LINUX_TRY_COMPILE([
741 #include <asm/atomic.h>
742 #include <asm/system.h>
744 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
747 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
748 [kernel defines atomic64_cmpxchg])
755 dnl # 2.6.24 API change,
756 dnl # check if atomic64_xchg is defined
758 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
759 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
760 SPL_LINUX_TRY_COMPILE([
761 #include <asm/atomic.h>
763 atomic64_xchg((atomic64_t *)NULL, 0);
766 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
767 [kernel defines atomic64_xchg])
774 dnl # 2.6.24 API change,
775 dnl # check if uintptr_t typedef is defined
777 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
778 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
779 SPL_LINUX_TRY_COMPILE([
780 #include <linux/types.h>
782 uintptr_t *ptr __attribute__ ((unused));
785 AC_DEFINE(HAVE_UINTPTR_T, 1,
786 [kernel defines uintptr_t])
793 dnl # 2.6.20 API change,
794 dnl # INIT_WORK use 2 args and not store data inside
796 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
797 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
798 SPL_LINUX_TRY_COMPILE([
799 #include <linux/workqueue.h>
801 struct work_struct work __attribute__ ((unused));
802 INIT_WORK(&work, NULL, NULL);
805 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
806 [INIT_WORK wants 3 args])
813 dnl # 2.6.21 API change,
814 dnl # 'register_sysctl_table' use only one argument instead of two
816 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
817 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
818 SPL_LINUX_TRY_COMPILE([
819 #include <linux/sysctl.h>
821 (void) register_sysctl_table(NULL, 0);
824 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
825 [register_sysctl_table() wants 2 args])
832 dnl # 2.6.23 API change
833 dnl # Old set_shrinker API replaced with register_shrinker
835 AC_DEFUN([SPL_AC_SET_SHRINKER], [
836 AC_MSG_CHECKING([whether set_shrinker() available])
837 SPL_LINUX_TRY_COMPILE([
838 #include <linux/mm.h>
840 return set_shrinker(DEFAULT_SEEKS, NULL);
843 AC_DEFINE(HAVE_SET_SHRINKER, 1,
844 [set_shrinker() available])
851 dnl # 2.6.35 API change,
852 dnl # Add context to shrinker callback
854 AC_DEFUN([SPL_AC_3ARGS_SHRINKER_CALLBACK],
855 [AC_MSG_CHECKING([whether shrinker callback wants 3 args])
856 tmp_flags="$EXTRA_KCFLAGS"
857 EXTRA_KCFLAGS="-Werror"
858 SPL_LINUX_TRY_COMPILE([
859 #include <linux/mm.h>
861 int shrinker_cb(struct shrinker *, int, unsigned int);
863 struct shrinker cache_shrinker = {
864 .shrink = shrinker_cb,
865 .seeks = DEFAULT_SEEKS,
867 register_shrinker(&cache_shrinker);
870 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
871 [shrinker callback wants 3 args])
875 EXTRA_KCFLAGS="$tmp_flags"
879 dnl # 2.6.25 API change,
880 dnl # struct path entry added to struct nameidata
882 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
883 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
884 SPL_LINUX_TRY_COMPILE([
885 #include <linux/namei.h>
887 struct nameidata nd __attribute__ ((unused));
890 nd.path.dentry = NULL;
893 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
894 [struct path used in struct nameidata])
901 dnl # Custom SPL patch may export this system it is not required
903 AC_DEFUN([SPL_AC_TASK_CURR], [
904 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
905 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
910 dnl # 2.6.19 API change,
911 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
913 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
914 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
915 SPL_LINUX_TRY_COMPILE([
916 #include <linux/sysctl.h>
918 #ifndef CTL_UNNUMBERED
919 #error CTL_UNNUMBERED undefined
923 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
924 [unnumbered sysctl support exists])
931 dnl # 2.6.33 API change,
932 dnl # Removed .ctl_name from struct ctl_table.
934 AC_DEFUN([SPL_AC_CTL_NAME], [
935 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
936 SPL_LINUX_TRY_COMPILE([
937 #include <linux/sysctl.h>
939 struct ctl_table ctl __attribute__ ((unused));
943 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
950 dnl # 2.6.16 API change.
951 dnl # Check if 'fls64()' is available
953 AC_DEFUN([SPL_AC_FLS64],
954 [AC_MSG_CHECKING([whether fls64() is available])
955 SPL_LINUX_TRY_COMPILE([
956 #include <linux/bitops.h>
961 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
968 dnl # 2.6.18 API change, check whether device_create() is available.
969 dnl # Device_create() was introduced in 2.6.18 and depricated
970 dnl # class_device_create() which was fully removed in 2.6.26.
972 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
973 SPL_CHECK_SYMBOL_EXPORT(
975 [drivers/base/core.c],
976 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
977 [device_create() is available])],
982 dnl # 2.6.27 API change,
983 dnl # device_create() uses 5 args, new 'drvdata' argument.
985 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
986 AC_MSG_CHECKING([whether device_create() wants 5 args])
987 tmp_flags="$EXTRA_KCFLAGS"
988 EXTRA_KCFLAGS="-Werror"
989 SPL_LINUX_TRY_COMPILE([
990 #include <linux/device.h>
992 device_create(NULL, NULL, 0, NULL, "%d", 1);
995 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
996 [device_create wants 5 args])
1000 EXTRA_KCFLAGS="$tmp_flags"
1004 dnl # 2.6.13 API change, check whether class_device_create() is available.
1005 dnl # Class_device_create() was introduced in 2.6.13 and depricated
1006 dnl # class_simple_device_add() which was fully removed in 2.6.13.
1008 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
1009 SPL_CHECK_SYMBOL_EXPORT(
1010 [class_device_create],
1011 [drivers/base/class.c],
1012 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
1013 [class_device_create() is available])],
1018 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
1020 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
1021 SPL_CHECK_SYMBOL_EXPORT(
1022 [set_normalized_timespec],
1024 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
1025 [set_normalized_timespec() is available as export])],
1030 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
1031 dnl # previously it was available in time.h as an inline.
1033 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
1034 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
1035 SPL_LINUX_TRY_COMPILE([
1036 #include <linux/time.h>
1037 void set_normalized_timespec(struct timespec *ts,
1038 time_t sec, long nsec) { }
1045 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
1046 [set_normalized_timespec() is available as inline])
1051 dnl # 2.6.18 API change,
1052 dnl # timespec_sub() inline function available in linux/time.h
1054 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
1055 AC_MSG_CHECKING([whether timespec_sub() is available])
1056 SPL_LINUX_TRY_COMPILE([
1057 #include <linux/time.h>
1059 struct timespec a = { 0 };
1060 struct timespec b = { 0 };
1061 struct timespec c __attribute__ ((unused));
1062 c = timespec_sub(a, b);
1065 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1072 dnl # 2.6.19 API change,
1073 dnl # check if init_utsname() is available in linux/utsname.h
1075 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
1076 AC_MSG_CHECKING([whether init_utsname() is available])
1077 SPL_LINUX_TRY_COMPILE([
1078 #include <linux/utsname.h>
1080 struct new_utsname *a __attribute__ ((unused));
1084 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1091 dnl # 2.6.26 API change,
1092 dnl # definition of struct fdtable relocated to linux/fdtable.h
1094 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
1095 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
1099 dnl # 2.6.14 API change,
1100 dnl # check whether 'files_fdtable()' exists
1102 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
1103 AC_MSG_CHECKING([whether files_fdtable() is available])
1104 SPL_LINUX_TRY_COMPILE([
1105 #include <linux/sched.h>
1106 #include <linux/file.h>
1107 #ifdef HAVE_FDTABLE_HEADER
1108 #include <linux/fdtable.h>
1111 struct files_struct *files = current->files;
1112 struct fdtable *fdt __attribute__ ((unused));
1113 fdt = files_fdtable(files);
1116 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
1123 dnl # 2.6.18 API change,
1124 dnl # added linux/uaccess.h
1126 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1127 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1131 dnl # 2.6.12 API change,
1132 dnl # check whether 'kmalloc_node()' is available.
1134 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1135 AC_MSG_CHECKING([whether kmalloc_node() is available])
1136 SPL_LINUX_TRY_COMPILE([
1137 #include <linux/slab.h>
1139 void *a __attribute__ ((unused));
1140 a = kmalloc_node(1, GFP_KERNEL, 0);
1143 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1150 dnl # 2.6.9 API change,
1151 dnl # check whether 'monotonic_clock()' is available it may
1152 dnl # be available for some archs but not others.
1154 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
1155 SPL_CHECK_SYMBOL_EXPORT(
1158 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1159 [monotonic_clock() is available])],
1164 dnl # 2.6.16 API change,
1165 dnl # check whether 'struct inode' has i_mutex
1167 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1168 AC_MSG_CHECKING([whether struct inode has i_mutex])
1169 SPL_LINUX_TRY_COMPILE([
1170 #include <linux/fs.h>
1171 #include <linux/mutex.h>
1174 mutex_init(&i.i_mutex);
1177 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1184 dnl # 2.6.29 API change,
1185 dnl # Adaptive mutexs introduced.
1187 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1188 AC_MSG_CHECKING([whether struct mutex has owner])
1189 SPL_LINUX_TRY_COMPILE([
1190 #include <linux/mutex.h>
1192 struct mutex mtx __attribute__ ((unused));
1196 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1203 dnl # 2.6.39 API change,
1204 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
1205 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
1206 dnl # was defined. As of 2.6.39 this was changed to a task_struct
1207 dnl # pointer which frankly makes a lot more sense.
1209 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
1210 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
1211 tmp_flags="$EXTRA_KCFLAGS"
1212 EXTRA_KCFLAGS="-Werror"
1213 SPL_LINUX_TRY_COMPILE([
1214 #include <linux/mutex.h>
1216 struct mutex mtx __attribute__ ((unused));
1217 mtx.owner = current;
1220 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
1221 [struct mutex owner is a task_struct])
1225 EXTRA_KCFLAGS="$tmp_flags"
1229 dnl # 2.6.18 API change,
1230 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1231 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1232 dnl # if the mutex validator is disabled or otherwise unavailable.
1234 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1235 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1236 SPL_LINUX_TRY_COMPILE([
1237 #include <linux/mutex.h>
1241 mutex_lock_nested(&mutex, 0);
1244 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1245 [mutex_lock_nested() is available])
1252 dnl # 2.6.27 API change,
1253 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1255 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1256 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1257 SPL_LINUX_TRY_COMPILE([
1258 #include <linux/smp.h>
1260 on_each_cpu(NULL, NULL, 0);
1263 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1264 [on_each_cpu wants 3 args])
1271 dnl # 2.6.18 API change,
1272 dnl # kallsyms_lookup_name no longer exported
1274 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
1275 SPL_CHECK_SYMBOL_EXPORT(
1276 [kallsyms_lookup_name],
1278 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1279 [kallsyms_lookup_name() is available])],
1284 dnl # Proposed API change,
1285 dnl # This symbol is not available in stock kernels. You may build a
1286 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1287 dnl # these symbols for use. If your already rolling a custom kernel for
1288 dnl # your environment this is recommended.
1290 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
1291 SPL_CHECK_SYMBOL_EXPORT(
1294 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1295 [get_vmalloc_info() is available])],
1300 dnl # 2.6.17 API change
1301 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1302 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1303 dnl # were exported in 2.6.17 for use by modules which was consistent with
1304 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1305 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1306 dnl # were dropped entirely leaving modules no way to directly iterate over
1307 dnl # the zone list. Because we need access to the zone helpers we check
1308 dnl # if the kernel contains the old or new implementation. Then we check
1309 dnl # to see if the symbols we need for each version are available. If they
1310 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1312 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1313 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1314 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1316 if test $rc -eq 0; then
1317 AC_MSG_RESULT([yes])
1318 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1325 dnl # Proposed API change,
1326 dnl # This symbol is not available in stock kernels. You may build a
1327 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1328 dnl # these symbols for use. If your already rolling a custom kernel for
1329 dnl # your environment this is recommended.
1331 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
1332 SPL_CHECK_SYMBOL_EXPORT(
1333 [first_online_pgdat],
1335 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1336 [first_online_pgdat() 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_NEXT_ONLINE_PGDAT], [
1348 SPL_CHECK_SYMBOL_EXPORT(
1349 [next_online_pgdat],
1351 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1352 [next_online_pgdat() is available])],
1357 dnl # Proposed API change,
1358 dnl # This symbol is not available in stock kernels. You may build a
1359 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1360 dnl # these symbols for use. If your already rolling a custom kernel for
1361 dnl # your environment this is recommended.
1363 AC_DEFUN([SPL_AC_NEXT_ZONE], [
1364 SPL_CHECK_SYMBOL_EXPORT(
1367 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1368 [next_zone() is available])],
1373 dnl # 2.6.17 API change,
1374 dnl # See SPL_AC_PGDAT_HELPERS for details.
1376 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1377 SPL_CHECK_SYMBOL_EXPORT(
1380 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1381 [pgdat_list is available])],
1386 dnl # 2.6.18 API change,
1387 dnl # First introduced global_page_state() support as an inline.
1389 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1390 AC_MSG_CHECKING([whether global_page_state() is available])
1391 SPL_LINUX_TRY_COMPILE([
1392 #include <linux/mm.h>
1394 unsigned long state __attribute__ ((unused));
1395 state = global_page_state(0);
1398 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1399 [global_page_state() is available])
1406 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1407 dnl # Public global zone stats now include a free page count. However
1408 dnl # the enumerated names of the counters have changed since this API
1409 dnl # was introduced. We need to deduce the corrent name to use. This
1410 dnl # replaces the priviate get_zone_counts() interface.
1412 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1413 dnl # is 2.6.30 as of when this was written.
1415 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1416 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1417 SPL_LINUX_TRY_COMPILE([
1418 #include <linux/mm.h>
1420 enum zone_stat_item zsi __attribute__ ((unused));
1421 zsi = NR_FREE_PAGES;
1424 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1425 [Page state NR_FREE_PAGES is available])
1432 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1433 dnl # Public global zone stats now include an inactive page count. However
1434 dnl # the enumerated names of the counters have changed since this API
1435 dnl # was introduced. We need to deduce the corrent name to use. This
1436 dnl # replaces the priviate get_zone_counts() interface.
1438 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1439 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1440 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1442 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1443 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1444 SPL_LINUX_TRY_COMPILE([
1445 #include <linux/mm.h>
1447 enum zone_stat_item zsi __attribute__ ((unused));
1451 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1452 [Page state NR_INACTIVE is available])
1457 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1458 SPL_LINUX_TRY_COMPILE([
1459 #include <linux/mm.h>
1461 enum zone_stat_item zsi __attribute__ ((unused));
1462 zsi = NR_INACTIVE_ANON;
1465 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1466 [Page state NR_INACTIVE_ANON is available])
1471 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1472 SPL_LINUX_TRY_COMPILE([
1473 #include <linux/mm.h>
1475 enum zone_stat_item zsi __attribute__ ((unused));
1476 zsi = NR_INACTIVE_FILE;
1479 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1480 [Page state NR_INACTIVE_FILE is available])
1487 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1488 dnl # Public global zone stats now include an active page count. However
1489 dnl # the enumerated names of the counters have changed since this API
1490 dnl # was introduced. We need to deduce the corrent name to use. This
1491 dnl # replaces the priviate get_zone_counts() interface.
1493 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1494 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1495 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1497 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1498 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1499 SPL_LINUX_TRY_COMPILE([
1500 #include <linux/mm.h>
1502 enum zone_stat_item zsi __attribute__ ((unused));
1506 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1507 [Page state NR_ACTIVE is available])
1512 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1513 SPL_LINUX_TRY_COMPILE([
1514 #include <linux/mm.h>
1516 enum zone_stat_item zsi __attribute__ ((unused));
1517 zsi = NR_ACTIVE_ANON;
1520 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1521 [Page state NR_ACTIVE_ANON is available])
1526 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1527 SPL_LINUX_TRY_COMPILE([
1528 #include <linux/mm.h>
1530 enum zone_stat_item zsi __attribute__ ((unused));
1531 zsi = NR_ACTIVE_FILE;
1534 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1535 [Page state NR_ACTIVE_FILE is available])
1542 dnl # Proposed API change for legacy kernels.
1543 dnl # This symbol is not available in older kernels. For kernels post
1544 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1545 dnl # page state information. This symbol is only used in legacy kernels
1546 dnl # any only as a last resort.
1548 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1549 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1550 SPL_LINUX_TRY_COMPILE([
1552 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1553 #error "global_page_state needs NR_FREE_PAGES"
1556 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1557 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1558 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1559 #error "global_page_state needs NR_ACTIVE*"
1562 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1563 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1564 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1565 #error "global_page_state needs NR_INACTIVE*"
1571 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1572 [get_zone_counts() is needed])
1574 SPL_CHECK_SYMBOL_EXPORT(
1577 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1578 [get_zone_counts() is available])],
1584 dnl # 2.6.27 API change,
1585 dnl # The user_path_dir() replaces __user_walk()
1587 AC_DEFUN([SPL_AC_USER_PATH_DIR], [
1588 SPL_CHECK_SYMBOL_EXPORT(
1591 [AC_DEFINE(HAVE_USER_PATH_DIR, 1,
1592 [user_path_dir() is available])],
1597 dnl # Symbol available in RHEL kernels not in stock kernels.
1599 AC_DEFUN([SPL_AC_SET_FS_PWD], [
1600 SPL_CHECK_SYMBOL_EXPORT(
1603 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1604 [set_fs_pwd() is available])],
1609 dnl # 2.6.25 API change,
1610 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1612 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1613 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1614 SPL_LINUX_TRY_COMPILE([
1615 #include <linux/sched.h>
1616 #include <linux/fs_struct.h>
1618 set_fs_pwd(NULL, NULL);
1621 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1622 [set_fs_pwd() wants 2 args])
1629 dnl # SLES API change, never adopted in mainline,
1630 dnl # Third 'struct vfsmount *' argument removed.
1632 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1633 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1634 SPL_LINUX_TRY_COMPILE([
1635 #include <linux/fs.h>
1637 vfs_unlink(NULL, NULL);
1640 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1641 [vfs_unlink() wants 2 args])
1648 dnl # SLES API change, never adopted in mainline,
1649 dnl # Third and sixth 'struct vfsmount *' argument removed.
1651 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1652 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1653 SPL_LINUX_TRY_COMPILE([
1654 #include <linux/fs.h>
1656 vfs_rename(NULL, NULL, NULL, NULL);
1659 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1660 [vfs_rename() wants 4 args])
1667 dnl # 2.6.36 API change,
1668 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1669 dnl # a spinlock_t to improve the fastpath performance.
1671 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1672 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1673 tmp_flags="$EXTRA_KCFLAGS"
1674 EXTRA_KCFLAGS="-Werror"
1675 SPL_LINUX_TRY_COMPILE([
1676 #include <linux/sched.h>
1677 #include <linux/fs_struct.h>
1679 struct fs_struct fs;
1680 spin_lock_init(&fs.lock);
1683 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1684 [struct fs_struct uses spinlock_t])
1688 EXTRA_KCFLAGS="$tmp_flags"
1692 dnl # 2.6.29 API change,
1693 dnl # check whether 'struct cred' exists
1695 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1696 AC_MSG_CHECKING([whether struct cred exists])
1697 SPL_LINUX_TRY_COMPILE([
1698 #include <linux/cred.h>
1700 struct cred *cr __attribute__ ((unused));
1704 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1711 dnl # Custom SPL patch may export this symbol.
1713 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1714 SPL_CHECK_SYMBOL_EXPORT(
1717 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1718 [groups_search() is available])],
1723 dnl # 2.6.x API change,
1724 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1726 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1727 SPL_CHECK_SYMBOL_EXPORT(
1728 [__put_task_struct],
1730 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1731 [__put_task_struct() is available])],
1736 dnl # 2.6.32 API change,
1737 dnl # Unused 'struct file *' removed from prototype.
1739 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1740 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1741 SPL_LINUX_TRY_COMPILE([
1742 #include <linux/sysctl.h>
1744 proc_dostring(NULL, 0, NULL, NULL, NULL);
1747 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1748 [proc_handler() wants 5 args])
1755 dnl # 2.6.x API change,
1756 dnl # kvasprintf() function added.
1758 AC_DEFUN([SPL_AC_KVASPRINTF], [
1759 SPL_CHECK_SYMBOL_EXPORT(
1762 [AC_DEFINE(HAVE_KVASPRINTF, 1,
1763 [kvasprintf() is available])],
1768 dnl # 2.6.29 API change,
1769 dnl # vfs_fsync() funcation added, prior to this use file_fsync().
1771 AC_DEFUN([SPL_AC_VFS_FSYNC], [
1772 SPL_CHECK_SYMBOL_EXPORT(
1775 [AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])],
1780 dnl # 2.6.35 API change,
1781 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
1783 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
1784 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
1785 SPL_LINUX_TRY_COMPILE([
1786 #include <linux/fs.h>
1791 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
1798 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
1799 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
1800 dnl # condition. The fixed version is exported as a symbol. The race
1801 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
1802 dnl # call that version while holding sem->wait_lock.
1804 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED], [
1805 SPL_CHECK_SYMBOL_EXPORT(
1807 [lib/rwsem-spinlock.c],
1808 [AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
1809 [rwsem_is_locked() acquires sem->wait_lock])],
1814 dnl # 2.6.37 API compat,
1815 dnl # The function invalidate_inodes() is no longer exported by the kernel.
1816 dnl # The prototype however is still available which means it is safe
1817 dnl # to acquire the symbol's address using spl_kallsyms_lookup_name().
1819 dnl # The Proxmox VE kernel contains a patch which renames the function
1820 dnl # invalidate_inodes() to invalidate_inodes_check(). In the process
1821 dnl # it adds a 'check' argument and a '#define invalidate_inodes(x)'
1822 dnl # compatibility wrapper for legacy callers. Therefore, if either
1823 dnl # of these functions are exported invalidate_inodes() can be
1826 AC_DEFUN([SPL_AC_KERNEL_INVALIDATE_INODES], [
1827 SPL_CHECK_SYMBOL_EXPORT(
1828 [invalidate_inodes],
1830 [AC_DEFINE(HAVE_INVALIDATE_INODES, 1,
1831 [invalidate_inodes() is available])],
1833 SPL_CHECK_SYMBOL_EXPORT(
1834 [invalidate_inodes_check],
1836 [AC_DEFINE(HAVE_INVALIDATE_INODES_CHECK, 1,
1837 [invalidate_inodes_check() is available])],
1842 dnl # 2.6.39 API compat,
1843 dnl # The function invalidate_inodes() now take 2 arguments. The second
1844 dnl # 'kill_dirty' argument describes how invalidate_inodes() should
1845 dnl # handle dirty inodes. Only when set will dirty inodes be discarded,
1846 dnl # otherwise they will be handled as busy.
1848 dnl # Unfortunately, we don't have access to the invalidate_inodes()
1849 dnl # prototype so it's not easy to check how many arguments it takes.
1850 dnl # However, this change was done for the benefit of invalidate_device()
1851 dnl # which also added an argument. The invalidate_device() symbol does
1852 dnl # exist in the development headers so if it takes two arguments we
1853 dnl # can fairly safely infer that invalidate_inodes() takes two arguments
1854 dnl # as well. See commit 93b270f76e7ef3b81001576860c2701931cdc78b.
1856 AC_DEFUN([SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES],
1857 [AC_MSG_CHECKING([whether invalidate_inodes() wants 2 args])
1858 SPL_LINUX_TRY_COMPILE([
1859 #include <linux/fs.h>
1861 return __invalidate_device(NULL, 0);
1864 AC_DEFINE(HAVE_2ARGS_INVALIDATE_INODES, 1,
1865 [invalidate_inodes() wants 2 args])
1872 dnl # 2.6.xx API compat,
1873 dnl # There currently exists no exposed API to partially shrink the dcache.
1874 dnl # The expected mechanism to shrink the cache is a registered shrinker
1875 dnl # which is called during memory pressure.
1877 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY], [
1878 SPL_CHECK_SYMBOL_EXPORT(
1879 [shrink_dcache_memory],
1881 [AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
1882 [shrink_dcache_memory() is available])],
1887 dnl # 2.6.xx API compat,
1888 dnl # There currently exists no exposed API to partially shrink the icache.
1889 dnl # The expected mechanism to shrink the cache is a registered shrinker
1890 dnl # which is called during memory pressure.
1892 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY], [
1893 SPL_CHECK_SYMBOL_EXPORT(
1894 [shrink_icache_memory],
1896 [AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
1897 [shrink_icache_memory() is available])],
1902 dnl # 2.6.39 API compat,
1903 dnl # The path_lookup() function has been renamed to kern_path_parent()
1904 dnl # and the flags argument has been removed. The only behavior now
1905 dnl # offered is that of LOOKUP_PARENT. The spl already always passed
1906 dnl # this flag so dropping the flag does not impact us.
1908 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_HEADER], [
1909 SPL_CHECK_SYMBOL_HEADER(
1911 [int kern_path_parent(const char \*, struct nameidata \*)],
1912 [include/linux/namei.h],
1913 [AC_DEFINE(HAVE_KERN_PATH_PARENT_HEADER, 1,
1914 [kern_path_parent() is available])],
1919 dnl # 3.1 API compat,
1920 dnl # The kern_path_parent() symbol is no longer exported by the kernel.
1921 dnl # However, it remains the prefered interface and since we still have
1922 dnl # access to the prototype we dynamically lookup the required address.
1924 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_SYMBOL], [
1925 SPL_CHECK_SYMBOL_EXPORT(
1928 [AC_DEFINE(HAVE_KERN_PATH_PARENT_SYMBOL, 1,
1929 [kern_path_parent() is available])],
1934 dnl # 2.6.39 API compat,
1935 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
1936 dnl # This was done to avoid always having to allocate the maximum size
1937 dnl # workspace (268K). The caller can now specific the windowBits and
1938 dnl # memLevel compression parameters to get a smaller workspace.
1940 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
1941 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
1942 SPL_LINUX_TRY_COMPILE([
1943 #include <linux/zlib.h>
1945 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
1948 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
1949 [zlib_deflate_workspacesize() wants 2 args])
1956 dnl # 2.6.39 API change,
1957 dnl # Shrinker adjust to use common shrink_control structure.
1959 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
1960 AC_MSG_CHECKING([whether struct shrink_control exists])
1961 SPL_LINUX_TRY_COMPILE([
1962 #include <linux/mm.h>
1964 struct shrink_control sc __attribute__ ((unused));
1967 sc.gfp_mask = GFP_KERNEL;
1970 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
1971 [struct shrink_control exists])