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
85 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
86 modpost=$LINUX/scripts/Makefile.modpost
87 AC_MSG_CHECKING([kernel file name for module symbols])
88 if test -f "$modpost"; then
89 if grep -q Modules.symvers $modpost; then
90 LINUX_SYMBOLS=Modules.symvers
92 LINUX_SYMBOLS=Module.symvers
95 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
97 *** Please make sure the kernel devel package for your distribution
98 *** is installed. If your building with a custom kernel make sure the
99 *** kernel is configured, built, and the '--with-linux=PATH' configure
100 *** option refers to the location of the kernel source.])
105 AC_MSG_RESULT($LINUX_SYMBOLS)
106 AC_SUBST(LINUX_SYMBOLS)
109 AC_DEFUN([SPL_AC_KERNEL], [
111 AS_HELP_STRING([--with-linux=PATH],
112 [Path to kernel source]),
113 [kernelsrc="$withval"])
115 AC_ARG_WITH([linux-obj],
116 AS_HELP_STRING([--with-linux-obj=PATH],
117 [Path to kernel build objects]),
118 [kernelbuild="$withval"])
120 AC_MSG_CHECKING([kernel source directory])
121 if test -z "$kernelsrc"; then
122 if test -e "/lib/modules/$(uname -r)/source"; then
123 headersdir="/lib/modules/$(uname -r)/source"
124 sourcelink=$(readlink -f "$headersdir")
125 elif test -e "/lib/modules/$(uname -r)/build"; then
126 headersdir="/lib/modules/$(uname -r)/build"
127 sourcelink=$(readlink -f "$headersdir")
129 sourcelink=$(ls -1d /usr/src/kernels/* \
131 2>/dev/null | grep -v obj | tail -1)
134 if test -n "$sourcelink" && test -e ${sourcelink}; then
135 kernelsrc=`readlink -f ${sourcelink}`
137 AC_MSG_RESULT([Not found])
139 *** Please make sure the kernel devel package for your distribution
140 *** is installed then try again. If that fails you can specify the
141 *** location of the kernel source with the '--with-linux=PATH' option.])
144 if test "$kernelsrc" = "NONE"; then
149 AC_MSG_RESULT([$kernelsrc])
150 AC_MSG_CHECKING([kernel build directory])
151 if test -z "$kernelbuild"; then
152 if test -e "/lib/modules/$(uname -r)/build"; then
153 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
154 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
155 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
156 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
157 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
158 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
159 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
161 kernelbuild=${kernelsrc}
164 AC_MSG_RESULT([$kernelbuild])
166 AC_MSG_CHECKING([kernel source version])
167 utsrelease1=$kernelbuild/include/linux/version.h
168 utsrelease2=$kernelbuild/include/linux/utsrelease.h
169 utsrelease3=$kernelbuild/include/generated/utsrelease.h
170 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
171 utsrelease=linux/version.h
172 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
173 utsrelease=linux/utsrelease.h
174 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
175 utsrelease=generated/utsrelease.h
178 if test "$utsrelease"; then
179 kernsrcver=`(echo "#include <$utsrelease>";
180 echo "kernsrcver=UTS_RELEASE") |
181 cpp -I $kernelbuild/include |
182 grep "^kernsrcver=" | cut -d \" -f 2`
184 if test -z "$kernsrcver"; then
185 AC_MSG_RESULT([Not found])
186 AC_MSG_ERROR([*** Cannot determine kernel version.])
189 AC_MSG_RESULT([Not found])
190 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
193 AC_MSG_RESULT([$kernsrcver])
196 LINUX_OBJ=${kernelbuild}
197 LINUX_VERSION=${kernsrcver}
201 AC_SUBST(LINUX_VERSION)
203 SPL_AC_MODULE_SYMVERS
206 AC_DEFUN([SPL_AC_KERNEL_CONFIG], [
207 SPL_LINUX_CONFIG([PREEMPT],
209 *** Kernel built with CONFIG_PREEMPT which is not supported.
210 ** You must rebuild your kernel without this option.]), [])
214 dnl # Explicitly check for gawk, we require it for the the usermode
215 dnl # helper. For some reason the standard awk command does not
216 dnl # behave correctly when invoked from the usermode helper.
218 AC_DEFUN([SPL_AC_GAWK], [
219 AS_IF([test "x$AWK" != xgawk], [
221 *** Required util gawk missing. Please install the required
222 *** gawk package for your distribution and try again.])
227 dnl # Default SPL user configuration
229 AC_DEFUN([SPL_AC_CONFIG_USER], [
234 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
235 dnl # are missing it is non-fatal but you will not be able to build
236 dnl # RPM packages and will be warned if you try too.
238 AC_DEFUN([SPL_AC_RPM], [
242 AC_MSG_CHECKING([whether $RPM is available])
243 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
244 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
246 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
249 AC_MSG_RESULT([$HAVE_RPM])
252 AC_MSG_CHECKING([whether $RPMBUILD is available])
253 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
254 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
256 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
259 AC_MSG_RESULT([$HAVE_RPMBUILD])
264 AC_SUBST(RPM_VERSION)
266 AC_SUBST(HAVE_RPMBUILD)
268 AC_SUBST(RPMBUILD_VERSION)
272 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
273 dnl # tools are missing it is non-fatal but you will not be able to build
274 dnl # DEB packages and will be warned if you try too.
276 AC_DEFUN([SPL_AC_DPKG], [
278 DPKGBUILD=dpkg-buildpackage
280 AC_MSG_CHECKING([whether $DPKG is available])
281 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
282 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
284 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
287 AC_MSG_RESULT([$HAVE_DPKG])
290 AC_MSG_CHECKING([whether $DPKGBUILD is available])
291 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
292 DPKGBUILD_VERSION=$(echo $tmp | \
293 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
295 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
298 AC_MSG_RESULT([$HAVE_DPKGBUILD])
303 AC_SUBST(DPKG_VERSION)
305 AC_SUBST(HAVE_DPKGBUILD)
307 AC_SUBST(DPKGBUILD_VERSION)
311 dnl # Until native packaging for various different packing systems
312 dnl # can be added the least we can do is attempt to use alien to
313 dnl # convert the RPM packages to the needed package type. This is
314 dnl # a hack but so far it has worked reasonable well.
316 AC_DEFUN([SPL_AC_ALIEN], [
319 AC_MSG_CHECKING([whether $ALIEN is available])
320 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
321 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
323 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
326 AC_MSG_RESULT([$HAVE_ALIEN])
331 AC_SUBST(ALIEN_VERSION)
335 dnl # Using the VENDOR tag from config.guess set the default
336 dnl # package type for 'make pkg': (rpm | deb | tgz)
338 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
339 AC_MSG_CHECKING([linux distribution])
340 if test -f /etc/redhat-release ; then
342 elif test -f /etc/fedora-release ; then
344 elif test -f /etc/lsb-release ; then
346 elif test -f /etc/debian_version ; then
348 elif test -f /etc/SuSE-release ; then
350 elif test -f /etc/slackware-version ; then
352 elif test -f /etc/gentoo-release ; then
357 AC_MSG_RESULT([$VENDOR])
360 AC_MSG_CHECKING([default package type])
362 fedora) DEFAULT_PACKAGE=rpm ;;
363 redhat) DEFAULT_PACKAGE=rpm ;;
364 sles) DEFAULT_PACKAGE=rpm ;;
365 ubuntu) DEFAULT_PACKAGE=deb ;;
366 debian) DEFAULT_PACKAGE=deb ;;
367 slackware) DEFAULT_PACKAGE=tgz ;;
368 *) DEFAULT_PACKAGE=rpm ;;
371 AC_MSG_RESULT([$DEFAULT_PACKAGE])
372 AC_SUBST(DEFAULT_PACKAGE)
376 dnl # Default SPL user configuration
378 AC_DEFUN([SPL_AC_PACKAGE], [
382 SPL_AC_DEFAULT_PACKAGE
385 AC_DEFUN([SPL_AC_LICENSE], [
386 AC_MSG_CHECKING([spl license])
388 AC_MSG_RESULT([$LICENSE])
389 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
393 AC_DEFUN([SPL_AC_CONFIG], [
395 AC_ARG_WITH([config],
396 AS_HELP_STRING([--with-config=CONFIG],
397 [Config file 'kernel|user|all|srpm']),
398 [SPL_CONFIG="$withval"])
400 AC_MSG_CHECKING([spl config])
401 AC_MSG_RESULT([$SPL_CONFIG]);
404 case "$SPL_CONFIG" in
405 kernel) SPL_AC_CONFIG_KERNEL ;;
406 user) SPL_AC_CONFIG_USER ;;
407 all) SPL_AC_CONFIG_KERNEL
408 SPL_AC_CONFIG_USER ;;
411 AC_MSG_RESULT([Error!])
412 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
413 user kernel|user|all|srpm]) ;;
416 AM_CONDITIONAL([CONFIG_USER],
417 [test "$SPL_CONFIG" = user] ||
418 [test "$SPL_CONFIG" = all])
419 AM_CONDITIONAL([CONFIG_KERNEL],
420 [test "$SPL_CONFIG" = kernel] ||
421 [test "$SPL_CONFIG" = all])
425 dnl # Enable if the SPL should be compiled with internal debugging enabled.
426 dnl # By default this support is disabled.
428 AC_DEFUN([SPL_AC_DEBUG], [
429 AC_MSG_CHECKING([whether debugging is enabled])
430 AC_ARG_ENABLE([debug],
431 [AS_HELP_STRING([--enable-debug],
432 [Enable generic debug support @<:@default=no@:>@])],
436 AS_IF([test "x$enable_debug" = xyes],
438 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
439 DEBUG_CFLAGS="-DDEBUG -Werror"
442 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
443 DEBUG_CFLAGS="-DNDEBUG"
446 AC_SUBST(DEBUG_CFLAGS)
447 AC_MSG_RESULT([$enable_debug])
451 dnl # Enabled by default it provides a minimal level of memory tracking.
452 dnl # A total count of bytes allocated is kept for each alloc and free.
453 dnl # Then at module unload time a report to the console will be printed
454 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
455 dnl # and provide an easy way to inspect the kmem based slab.
457 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
458 AC_ARG_ENABLE([debug-kmem],
459 [AS_HELP_STRING([--enable-debug-kmem],
460 [Enable basic kmem accounting @<:@default=yes@:>@])],
462 [enable_debug_kmem=yes])
464 AS_IF([test "x$enable_debug_kmem" = xyes],
465 [AC_DEFINE([DEBUG_KMEM], [1],
466 [Define to 1 to enable basic kmem accounting])
467 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"])
469 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
470 AC_MSG_RESULT([$enable_debug_kmem])
474 dnl # Disabled by default it provides detailed memory tracking. This
475 dnl # feature also requires --enable-debug-kmem to be set. When enabled
476 dnl # not only will total bytes be tracked but also the location of every
477 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
478 dnl # addresses and where they were allocated will be dumped to the console.
479 dnl # Enabling this feature has a significant impact on performance but it
480 dnl # makes finding memory leaks pretty straight forward.
482 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
483 AC_ARG_ENABLE([debug-kmem-tracking],
484 [AS_HELP_STRING([--enable-debug-kmem-tracking],
485 [Enable detailed kmem tracking @<:@default=no@:>@])],
487 [enable_debug_kmem_tracking=no])
489 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
490 [AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
491 [Define to 1 to enable detailed kmem tracking])
492 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"])
494 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
495 AC_MSG_RESULT([$enable_debug_kmem_tracking])
499 dnl # SPL_LINUX_CONFTEST
501 AC_DEFUN([SPL_LINUX_CONFTEST], [
502 cat confdefs.h - <<_ACEOF >conftest.c
508 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
510 m4_define([SPL_LANG_PROGRAM], [
515 dnl Do *not* indent the following line: there may be CPP directives.
516 dnl Don't move the `;' right after for the same reason.
524 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
526 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
527 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
528 rm -Rf build && mkdir -p build
529 echo "obj-m := conftest.o" >build/Makefile
531 [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])],
533 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
539 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
541 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
542 [SPL_LINUX_COMPILE_IFELSE(
543 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
545 [test -s build/conftest.o],
550 dnl # SPL_LINUX_CONFIG
552 AC_DEFUN([SPL_LINUX_CONFIG],
553 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
554 SPL_LINUX_TRY_COMPILE([
555 #ifndef AUTOCONF_INCLUDED
556 #include <linux/config.h>
560 #error CONFIG_$1 not #defined
572 dnl # SPL_CHECK_SYMBOL_EXPORT
573 dnl # check symbol exported or not
575 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
576 [AC_MSG_CHECKING([whether symbol $1 is exported])
577 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
578 $LINUX_OBJ/Module*.symvers 2>/dev/null
580 if test $rc -ne 0; then
583 grep -q -E "EXPORT_SYMBOL.*($1)" \
584 "$LINUX_OBJ/$file" 2>/dev/null
586 if test $rc -eq 0; then
591 if test $export -eq 0; then
605 dnl # SPL_CHECK_HEADER
606 dnl # check whether header exists and define HAVE_$2_HEADER
608 AC_DEFUN([SPL_CHECK_HEADER],
609 [AC_MSG_CHECKING([whether header $1 exists])
610 SPL_LINUX_TRY_COMPILE([
615 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
625 dnl # Use the atomic implemenation based on global spinlocks. This
626 dnl # should only be needed by 32-bit kernels which do not provide
627 dnl # the atomic64_* API. It may be optionally enabled as a fallback
628 dnl # if problems are observed with the direct mapping to the native
629 dnl # Linux atomic operations. You may not disable atomic spinlocks
630 dnl # if you kernel does not an atomic64_* API.
632 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
633 AC_ARG_ENABLE([atomic-spinlocks],
634 [AS_HELP_STRING([--enable-atomic-spinlocks],
635 [Atomic types use spinlocks @<:@default=check@:>@])],
637 [enable_atomic_spinlocks=check])
639 SPL_LINUX_TRY_COMPILE([
640 #include <asm/atomic.h>
642 atomic64_t *ptr __attribute__ ((unused));
645 AC_DEFINE(HAVE_ATOMIC64_T, 1,
646 [kernel defines atomic64_t])
651 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
652 AS_IF([test "x$have_atomic64_t" = xyes], [
653 enable_atomic_spinlocks=no
655 enable_atomic_spinlocks=yes
659 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
660 AC_DEFINE([ATOMIC_SPINLOCK], [1],
661 [Atomic types use spinlocks])
663 AS_IF([test "x$have_atomic64_t" = xno], [
665 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
669 AC_MSG_CHECKING([whether atomic types use spinlocks])
670 AC_MSG_RESULT([$enable_atomic_spinlocks])
672 AC_MSG_CHECKING([whether kernel defines atomic64_t])
673 AC_MSG_RESULT([$have_atomic64_t])
677 dnl # 2.6.24 API change,
678 dnl # check if atomic64_cmpxchg is defined
680 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
681 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
682 SPL_LINUX_TRY_COMPILE([
683 #include <asm/atomic.h>
684 #include <asm/system.h>
686 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
689 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
690 [kernel defines atomic64_cmpxchg])
697 dnl # 2.6.24 API change,
698 dnl # check if atomic64_xchg is defined
700 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
701 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
702 SPL_LINUX_TRY_COMPILE([
703 #include <asm/atomic.h>
705 atomic64_xchg((atomic64_t *)NULL, 0);
708 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
709 [kernel defines atomic64_xchg])
716 dnl # 2.6.24 API change,
717 dnl # check if uintptr_t typedef is defined
719 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
720 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
721 SPL_LINUX_TRY_COMPILE([
722 #include <linux/types.h>
724 uintptr_t *ptr __attribute__ ((unused));
727 AC_DEFINE(HAVE_UINTPTR_T, 1,
728 [kernel defines uintptr_t])
735 dnl # 2.6.20 API change,
736 dnl # INIT_WORK use 2 args and not store data inside
738 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
739 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
740 SPL_LINUX_TRY_COMPILE([
741 #include <linux/workqueue.h>
743 struct work_struct work __attribute__ ((unused));
744 INIT_WORK(&work, NULL, NULL);
747 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
748 [INIT_WORK wants 3 args])
755 dnl # 2.6.21 API change,
756 dnl # 'register_sysctl_table' use only one argument instead of two
758 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
759 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
760 SPL_LINUX_TRY_COMPILE([
761 #include <linux/sysctl.h>
763 (void) register_sysctl_table(NULL, 0);
766 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
767 [register_sysctl_table() wants 2 args])
774 dnl # 2.6.23 API change
775 dnl # Old set_shrinker API replaced with register_shrinker
777 AC_DEFUN([SPL_AC_SET_SHRINKER], [
778 AC_MSG_CHECKING([whether set_shrinker() available])
779 SPL_LINUX_TRY_COMPILE([
780 #include <linux/mm.h>
782 return set_shrinker(DEFAULT_SEEKS, NULL);
785 AC_DEFINE(HAVE_SET_SHRINKER, 1,
786 [set_shrinker() available])
793 dnl # 2.6.35 API change,
794 dnl # Add context to shrinker callback
796 AC_DEFUN([SPL_AC_3ARGS_SHRINKER_CALLBACK],
797 [AC_MSG_CHECKING([whether shrinker callback wants 3 args])
798 tmp_flags="$EXTRA_KCFLAGS"
799 EXTRA_KCFLAGS="-Werror"
800 SPL_LINUX_TRY_COMPILE([
801 #include <linux/mm.h>
803 int shrinker_cb(struct shrinker *, int, unsigned int);
805 struct shrinker cache_shrinker = {
806 .shrink = shrinker_cb,
807 .seeks = DEFAULT_SEEKS,
809 register_shrinker(&cache_shrinker);
812 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
813 [shrinker callback wants 3 args])
817 EXTRA_KCFLAGS="$tmp_flags"
821 dnl # 2.6.25 API change,
822 dnl # struct path entry added to struct nameidata
824 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
825 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
826 SPL_LINUX_TRY_COMPILE([
827 #include <linux/namei.h>
829 struct nameidata nd __attribute__ ((unused));
832 nd.path.dentry = NULL;
835 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
836 [struct path used in struct nameidata])
843 dnl # Custom SPL patch may export this system it is not required
845 AC_DEFUN([SPL_AC_TASK_CURR], [
846 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
847 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
852 dnl # 2.6.19 API change,
853 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
855 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
856 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
857 SPL_LINUX_TRY_COMPILE([
858 #include <linux/sysctl.h>
860 #ifndef CTL_UNNUMBERED
861 #error CTL_UNNUMBERED undefined
865 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
866 [unnumbered sysctl support exists])
873 dnl # 2.6.33 API change,
874 dnl # Removed .ctl_name from struct ctl_table.
876 AC_DEFUN([SPL_AC_CTL_NAME], [
877 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
878 SPL_LINUX_TRY_COMPILE([
879 #include <linux/sysctl.h>
881 struct ctl_table ctl __attribute__ ((unused));
885 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
892 dnl # 2.6.16 API change.
893 dnl # Check if 'fls64()' is available
895 AC_DEFUN([SPL_AC_FLS64],
896 [AC_MSG_CHECKING([whether fls64() is available])
897 SPL_LINUX_TRY_COMPILE([
898 #include <linux/bitops.h>
903 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
910 dnl # 2.6.18 API change, check whether device_create() is available.
911 dnl # Device_create() was introduced in 2.6.18 and depricated
912 dnl # class_device_create() which was fully removed in 2.6.26.
914 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
915 SPL_CHECK_SYMBOL_EXPORT(
917 [drivers/base/core.c],
918 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
919 [device_create() is available])],
924 dnl # 2.6.27 API change,
925 dnl # device_create() uses 5 args, new 'drvdata' argument.
927 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
928 AC_MSG_CHECKING([whether device_create() wants 5 args])
929 tmp_flags="$EXTRA_KCFLAGS"
930 EXTRA_KCFLAGS="-Werror"
931 SPL_LINUX_TRY_COMPILE([
932 #include <linux/device.h>
934 device_create(NULL, NULL, 0, NULL, "%d", 1);
937 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
938 [device_create wants 5 args])
942 EXTRA_KCFLAGS="$tmp_flags"
946 dnl # 2.6.13 API change, check whether class_device_create() is available.
947 dnl # Class_device_create() was introduced in 2.6.13 and depricated
948 dnl # class_simple_device_add() which was fully removed in 2.6.13.
950 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
951 SPL_CHECK_SYMBOL_EXPORT(
952 [class_device_create],
953 [drivers/base/class.c],
954 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
955 [class_device_create() is available])],
960 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
962 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
963 SPL_CHECK_SYMBOL_EXPORT(
964 [set_normalized_timespec],
966 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
967 [set_normalized_timespec() is available as export])],
972 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
973 dnl # previously it was available in time.h as an inline.
975 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
976 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
977 SPL_LINUX_TRY_COMPILE([
978 #include <linux/time.h>
979 void set_normalized_timespec(struct timespec *ts,
980 time_t sec, long nsec) { }
987 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
988 [set_normalized_timespec() is available as inline])
993 dnl # 2.6.18 API change,
994 dnl # timespec_sub() inline function available in linux/time.h
996 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
997 AC_MSG_CHECKING([whether timespec_sub() is available])
998 SPL_LINUX_TRY_COMPILE([
999 #include <linux/time.h>
1001 struct timespec a = { 0 };
1002 struct timespec b = { 0 };
1003 struct timespec c __attribute__ ((unused));
1004 c = timespec_sub(a, b);
1007 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1014 dnl # 2.6.19 API change,
1015 dnl # check if init_utsname() is available in linux/utsname.h
1017 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
1018 AC_MSG_CHECKING([whether init_utsname() is available])
1019 SPL_LINUX_TRY_COMPILE([
1020 #include <linux/utsname.h>
1022 struct new_utsname *a __attribute__ ((unused));
1026 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1033 dnl # 2.6.26 API change,
1034 dnl # definition of struct fdtable relocated to linux/fdtable.h
1036 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
1037 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
1041 dnl # 2.6.14 API change,
1042 dnl # check whether 'files_fdtable()' exists
1044 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
1045 AC_MSG_CHECKING([whether files_fdtable() is available])
1046 SPL_LINUX_TRY_COMPILE([
1047 #include <linux/sched.h>
1048 #include <linux/file.h>
1049 #ifdef HAVE_FDTABLE_HEADER
1050 #include <linux/fdtable.h>
1053 struct files_struct *files = current->files;
1054 struct fdtable *fdt __attribute__ ((unused));
1055 fdt = files_fdtable(files);
1058 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
1065 dnl # 2.6.18 API change,
1066 dnl # added linux/uaccess.h
1068 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1069 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1073 dnl # 2.6.12 API change,
1074 dnl # check whether 'kmalloc_node()' is available.
1076 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1077 AC_MSG_CHECKING([whether kmalloc_node() is available])
1078 SPL_LINUX_TRY_COMPILE([
1079 #include <linux/slab.h>
1081 void *a __attribute__ ((unused));
1082 a = kmalloc_node(1, GFP_KERNEL, 0);
1085 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1092 dnl # 2.6.9 API change,
1093 dnl # check whether 'monotonic_clock()' is available it may
1094 dnl # be available for some archs but not others.
1096 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
1097 SPL_CHECK_SYMBOL_EXPORT(
1100 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1101 [monotonic_clock() is available])],
1106 dnl # 2.6.16 API change,
1107 dnl # check whether 'struct inode' has i_mutex
1109 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1110 AC_MSG_CHECKING([whether struct inode has i_mutex])
1111 SPL_LINUX_TRY_COMPILE([
1112 #include <linux/fs.h>
1113 #include <linux/mutex.h>
1116 mutex_init(&i.i_mutex);
1119 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1126 dnl # 2.6.29 API change,
1127 dnl # Adaptive mutexs introduced.
1129 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1130 AC_MSG_CHECKING([whether struct mutex has owner])
1131 SPL_LINUX_TRY_COMPILE([
1132 #include <linux/mutex.h>
1134 struct mutex mtx __attribute__ ((unused));
1138 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1145 dnl # 2.6.18 API change,
1146 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1147 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1148 dnl # if the mutex validator is disabled or otherwise unavailable.
1150 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1151 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1152 SPL_LINUX_TRY_COMPILE([
1153 #include <linux/mutex.h>
1157 mutex_lock_nested(&mutex, 0);
1160 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1161 [mutex_lock_nested() is available])
1168 dnl # 2.6.27 API change,
1169 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1171 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1172 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1173 SPL_LINUX_TRY_COMPILE([
1174 #include <linux/smp.h>
1176 on_each_cpu(NULL, NULL, 0);
1179 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1180 [on_each_cpu wants 3 args])
1187 dnl # 2.6.18 API change,
1188 dnl # kallsyms_lookup_name no longer exported
1190 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
1191 SPL_CHECK_SYMBOL_EXPORT(
1192 [kallsyms_lookup_name],
1194 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1195 [kallsyms_lookup_name() is available])],
1200 dnl # Proposed API change,
1201 dnl # This symbol is not available in stock kernels. You may build a
1202 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1203 dnl # these symbols for use. If your already rolling a custom kernel for
1204 dnl # your environment this is recommended.
1206 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
1207 SPL_CHECK_SYMBOL_EXPORT(
1210 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1211 [get_vmalloc_info() is available])],
1216 dnl # 2.6.17 API change
1217 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1218 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1219 dnl # were exported in 2.6.17 for use by modules which was consistent with
1220 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1221 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1222 dnl # were dropped entirely leaving modules no way to directly iterate over
1223 dnl # the zone list. Because we need access to the zone helpers we check
1224 dnl # if the kernel contains the old or new implementation. Then we check
1225 dnl # to see if the symbols we need for each version are available. If they
1226 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1228 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1229 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1230 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1232 if test $rc -eq 0; then
1233 AC_MSG_RESULT([yes])
1234 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1241 dnl # Proposed API change,
1242 dnl # This symbol is not available in stock kernels. You may build a
1243 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1244 dnl # these symbols for use. If your already rolling a custom kernel for
1245 dnl # your environment this is recommended.
1247 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
1248 SPL_CHECK_SYMBOL_EXPORT(
1249 [first_online_pgdat],
1251 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1252 [first_online_pgdat() is available])],
1257 dnl # Proposed API change,
1258 dnl # This symbol is not available in stock kernels. You may build a
1259 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1260 dnl # these symbols for use. If your already rolling a custom kernel for
1261 dnl # your environment this is recommended.
1263 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
1264 SPL_CHECK_SYMBOL_EXPORT(
1265 [next_online_pgdat],
1267 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1268 [next_online_pgdat() is available])],
1273 dnl # Proposed API change,
1274 dnl # This symbol is not available in stock kernels. You may build a
1275 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1276 dnl # these symbols for use. If your already rolling a custom kernel for
1277 dnl # your environment this is recommended.
1279 AC_DEFUN([SPL_AC_NEXT_ZONE], [
1280 SPL_CHECK_SYMBOL_EXPORT(
1283 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1284 [next_zone() is available])],
1289 dnl # 2.6.17 API change,
1290 dnl # See SPL_AC_PGDAT_HELPERS for details.
1292 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1293 SPL_CHECK_SYMBOL_EXPORT(
1296 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1297 [pgdat_list is available])],
1302 dnl # 2.6.18 API change,
1303 dnl # First introduced global_page_state() support as an inline.
1305 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1306 AC_MSG_CHECKING([whether global_page_state() is available])
1307 SPL_LINUX_TRY_COMPILE([
1308 #include <linux/mm.h>
1310 unsigned long state __attribute__ ((unused));
1311 state = global_page_state(0);
1314 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1315 [global_page_state() is available])
1322 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1323 dnl # Public global zone stats now include a free page count. However
1324 dnl # the enumerated names of the counters have changed since this API
1325 dnl # was introduced. We need to deduce the corrent name to use. This
1326 dnl # replaces the priviate get_zone_counts() interface.
1328 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1329 dnl # is 2.6.30 as of when this was written.
1331 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1332 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1333 SPL_LINUX_TRY_COMPILE([
1334 #include <linux/mm.h>
1336 enum zone_stat_item zsi __attribute__ ((unused));
1337 zsi = NR_FREE_PAGES;
1340 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1341 [Page state NR_FREE_PAGES is available])
1348 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1349 dnl # Public global zone stats now include an inactive page count. However
1350 dnl # the enumerated names of the counters have changed since this API
1351 dnl # was introduced. We need to deduce the corrent name to use. This
1352 dnl # replaces the priviate get_zone_counts() interface.
1354 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1355 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1356 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1358 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1359 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1360 SPL_LINUX_TRY_COMPILE([
1361 #include <linux/mm.h>
1363 enum zone_stat_item zsi __attribute__ ((unused));
1367 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1368 [Page state NR_INACTIVE is available])
1373 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1374 SPL_LINUX_TRY_COMPILE([
1375 #include <linux/mm.h>
1377 enum zone_stat_item zsi __attribute__ ((unused));
1378 zsi = NR_INACTIVE_ANON;
1381 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1382 [Page state NR_INACTIVE_ANON is available])
1387 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1388 SPL_LINUX_TRY_COMPILE([
1389 #include <linux/mm.h>
1391 enum zone_stat_item zsi __attribute__ ((unused));
1392 zsi = NR_INACTIVE_FILE;
1395 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1396 [Page state NR_INACTIVE_FILE is available])
1403 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1404 dnl # Public global zone stats now include an active page count. However
1405 dnl # the enumerated names of the counters have changed since this API
1406 dnl # was introduced. We need to deduce the corrent name to use. This
1407 dnl # replaces the priviate get_zone_counts() interface.
1409 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1410 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1411 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1413 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1414 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1415 SPL_LINUX_TRY_COMPILE([
1416 #include <linux/mm.h>
1418 enum zone_stat_item zsi __attribute__ ((unused));
1422 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1423 [Page state NR_ACTIVE is available])
1428 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1429 SPL_LINUX_TRY_COMPILE([
1430 #include <linux/mm.h>
1432 enum zone_stat_item zsi __attribute__ ((unused));
1433 zsi = NR_ACTIVE_ANON;
1436 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1437 [Page state NR_ACTIVE_ANON is available])
1442 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1443 SPL_LINUX_TRY_COMPILE([
1444 #include <linux/mm.h>
1446 enum zone_stat_item zsi __attribute__ ((unused));
1447 zsi = NR_ACTIVE_FILE;
1450 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1451 [Page state NR_ACTIVE_FILE is available])
1458 dnl # Proposed API change for legacy kernels.
1459 dnl # This symbol is not available in older kernels. For kernels post
1460 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1461 dnl # page state information. This symbol is only used in legacy kernels
1462 dnl # any only as a last resort.
1464 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1465 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1466 SPL_LINUX_TRY_COMPILE([
1468 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1469 #error "global_page_state needs NR_FREE_PAGES"
1472 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1473 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1474 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1475 #error "global_page_state needs NR_ACTIVE*"
1478 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1479 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1480 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1481 #error "global_page_state needs NR_INACTIVE*"
1487 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1488 [get_zone_counts() is needed])
1490 SPL_CHECK_SYMBOL_EXPORT(
1493 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1494 [get_zone_counts() is available])],
1500 dnl # 2.6.27 API change,
1501 dnl # The user_path_dir() replaces __user_walk()
1503 AC_DEFUN([SPL_AC_USER_PATH_DIR], [
1504 SPL_CHECK_SYMBOL_EXPORT(
1507 [AC_DEFINE(HAVE_USER_PATH_DIR, 1,
1508 [user_path_dir() is available])],
1513 dnl # Symbol available in RHEL kernels not in stock kernels.
1515 AC_DEFUN([SPL_AC_SET_FS_PWD], [
1516 SPL_CHECK_SYMBOL_EXPORT(
1519 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1520 [set_fs_pwd() is available])],
1525 dnl # 2.6.25 API change,
1526 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1528 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1529 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1530 SPL_LINUX_TRY_COMPILE([
1531 #include <linux/sched.h>
1532 #include <linux/fs_struct.h>
1534 set_fs_pwd(NULL, NULL);
1537 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1538 [set_fs_pwd() wants 2 args])
1545 dnl # SLES API change, never adopted in mainline,
1546 dnl # Third 'struct vfsmount *' argument removed.
1548 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1549 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1550 SPL_LINUX_TRY_COMPILE([
1551 #include <linux/fs.h>
1553 vfs_unlink(NULL, NULL);
1556 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1557 [vfs_unlink() wants 2 args])
1564 dnl # SLES API change, never adopted in mainline,
1565 dnl # Third and sixth 'struct vfsmount *' argument removed.
1567 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1568 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1569 SPL_LINUX_TRY_COMPILE([
1570 #include <linux/fs.h>
1572 vfs_rename(NULL, NULL, NULL, NULL);
1575 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1576 [vfs_rename() wants 4 args])
1583 dnl # 2.6.36 API change,
1584 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1585 dnl # a spinlock_t to improve the fastpath performance.
1587 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1588 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1589 SPL_LINUX_TRY_COMPILE([
1590 #include <linux/sched.h>
1591 #include <linux/fs_struct.h>
1593 struct fs_struct fs;
1594 spin_lock_init(&fs.lock);
1597 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1598 [struct fs_struct uses spinlock_t])
1605 dnl # 2.6.29 API change,
1606 dnl # check whether 'struct cred' exists
1608 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1609 AC_MSG_CHECKING([whether struct cred exists])
1610 SPL_LINUX_TRY_COMPILE([
1611 #include <linux/cred.h>
1613 struct cred *cr __attribute__ ((unused));
1617 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1624 dnl # Custom SPL patch may export this symbol.
1626 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1627 SPL_CHECK_SYMBOL_EXPORT(
1630 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1631 [groups_search() is available])],
1636 dnl # 2.6.x API change,
1637 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1639 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1640 SPL_CHECK_SYMBOL_EXPORT(
1641 [__put_task_struct],
1643 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1644 [__put_task_struct() is available])],
1649 dnl # 2.6.32 API change,
1650 dnl # Unused 'struct file *' removed from prototype.
1652 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1653 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1654 SPL_LINUX_TRY_COMPILE([
1655 #include <linux/sysctl.h>
1657 proc_dostring(NULL, 0, NULL, NULL, NULL);
1660 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1661 [proc_handler() wants 5 args])
1668 dnl # 2.6.x API change,
1669 dnl # kvasprintf() function added.
1671 AC_DEFUN([SPL_AC_KVASPRINTF], [
1672 SPL_CHECK_SYMBOL_EXPORT(
1675 [AC_DEFINE(HAVE_KVASPRINTF, 1,
1676 [kvasprintf() is available])],
1681 dnl # 2.6.35 API change,
1682 dnl # Unused 'struct dentry *' removed from prototype.
1684 AC_DEFUN([SPL_AC_3ARGS_FILE_FSYNC], [
1685 AC_MSG_CHECKING([whether file_fsync() wants 3 args])
1686 SPL_LINUX_TRY_COMPILE([
1687 #include <linux/buffer_head.h>
1689 file_fsync(NULL, NULL, 0);
1692 AC_DEFINE(HAVE_3ARGS_FILE_FSYNC, 1,
1693 [file_fsync() wants 3 args])
1700 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
1701 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
1702 dnl # condition. The fixed version is exported as a symbol. The race
1703 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
1704 dnl # call that version while holding sem->wait_lock.
1706 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED], [
1707 SPL_CHECK_SYMBOL_EXPORT(
1709 [lib/rwsem-spinlock.c],
1710 [AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
1711 [rwsem_is_locked() acquires sem->wait_lock])],
1716 dnl # 2.6.37 API compat,
1717 dnl # The function invalidate_inodes() is no longer exported by the kernel.
1718 dnl # The prototype however is still available which means it is safe
1719 dnl # to acquire the symbol's address using spl_kallsyms_lookup_name().
1721 AC_DEFUN([SPL_AC_KERNEL_INVALIDATE_INODES], [
1722 SPL_CHECK_SYMBOL_EXPORT(
1723 [invalidate_inodes],
1725 [AC_DEFINE(HAVE_INVALIDATE_INODES, 1,
1726 [invalidate_inodes() is available])],
1731 dnl # 2.6.39 API compat,
1732 dnl # The function invalidate_inodes() now take 2 arguments. The second
1733 dnl # 'kill_dirty' argument describes how invalidate_inodes() should
1734 dnl # handle dirty inodes. Only when set will dirty inodes be discarded,
1735 dnl # otherwise they will be handled as busy.
1737 dnl # Unfortunately, we don't have access to the invalidate_inodes()
1738 dnl # prototype so it's not easy to check how many arguments it takes.
1739 dnl # However, this change was done for the benefit of invalidate_device()
1740 dnl # which also added an argument. The invalidate_device() symbol does
1741 dnl # exist in the development headers so if it takes two arguments we
1742 dnl # can fairly safely infer that invalidate_inodes() takes two arguments
1743 dnl # as well. See commit 93b270f76e7ef3b81001576860c2701931cdc78b.
1745 AC_DEFUN([SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES],
1746 [AC_MSG_CHECKING([whether invalidate_inodes() wants 2 args])
1747 SPL_LINUX_TRY_COMPILE([
1748 #include <linux/fs.h>
1750 return __invalidate_device(NULL, 0);
1753 AC_DEFINE(HAVE_2ARGS_INVALIDATE_INODES, 1,
1754 [invalidate_inodes() wants 2 args])
1761 dnl # 2.6.xx API compat,
1762 dnl # There currently exists no exposed API to partially shrink the dcache.
1763 dnl # The expected mechanism to shrink the cache is a registered shrinker
1764 dnl # which is called during memory pressure.
1766 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY], [
1767 SPL_CHECK_SYMBOL_EXPORT(
1768 [shrink_dcache_memory],
1770 [AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
1771 [shrink_dcache_memory() is available])],
1776 dnl # 2.6.xx API compat,
1777 dnl # There currently exists no exposed API to partially shrink the icache.
1778 dnl # The expected mechanism to shrink the cache is a registered shrinker
1779 dnl # which is called during memory pressure.
1781 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY], [
1782 SPL_CHECK_SYMBOL_EXPORT(
1783 [shrink_icache_memory],
1785 [AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
1786 [shrink_icache_memory() is available])],
1791 dnl # 2.6.39 API compat,
1792 dnl # The path_lookup() function has been renamed to kern_path_parent()
1793 dnl # and the flags argument has been removed. The only behavior now
1794 dnl # offered is that of LOOKUP_PARENT. The spl already always passed
1795 dnl # this flag so dropping the flag does not impact us.
1797 AC_DEFUN([SPL_AC_KERN_PATH_PARENT], [
1798 SPL_CHECK_SYMBOL_EXPORT(
1801 [AC_DEFINE(HAVE_KERN_PATH_PARENT, 1,
1802 [kern_path_parent() is available])],