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_LOCK_NESTED
52 SPL_AC_3ARGS_ON_EACH_CPU
53 SPL_AC_KALLSYMS_LOOKUP_NAME
54 SPL_AC_GET_VMALLOC_INFO
56 SPL_AC_FIRST_ONLINE_PGDAT
57 SPL_AC_NEXT_ONLINE_PGDAT
60 SPL_AC_GLOBAL_PAGE_STATE
61 SPL_AC_ZONE_STAT_ITEM_FREE
62 SPL_AC_ZONE_STAT_ITEM_INACTIVE
63 SPL_AC_ZONE_STAT_ITEM_ACTIVE
64 SPL_AC_GET_ZONE_COUNTS
67 SPL_AC_2ARGS_SET_FS_PWD
68 SPL_AC_2ARGS_VFS_UNLINK
69 SPL_AC_4ARGS_VFS_RENAME
70 SPL_AC_FS_STRUCT_SPINLOCK
73 SPL_AC_PUT_TASK_STRUCT
74 SPL_AC_5ARGS_PROC_HANDLER
76 SPL_AC_3ARGS_FILE_FSYNC
77 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
78 SPL_AC_KERNEL_INVALIDATE_INODES
79 SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES
80 SPL_AC_SHRINK_DCACHE_MEMORY
81 SPL_AC_SHRINK_ICACHE_MEMORY
82 SPL_AC_KERN_PATH_PARENT
83 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
86 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
87 modpost=$LINUX/scripts/Makefile.modpost
88 AC_MSG_CHECKING([kernel file name for module symbols])
89 if test -f "$modpost"; then
90 if grep -q Modules.symvers $modpost; then
91 LINUX_SYMBOLS=Modules.symvers
93 LINUX_SYMBOLS=Module.symvers
96 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
98 *** Please make sure the kernel devel package for your distribution
99 *** is installed. If your building with a custom kernel make sure the
100 *** kernel is configured, built, and the '--with-linux=PATH' configure
101 *** option refers to the location of the kernel source.])
106 AC_MSG_RESULT($LINUX_SYMBOLS)
107 AC_SUBST(LINUX_SYMBOLS)
110 AC_DEFUN([SPL_AC_KERNEL], [
112 AS_HELP_STRING([--with-linux=PATH],
113 [Path to kernel source]),
114 [kernelsrc="$withval"])
116 AC_ARG_WITH([linux-obj],
117 AS_HELP_STRING([--with-linux-obj=PATH],
118 [Path to kernel build objects]),
119 [kernelbuild="$withval"])
121 AC_MSG_CHECKING([kernel source directory])
122 if test -z "$kernelsrc"; then
123 if test -e "/lib/modules/$(uname -r)/source"; then
124 headersdir="/lib/modules/$(uname -r)/source"
125 sourcelink=$(readlink -f "$headersdir")
126 elif test -e "/lib/modules/$(uname -r)/build"; then
127 headersdir="/lib/modules/$(uname -r)/build"
128 sourcelink=$(readlink -f "$headersdir")
130 sourcelink=$(ls -1d /usr/src/kernels/* \
132 2>/dev/null | grep -v obj | tail -1)
135 if test -n "$sourcelink" && test -e ${sourcelink}; then
136 kernelsrc=`readlink -f ${sourcelink}`
138 AC_MSG_RESULT([Not found])
140 *** Please make sure the kernel devel package for your distribution
141 *** is installed then try again. If that fails you can specify the
142 *** location of the kernel source with the '--with-linux=PATH' option.])
145 if test "$kernelsrc" = "NONE"; then
150 AC_MSG_RESULT([$kernelsrc])
151 AC_MSG_CHECKING([kernel build directory])
152 if test -z "$kernelbuild"; then
153 if test -e "/lib/modules/$(uname -r)/build"; then
154 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
155 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
156 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
157 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
158 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
159 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
160 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
162 kernelbuild=${kernelsrc}
165 AC_MSG_RESULT([$kernelbuild])
167 AC_MSG_CHECKING([kernel source version])
168 utsrelease1=$kernelbuild/include/linux/version.h
169 utsrelease2=$kernelbuild/include/linux/utsrelease.h
170 utsrelease3=$kernelbuild/include/generated/utsrelease.h
171 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
172 utsrelease=linux/version.h
173 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
174 utsrelease=linux/utsrelease.h
175 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
176 utsrelease=generated/utsrelease.h
179 if test "$utsrelease"; then
180 kernsrcver=`(echo "#include <$utsrelease>";
181 echo "kernsrcver=UTS_RELEASE") |
182 cpp -I $kernelbuild/include |
183 grep "^kernsrcver=" | cut -d \" -f 2`
185 if test -z "$kernsrcver"; then
186 AC_MSG_RESULT([Not found])
187 AC_MSG_ERROR([*** Cannot determine kernel version.])
190 AC_MSG_RESULT([Not found])
191 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
194 AC_MSG_RESULT([$kernsrcver])
197 LINUX_OBJ=${kernelbuild}
198 LINUX_VERSION=${kernsrcver}
202 AC_SUBST(LINUX_VERSION)
204 SPL_AC_MODULE_SYMVERS
207 AC_DEFUN([SPL_AC_KERNEL_CONFIG], [
208 SPL_LINUX_CONFIG([PREEMPT],
210 *** Kernel built with CONFIG_PREEMPT which is not supported.
211 ** You must rebuild your kernel without this option.]), [])
215 dnl # Explicitly check for gawk, we require it for the the usermode
216 dnl # helper. For some reason the standard awk command does not
217 dnl # behave correctly when invoked from the usermode helper.
219 AC_DEFUN([SPL_AC_GAWK], [
220 AS_IF([test "x$AWK" != xgawk], [
222 *** Required util gawk missing. Please install the required
223 *** gawk package for your distribution and try again.])
228 dnl # Default SPL user configuration
230 AC_DEFUN([SPL_AC_CONFIG_USER], [
235 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
236 dnl # are missing it is non-fatal but you will not be able to build
237 dnl # RPM packages and will be warned if you try too.
239 AC_DEFUN([SPL_AC_RPM], [
243 AC_MSG_CHECKING([whether $RPM is available])
244 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
245 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
247 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
250 AC_MSG_RESULT([$HAVE_RPM])
253 AC_MSG_CHECKING([whether $RPMBUILD is available])
254 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
255 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
257 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
260 AC_MSG_RESULT([$HAVE_RPMBUILD])
265 AC_SUBST(RPM_VERSION)
267 AC_SUBST(HAVE_RPMBUILD)
269 AC_SUBST(RPMBUILD_VERSION)
273 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
274 dnl # tools are missing it is non-fatal but you will not be able to build
275 dnl # DEB packages and will be warned if you try too.
277 AC_DEFUN([SPL_AC_DPKG], [
279 DPKGBUILD=dpkg-buildpackage
281 AC_MSG_CHECKING([whether $DPKG is available])
282 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
283 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
285 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
288 AC_MSG_RESULT([$HAVE_DPKG])
291 AC_MSG_CHECKING([whether $DPKGBUILD is available])
292 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
293 DPKGBUILD_VERSION=$(echo $tmp | \
294 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
296 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
299 AC_MSG_RESULT([$HAVE_DPKGBUILD])
304 AC_SUBST(DPKG_VERSION)
306 AC_SUBST(HAVE_DPKGBUILD)
308 AC_SUBST(DPKGBUILD_VERSION)
312 dnl # Until native packaging for various different packing systems
313 dnl # can be added the least we can do is attempt to use alien to
314 dnl # convert the RPM packages to the needed package type. This is
315 dnl # a hack but so far it has worked reasonable well.
317 AC_DEFUN([SPL_AC_ALIEN], [
320 AC_MSG_CHECKING([whether $ALIEN is available])
321 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
322 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
324 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
327 AC_MSG_RESULT([$HAVE_ALIEN])
332 AC_SUBST(ALIEN_VERSION)
336 dnl # Using the VENDOR tag from config.guess set the default
337 dnl # package type for 'make pkg': (rpm | deb | tgz)
339 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
340 AC_MSG_CHECKING([linux distribution])
341 if test -f /etc/redhat-release ; then
343 elif test -f /etc/fedora-release ; then
345 elif test -f /etc/lsb-release ; then
347 elif test -f /etc/debian_version ; then
349 elif test -f /etc/SuSE-release ; then
351 elif test -f /etc/slackware-version ; then
353 elif test -f /etc/gentoo-release ; then
358 AC_MSG_RESULT([$VENDOR])
361 AC_MSG_CHECKING([default package type])
363 fedora) DEFAULT_PACKAGE=rpm ;;
364 redhat) DEFAULT_PACKAGE=rpm ;;
365 sles) DEFAULT_PACKAGE=rpm ;;
366 ubuntu) DEFAULT_PACKAGE=deb ;;
367 debian) DEFAULT_PACKAGE=deb ;;
368 slackware) DEFAULT_PACKAGE=tgz ;;
369 *) DEFAULT_PACKAGE=rpm ;;
372 AC_MSG_RESULT([$DEFAULT_PACKAGE])
373 AC_SUBST(DEFAULT_PACKAGE)
377 dnl # Default SPL user configuration
379 AC_DEFUN([SPL_AC_PACKAGE], [
383 SPL_AC_DEFAULT_PACKAGE
386 AC_DEFUN([SPL_AC_LICENSE], [
387 AC_MSG_CHECKING([spl license])
389 AC_MSG_RESULT([$LICENSE])
390 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
394 AC_DEFUN([SPL_AC_CONFIG], [
396 AC_ARG_WITH([config],
397 AS_HELP_STRING([--with-config=CONFIG],
398 [Config file 'kernel|user|all|srpm']),
399 [SPL_CONFIG="$withval"])
401 AC_MSG_CHECKING([spl config])
402 AC_MSG_RESULT([$SPL_CONFIG]);
405 case "$SPL_CONFIG" in
406 kernel) SPL_AC_CONFIG_KERNEL ;;
407 user) SPL_AC_CONFIG_USER ;;
408 all) SPL_AC_CONFIG_KERNEL
409 SPL_AC_CONFIG_USER ;;
412 AC_MSG_RESULT([Error!])
413 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
414 user kernel|user|all|srpm]) ;;
417 AM_CONDITIONAL([CONFIG_USER],
418 [test "$SPL_CONFIG" = user] ||
419 [test "$SPL_CONFIG" = all])
420 AM_CONDITIONAL([CONFIG_KERNEL],
421 [test "$SPL_CONFIG" = kernel] ||
422 [test "$SPL_CONFIG" = all])
426 dnl # Enable if the SPL should be compiled with internal debugging enabled.
427 dnl # By default this support is disabled.
429 AC_DEFUN([SPL_AC_DEBUG], [
430 AC_MSG_CHECKING([whether debugging is enabled])
431 AC_ARG_ENABLE([debug],
432 [AS_HELP_STRING([--enable-debug],
433 [Enable generic debug support @<:@default=no@:>@])],
437 AS_IF([test "x$enable_debug" = xyes],
439 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
440 DEBUG_CFLAGS="-DDEBUG -Werror"
443 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
444 DEBUG_CFLAGS="-DNDEBUG"
447 AC_SUBST(DEBUG_CFLAGS)
448 AC_MSG_RESULT([$enable_debug])
452 dnl # Enabled by default it provides a minimal level of memory tracking.
453 dnl # A total count of bytes allocated is kept for each alloc and free.
454 dnl # Then at module unload time a report to the console will be printed
455 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
456 dnl # and provide an easy way to inspect the kmem based slab.
458 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
459 AC_ARG_ENABLE([debug-kmem],
460 [AS_HELP_STRING([--enable-debug-kmem],
461 [Enable basic kmem accounting @<:@default=yes@:>@])],
463 [enable_debug_kmem=yes])
465 AS_IF([test "x$enable_debug_kmem" = xyes],
466 [AC_DEFINE([DEBUG_KMEM], [1],
467 [Define to 1 to enable basic kmem accounting])
468 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"])
470 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
471 AC_MSG_RESULT([$enable_debug_kmem])
475 dnl # Disabled by default it provides detailed memory tracking. This
476 dnl # feature also requires --enable-debug-kmem to be set. When enabled
477 dnl # not only will total bytes be tracked but also the location of every
478 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
479 dnl # addresses and where they were allocated will be dumped to the console.
480 dnl # Enabling this feature has a significant impact on performance but it
481 dnl # makes finding memory leaks pretty straight forward.
483 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
484 AC_ARG_ENABLE([debug-kmem-tracking],
485 [AS_HELP_STRING([--enable-debug-kmem-tracking],
486 [Enable detailed kmem tracking @<:@default=no@:>@])],
488 [enable_debug_kmem_tracking=no])
490 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
491 [AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
492 [Define to 1 to enable detailed kmem tracking])
493 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"])
495 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
496 AC_MSG_RESULT([$enable_debug_kmem_tracking])
500 dnl # SPL_LINUX_CONFTEST
502 AC_DEFUN([SPL_LINUX_CONFTEST], [
503 cat confdefs.h - <<_ACEOF >conftest.c
509 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
511 m4_define([SPL_LANG_PROGRAM], [
516 dnl Do *not* indent the following line: there may be CPP directives.
517 dnl Don't move the `;' right after for the same reason.
525 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
527 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
528 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
529 rm -Rf build && mkdir -p build
530 echo "obj-m := conftest.o" >build/Makefile
532 [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])],
534 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
540 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
542 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
543 [SPL_LINUX_COMPILE_IFELSE(
544 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
546 [test -s build/conftest.o],
551 dnl # SPL_LINUX_CONFIG
553 AC_DEFUN([SPL_LINUX_CONFIG],
554 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
555 SPL_LINUX_TRY_COMPILE([
556 #ifndef AUTOCONF_INCLUDED
557 #include <linux/config.h>
561 #error CONFIG_$1 not #defined
573 dnl # SPL_CHECK_SYMBOL_EXPORT
574 dnl # check symbol exported or not
576 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
577 [AC_MSG_CHECKING([whether symbol $1 is exported])
578 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
579 $LINUX_OBJ/Module*.symvers 2>/dev/null
581 if test $rc -ne 0; then
584 grep -q -E "EXPORT_SYMBOL.*($1)" \
585 "$LINUX_OBJ/$file" 2>/dev/null
587 if test $rc -eq 0; then
592 if test $export -eq 0; then
606 dnl # SPL_CHECK_HEADER
607 dnl # check whether header exists and define HAVE_$2_HEADER
609 AC_DEFUN([SPL_CHECK_HEADER],
610 [AC_MSG_CHECKING([whether header $1 exists])
611 SPL_LINUX_TRY_COMPILE([
616 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
626 dnl # Use the atomic implemenation based on global spinlocks. This
627 dnl # should only be needed by 32-bit kernels which do not provide
628 dnl # the atomic64_* API. It may be optionally enabled as a fallback
629 dnl # if problems are observed with the direct mapping to the native
630 dnl # Linux atomic operations. You may not disable atomic spinlocks
631 dnl # if you kernel does not an atomic64_* API.
633 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
634 AC_ARG_ENABLE([atomic-spinlocks],
635 [AS_HELP_STRING([--enable-atomic-spinlocks],
636 [Atomic types use spinlocks @<:@default=check@:>@])],
638 [enable_atomic_spinlocks=check])
640 SPL_LINUX_TRY_COMPILE([
641 #include <asm/atomic.h>
643 atomic64_t *ptr __attribute__ ((unused));
646 AC_DEFINE(HAVE_ATOMIC64_T, 1,
647 [kernel defines atomic64_t])
652 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
653 AS_IF([test "x$have_atomic64_t" = xyes], [
654 enable_atomic_spinlocks=no
656 enable_atomic_spinlocks=yes
660 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
661 AC_DEFINE([ATOMIC_SPINLOCK], [1],
662 [Atomic types use spinlocks])
664 AS_IF([test "x$have_atomic64_t" = xno], [
666 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
670 AC_MSG_CHECKING([whether atomic types use spinlocks])
671 AC_MSG_RESULT([$enable_atomic_spinlocks])
673 AC_MSG_CHECKING([whether kernel defines atomic64_t])
674 AC_MSG_RESULT([$have_atomic64_t])
678 dnl # 2.6.24 API change,
679 dnl # check if atomic64_cmpxchg is defined
681 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
682 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
683 SPL_LINUX_TRY_COMPILE([
684 #include <asm/atomic.h>
685 #include <asm/system.h>
687 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
690 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
691 [kernel defines atomic64_cmpxchg])
698 dnl # 2.6.24 API change,
699 dnl # check if atomic64_xchg is defined
701 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
702 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
703 SPL_LINUX_TRY_COMPILE([
704 #include <asm/atomic.h>
706 atomic64_xchg((atomic64_t *)NULL, 0);
709 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
710 [kernel defines atomic64_xchg])
717 dnl # 2.6.24 API change,
718 dnl # check if uintptr_t typedef is defined
720 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
721 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
722 SPL_LINUX_TRY_COMPILE([
723 #include <linux/types.h>
725 uintptr_t *ptr __attribute__ ((unused));
728 AC_DEFINE(HAVE_UINTPTR_T, 1,
729 [kernel defines uintptr_t])
736 dnl # 2.6.20 API change,
737 dnl # INIT_WORK use 2 args and not store data inside
739 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
740 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
741 SPL_LINUX_TRY_COMPILE([
742 #include <linux/workqueue.h>
744 struct work_struct work __attribute__ ((unused));
745 INIT_WORK(&work, NULL, NULL);
748 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
749 [INIT_WORK wants 3 args])
756 dnl # 2.6.21 API change,
757 dnl # 'register_sysctl_table' use only one argument instead of two
759 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
760 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
761 SPL_LINUX_TRY_COMPILE([
762 #include <linux/sysctl.h>
764 (void) register_sysctl_table(NULL, 0);
767 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
768 [register_sysctl_table() wants 2 args])
775 dnl # 2.6.23 API change
776 dnl # Old set_shrinker API replaced with register_shrinker
778 AC_DEFUN([SPL_AC_SET_SHRINKER], [
779 AC_MSG_CHECKING([whether set_shrinker() available])
780 SPL_LINUX_TRY_COMPILE([
781 #include <linux/mm.h>
783 return set_shrinker(DEFAULT_SEEKS, NULL);
786 AC_DEFINE(HAVE_SET_SHRINKER, 1,
787 [set_shrinker() available])
794 dnl # 2.6.35 API change,
795 dnl # Add context to shrinker callback
797 AC_DEFUN([SPL_AC_3ARGS_SHRINKER_CALLBACK],
798 [AC_MSG_CHECKING([whether shrinker callback wants 3 args])
799 tmp_flags="$EXTRA_KCFLAGS"
800 EXTRA_KCFLAGS="-Werror"
801 SPL_LINUX_TRY_COMPILE([
802 #include <linux/mm.h>
804 int shrinker_cb(struct shrinker *, int, unsigned int);
806 struct shrinker cache_shrinker = {
807 .shrink = shrinker_cb,
808 .seeks = DEFAULT_SEEKS,
810 register_shrinker(&cache_shrinker);
813 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
814 [shrinker callback wants 3 args])
818 EXTRA_KCFLAGS="$tmp_flags"
822 dnl # 2.6.25 API change,
823 dnl # struct path entry added to struct nameidata
825 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
826 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
827 SPL_LINUX_TRY_COMPILE([
828 #include <linux/namei.h>
830 struct nameidata nd __attribute__ ((unused));
833 nd.path.dentry = NULL;
836 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
837 [struct path used in struct nameidata])
844 dnl # Custom SPL patch may export this system it is not required
846 AC_DEFUN([SPL_AC_TASK_CURR], [
847 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
848 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
853 dnl # 2.6.19 API change,
854 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
856 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
857 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
858 SPL_LINUX_TRY_COMPILE([
859 #include <linux/sysctl.h>
861 #ifndef CTL_UNNUMBERED
862 #error CTL_UNNUMBERED undefined
866 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
867 [unnumbered sysctl support exists])
874 dnl # 2.6.33 API change,
875 dnl # Removed .ctl_name from struct ctl_table.
877 AC_DEFUN([SPL_AC_CTL_NAME], [
878 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
879 SPL_LINUX_TRY_COMPILE([
880 #include <linux/sysctl.h>
882 struct ctl_table ctl __attribute__ ((unused));
886 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
893 dnl # 2.6.16 API change.
894 dnl # Check if 'fls64()' is available
896 AC_DEFUN([SPL_AC_FLS64],
897 [AC_MSG_CHECKING([whether fls64() is available])
898 SPL_LINUX_TRY_COMPILE([
899 #include <linux/bitops.h>
904 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
911 dnl # 2.6.18 API change, check whether device_create() is available.
912 dnl # Device_create() was introduced in 2.6.18 and depricated
913 dnl # class_device_create() which was fully removed in 2.6.26.
915 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
916 SPL_CHECK_SYMBOL_EXPORT(
918 [drivers/base/core.c],
919 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
920 [device_create() is available])],
925 dnl # 2.6.27 API change,
926 dnl # device_create() uses 5 args, new 'drvdata' argument.
928 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
929 AC_MSG_CHECKING([whether device_create() wants 5 args])
930 tmp_flags="$EXTRA_KCFLAGS"
931 EXTRA_KCFLAGS="-Werror"
932 SPL_LINUX_TRY_COMPILE([
933 #include <linux/device.h>
935 device_create(NULL, NULL, 0, NULL, "%d", 1);
938 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
939 [device_create wants 5 args])
943 EXTRA_KCFLAGS="$tmp_flags"
947 dnl # 2.6.13 API change, check whether class_device_create() is available.
948 dnl # Class_device_create() was introduced in 2.6.13 and depricated
949 dnl # class_simple_device_add() which was fully removed in 2.6.13.
951 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
952 SPL_CHECK_SYMBOL_EXPORT(
953 [class_device_create],
954 [drivers/base/class.c],
955 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
956 [class_device_create() is available])],
961 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
963 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
964 SPL_CHECK_SYMBOL_EXPORT(
965 [set_normalized_timespec],
967 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
968 [set_normalized_timespec() is available as export])],
973 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
974 dnl # previously it was available in time.h as an inline.
976 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
977 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
978 SPL_LINUX_TRY_COMPILE([
979 #include <linux/time.h>
980 void set_normalized_timespec(struct timespec *ts,
981 time_t sec, long nsec) { }
988 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
989 [set_normalized_timespec() is available as inline])
994 dnl # 2.6.18 API change,
995 dnl # timespec_sub() inline function available in linux/time.h
997 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
998 AC_MSG_CHECKING([whether timespec_sub() is available])
999 SPL_LINUX_TRY_COMPILE([
1000 #include <linux/time.h>
1002 struct timespec a = { 0 };
1003 struct timespec b = { 0 };
1004 struct timespec c __attribute__ ((unused));
1005 c = timespec_sub(a, b);
1008 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1015 dnl # 2.6.19 API change,
1016 dnl # check if init_utsname() is available in linux/utsname.h
1018 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
1019 AC_MSG_CHECKING([whether init_utsname() is available])
1020 SPL_LINUX_TRY_COMPILE([
1021 #include <linux/utsname.h>
1023 struct new_utsname *a __attribute__ ((unused));
1027 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1034 dnl # 2.6.26 API change,
1035 dnl # definition of struct fdtable relocated to linux/fdtable.h
1037 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
1038 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
1042 dnl # 2.6.14 API change,
1043 dnl # check whether 'files_fdtable()' exists
1045 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
1046 AC_MSG_CHECKING([whether files_fdtable() is available])
1047 SPL_LINUX_TRY_COMPILE([
1048 #include <linux/sched.h>
1049 #include <linux/file.h>
1050 #ifdef HAVE_FDTABLE_HEADER
1051 #include <linux/fdtable.h>
1054 struct files_struct *files = current->files;
1055 struct fdtable *fdt __attribute__ ((unused));
1056 fdt = files_fdtable(files);
1059 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
1066 dnl # 2.6.18 API change,
1067 dnl # added linux/uaccess.h
1069 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1070 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1074 dnl # 2.6.12 API change,
1075 dnl # check whether 'kmalloc_node()' is available.
1077 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1078 AC_MSG_CHECKING([whether kmalloc_node() is available])
1079 SPL_LINUX_TRY_COMPILE([
1080 #include <linux/slab.h>
1082 void *a __attribute__ ((unused));
1083 a = kmalloc_node(1, GFP_KERNEL, 0);
1086 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1093 dnl # 2.6.9 API change,
1094 dnl # check whether 'monotonic_clock()' is available it may
1095 dnl # be available for some archs but not others.
1097 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
1098 SPL_CHECK_SYMBOL_EXPORT(
1101 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1102 [monotonic_clock() is available])],
1107 dnl # 2.6.16 API change,
1108 dnl # check whether 'struct inode' has i_mutex
1110 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1111 AC_MSG_CHECKING([whether struct inode has i_mutex])
1112 SPL_LINUX_TRY_COMPILE([
1113 #include <linux/fs.h>
1114 #include <linux/mutex.h>
1117 mutex_init(&i.i_mutex);
1120 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1127 dnl # 2.6.29 API change,
1128 dnl # Adaptive mutexs introduced.
1130 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1131 AC_MSG_CHECKING([whether struct mutex has owner])
1132 SPL_LINUX_TRY_COMPILE([
1133 #include <linux/mutex.h>
1135 struct mutex mtx __attribute__ ((unused));
1139 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1146 dnl # 2.6.18 API change,
1147 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1148 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1149 dnl # if the mutex validator is disabled or otherwise unavailable.
1151 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1152 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1153 SPL_LINUX_TRY_COMPILE([
1154 #include <linux/mutex.h>
1158 mutex_lock_nested(&mutex, 0);
1161 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1162 [mutex_lock_nested() is available])
1169 dnl # 2.6.27 API change,
1170 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1172 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1173 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1174 SPL_LINUX_TRY_COMPILE([
1175 #include <linux/smp.h>
1177 on_each_cpu(NULL, NULL, 0);
1180 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1181 [on_each_cpu wants 3 args])
1188 dnl # 2.6.18 API change,
1189 dnl # kallsyms_lookup_name no longer exported
1191 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
1192 SPL_CHECK_SYMBOL_EXPORT(
1193 [kallsyms_lookup_name],
1195 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1196 [kallsyms_lookup_name() is available])],
1201 dnl # Proposed API change,
1202 dnl # This symbol is not available in stock kernels. You may build a
1203 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1204 dnl # these symbols for use. If your already rolling a custom kernel for
1205 dnl # your environment this is recommended.
1207 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
1208 SPL_CHECK_SYMBOL_EXPORT(
1211 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1212 [get_vmalloc_info() is available])],
1217 dnl # 2.6.17 API change
1218 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1219 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1220 dnl # were exported in 2.6.17 for use by modules which was consistent with
1221 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1222 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1223 dnl # were dropped entirely leaving modules no way to directly iterate over
1224 dnl # the zone list. Because we need access to the zone helpers we check
1225 dnl # if the kernel contains the old or new implementation. Then we check
1226 dnl # to see if the symbols we need for each version are available. If they
1227 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1229 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1230 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1231 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1233 if test $rc -eq 0; then
1234 AC_MSG_RESULT([yes])
1235 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1242 dnl # Proposed API change,
1243 dnl # This symbol is not available in stock kernels. You may build a
1244 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1245 dnl # these symbols for use. If your already rolling a custom kernel for
1246 dnl # your environment this is recommended.
1248 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
1249 SPL_CHECK_SYMBOL_EXPORT(
1250 [first_online_pgdat],
1252 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1253 [first_online_pgdat() is available])],
1258 dnl # Proposed API change,
1259 dnl # This symbol is not available in stock kernels. You may build a
1260 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1261 dnl # these symbols for use. If your already rolling a custom kernel for
1262 dnl # your environment this is recommended.
1264 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
1265 SPL_CHECK_SYMBOL_EXPORT(
1266 [next_online_pgdat],
1268 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1269 [next_online_pgdat() is available])],
1274 dnl # Proposed API change,
1275 dnl # This symbol is not available in stock kernels. You may build a
1276 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1277 dnl # these symbols for use. If your already rolling a custom kernel for
1278 dnl # your environment this is recommended.
1280 AC_DEFUN([SPL_AC_NEXT_ZONE], [
1281 SPL_CHECK_SYMBOL_EXPORT(
1284 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1285 [next_zone() is available])],
1290 dnl # 2.6.17 API change,
1291 dnl # See SPL_AC_PGDAT_HELPERS for details.
1293 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1294 SPL_CHECK_SYMBOL_EXPORT(
1297 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1298 [pgdat_list is available])],
1303 dnl # 2.6.18 API change,
1304 dnl # First introduced global_page_state() support as an inline.
1306 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1307 AC_MSG_CHECKING([whether global_page_state() is available])
1308 SPL_LINUX_TRY_COMPILE([
1309 #include <linux/mm.h>
1311 unsigned long state __attribute__ ((unused));
1312 state = global_page_state(0);
1315 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1316 [global_page_state() is available])
1323 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1324 dnl # Public global zone stats now include a free page count. However
1325 dnl # the enumerated names of the counters have changed since this API
1326 dnl # was introduced. We need to deduce the corrent name to use. This
1327 dnl # replaces the priviate get_zone_counts() interface.
1329 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1330 dnl # is 2.6.30 as of when this was written.
1332 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1333 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1334 SPL_LINUX_TRY_COMPILE([
1335 #include <linux/mm.h>
1337 enum zone_stat_item zsi __attribute__ ((unused));
1338 zsi = NR_FREE_PAGES;
1341 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1342 [Page state NR_FREE_PAGES is available])
1349 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1350 dnl # Public global zone stats now include an inactive page count. However
1351 dnl # the enumerated names of the counters have changed since this API
1352 dnl # was introduced. We need to deduce the corrent name to use. This
1353 dnl # replaces the priviate get_zone_counts() interface.
1355 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1356 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1357 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1359 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1360 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1361 SPL_LINUX_TRY_COMPILE([
1362 #include <linux/mm.h>
1364 enum zone_stat_item zsi __attribute__ ((unused));
1368 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1369 [Page state NR_INACTIVE is available])
1374 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1375 SPL_LINUX_TRY_COMPILE([
1376 #include <linux/mm.h>
1378 enum zone_stat_item zsi __attribute__ ((unused));
1379 zsi = NR_INACTIVE_ANON;
1382 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1383 [Page state NR_INACTIVE_ANON is available])
1388 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1389 SPL_LINUX_TRY_COMPILE([
1390 #include <linux/mm.h>
1392 enum zone_stat_item zsi __attribute__ ((unused));
1393 zsi = NR_INACTIVE_FILE;
1396 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1397 [Page state NR_INACTIVE_FILE is available])
1404 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1405 dnl # Public global zone stats now include an active page count. However
1406 dnl # the enumerated names of the counters have changed since this API
1407 dnl # was introduced. We need to deduce the corrent name to use. This
1408 dnl # replaces the priviate get_zone_counts() interface.
1410 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1411 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1412 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1414 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1415 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1416 SPL_LINUX_TRY_COMPILE([
1417 #include <linux/mm.h>
1419 enum zone_stat_item zsi __attribute__ ((unused));
1423 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1424 [Page state NR_ACTIVE is available])
1429 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1430 SPL_LINUX_TRY_COMPILE([
1431 #include <linux/mm.h>
1433 enum zone_stat_item zsi __attribute__ ((unused));
1434 zsi = NR_ACTIVE_ANON;
1437 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1438 [Page state NR_ACTIVE_ANON is available])
1443 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1444 SPL_LINUX_TRY_COMPILE([
1445 #include <linux/mm.h>
1447 enum zone_stat_item zsi __attribute__ ((unused));
1448 zsi = NR_ACTIVE_FILE;
1451 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1452 [Page state NR_ACTIVE_FILE is available])
1459 dnl # Proposed API change for legacy kernels.
1460 dnl # This symbol is not available in older kernels. For kernels post
1461 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1462 dnl # page state information. This symbol is only used in legacy kernels
1463 dnl # any only as a last resort.
1465 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1466 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1467 SPL_LINUX_TRY_COMPILE([
1469 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1470 #error "global_page_state needs NR_FREE_PAGES"
1473 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1474 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1475 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1476 #error "global_page_state needs NR_ACTIVE*"
1479 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1480 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1481 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1482 #error "global_page_state needs NR_INACTIVE*"
1488 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1489 [get_zone_counts() is needed])
1491 SPL_CHECK_SYMBOL_EXPORT(
1494 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1495 [get_zone_counts() is available])],
1501 dnl # 2.6.27 API change,
1502 dnl # The user_path_dir() replaces __user_walk()
1504 AC_DEFUN([SPL_AC_USER_PATH_DIR], [
1505 SPL_CHECK_SYMBOL_EXPORT(
1508 [AC_DEFINE(HAVE_USER_PATH_DIR, 1,
1509 [user_path_dir() is available])],
1514 dnl # Symbol available in RHEL kernels not in stock kernels.
1516 AC_DEFUN([SPL_AC_SET_FS_PWD], [
1517 SPL_CHECK_SYMBOL_EXPORT(
1520 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1521 [set_fs_pwd() is available])],
1526 dnl # 2.6.25 API change,
1527 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1529 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1530 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1531 SPL_LINUX_TRY_COMPILE([
1532 #include <linux/sched.h>
1533 #include <linux/fs_struct.h>
1535 set_fs_pwd(NULL, NULL);
1538 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1539 [set_fs_pwd() wants 2 args])
1546 dnl # SLES API change, never adopted in mainline,
1547 dnl # Third 'struct vfsmount *' argument removed.
1549 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1550 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1551 SPL_LINUX_TRY_COMPILE([
1552 #include <linux/fs.h>
1554 vfs_unlink(NULL, NULL);
1557 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1558 [vfs_unlink() wants 2 args])
1565 dnl # SLES API change, never adopted in mainline,
1566 dnl # Third and sixth 'struct vfsmount *' argument removed.
1568 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1569 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1570 SPL_LINUX_TRY_COMPILE([
1571 #include <linux/fs.h>
1573 vfs_rename(NULL, NULL, NULL, NULL);
1576 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1577 [vfs_rename() wants 4 args])
1584 dnl # 2.6.36 API change,
1585 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1586 dnl # a spinlock_t to improve the fastpath performance.
1588 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1589 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1590 SPL_LINUX_TRY_COMPILE([
1591 #include <linux/sched.h>
1592 #include <linux/fs_struct.h>
1594 struct fs_struct fs;
1595 spin_lock_init(&fs.lock);
1598 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1599 [struct fs_struct uses spinlock_t])
1606 dnl # 2.6.29 API change,
1607 dnl # check whether 'struct cred' exists
1609 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1610 AC_MSG_CHECKING([whether struct cred exists])
1611 SPL_LINUX_TRY_COMPILE([
1612 #include <linux/cred.h>
1614 struct cred *cr __attribute__ ((unused));
1618 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1625 dnl # Custom SPL patch may export this symbol.
1627 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1628 SPL_CHECK_SYMBOL_EXPORT(
1631 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1632 [groups_search() is available])],
1637 dnl # 2.6.x API change,
1638 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1640 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1641 SPL_CHECK_SYMBOL_EXPORT(
1642 [__put_task_struct],
1644 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1645 [__put_task_struct() is available])],
1650 dnl # 2.6.32 API change,
1651 dnl # Unused 'struct file *' removed from prototype.
1653 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1654 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1655 SPL_LINUX_TRY_COMPILE([
1656 #include <linux/sysctl.h>
1658 proc_dostring(NULL, 0, NULL, NULL, NULL);
1661 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1662 [proc_handler() wants 5 args])
1669 dnl # 2.6.x API change,
1670 dnl # kvasprintf() function added.
1672 AC_DEFUN([SPL_AC_KVASPRINTF], [
1673 SPL_CHECK_SYMBOL_EXPORT(
1676 [AC_DEFINE(HAVE_KVASPRINTF, 1,
1677 [kvasprintf() is available])],
1682 dnl # 2.6.35 API change,
1683 dnl # Unused 'struct dentry *' removed from prototype.
1685 AC_DEFUN([SPL_AC_3ARGS_FILE_FSYNC], [
1686 AC_MSG_CHECKING([whether file_fsync() wants 3 args])
1687 SPL_LINUX_TRY_COMPILE([
1688 #include <linux/buffer_head.h>
1690 file_fsync(NULL, NULL, 0);
1693 AC_DEFINE(HAVE_3ARGS_FILE_FSYNC, 1,
1694 [file_fsync() wants 3 args])
1701 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
1702 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
1703 dnl # condition. The fixed version is exported as a symbol. The race
1704 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
1705 dnl # call that version while holding sem->wait_lock.
1707 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED], [
1708 SPL_CHECK_SYMBOL_EXPORT(
1710 [lib/rwsem-spinlock.c],
1711 [AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
1712 [rwsem_is_locked() acquires sem->wait_lock])],
1717 dnl # 2.6.37 API compat,
1718 dnl # The function invalidate_inodes() is no longer exported by the kernel.
1719 dnl # The prototype however is still available which means it is safe
1720 dnl # to acquire the symbol's address using spl_kallsyms_lookup_name().
1722 AC_DEFUN([SPL_AC_KERNEL_INVALIDATE_INODES], [
1723 SPL_CHECK_SYMBOL_EXPORT(
1724 [invalidate_inodes],
1726 [AC_DEFINE(HAVE_INVALIDATE_INODES, 1,
1727 [invalidate_inodes() is available])],
1732 dnl # 2.6.39 API compat,
1733 dnl # The function invalidate_inodes() now take 2 arguments. The second
1734 dnl # 'kill_dirty' argument describes how invalidate_inodes() should
1735 dnl # handle dirty inodes. Only when set will dirty inodes be discarded,
1736 dnl # otherwise they will be handled as busy.
1738 dnl # Unfortunately, we don't have access to the invalidate_inodes()
1739 dnl # prototype so it's not easy to check how many arguments it takes.
1740 dnl # However, this change was done for the benefit of invalidate_device()
1741 dnl # which also added an argument. The invalidate_device() symbol does
1742 dnl # exist in the development headers so if it takes two arguments we
1743 dnl # can fairly safely infer that invalidate_inodes() takes two arguments
1744 dnl # as well. See commit 93b270f76e7ef3b81001576860c2701931cdc78b.
1746 AC_DEFUN([SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES],
1747 [AC_MSG_CHECKING([whether invalidate_inodes() wants 2 args])
1748 SPL_LINUX_TRY_COMPILE([
1749 #include <linux/fs.h>
1751 return __invalidate_device(NULL, 0);
1754 AC_DEFINE(HAVE_2ARGS_INVALIDATE_INODES, 1,
1755 [invalidate_inodes() wants 2 args])
1762 dnl # 2.6.xx API compat,
1763 dnl # There currently exists no exposed API to partially shrink the dcache.
1764 dnl # The expected mechanism to shrink the cache is a registered shrinker
1765 dnl # which is called during memory pressure.
1767 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY], [
1768 SPL_CHECK_SYMBOL_EXPORT(
1769 [shrink_dcache_memory],
1771 [AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
1772 [shrink_dcache_memory() is available])],
1777 dnl # 2.6.xx API compat,
1778 dnl # There currently exists no exposed API to partially shrink the icache.
1779 dnl # The expected mechanism to shrink the cache is a registered shrinker
1780 dnl # which is called during memory pressure.
1782 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY], [
1783 SPL_CHECK_SYMBOL_EXPORT(
1784 [shrink_icache_memory],
1786 [AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
1787 [shrink_icache_memory() is available])],
1792 dnl # 2.6.39 API compat,
1793 dnl # The path_lookup() function has been renamed to kern_path_parent()
1794 dnl # and the flags argument has been removed. The only behavior now
1795 dnl # offered is that of LOOKUP_PARENT. The spl already always passed
1796 dnl # this flag so dropping the flag does not impact us.
1798 AC_DEFUN([SPL_AC_KERN_PATH_PARENT], [
1799 SPL_CHECK_SYMBOL_EXPORT(
1802 [AC_DEFINE(HAVE_KERN_PATH_PARENT, 1,
1803 [kern_path_parent() is available])],
1808 dnl # 2.6.39 API compat,
1809 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
1810 dnl # This was done to avoid always having to allocate the maximum size
1811 dnl # workspace (268K). The caller can now specific the windowBits and
1812 dnl # memLevel compression parameters to get a smaller workspace.
1814 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
1815 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
1816 SPL_LINUX_TRY_COMPILE([
1817 #include <linux/zlib.h>
1819 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
1822 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
1823 [zlib_deflate_workspacesize() wants 2 args])