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
84 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
85 modpost=$LINUX/scripts/Makefile.modpost
86 AC_MSG_CHECKING([kernel file name for module symbols])
87 if test -f "$modpost"; then
88 if grep -q Modules.symvers $modpost; then
89 LINUX_SYMBOLS=Modules.symvers
91 LINUX_SYMBOLS=Module.symvers
94 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
96 *** Please make sure the kernel devel package for your distribution
97 *** is installed. If your building with a custom kernel make sure the
98 *** kernel is configured, built, and the '--with-linux=PATH' configure
99 *** option refers to the location of the kernel source.])
104 AC_MSG_RESULT($LINUX_SYMBOLS)
105 AC_SUBST(LINUX_SYMBOLS)
108 AC_DEFUN([SPL_AC_KERNEL], [
110 AS_HELP_STRING([--with-linux=PATH],
111 [Path to kernel source]),
112 [kernelsrc="$withval"])
114 AC_ARG_WITH([linux-obj],
115 AS_HELP_STRING([--with-linux-obj=PATH],
116 [Path to kernel build objects]),
117 [kernelbuild="$withval"])
119 AC_MSG_CHECKING([kernel source directory])
120 if test -z "$kernelsrc"; then
121 if test -e "/lib/modules/$(uname -r)/source"; then
122 headersdir="/lib/modules/$(uname -r)/source"
123 sourcelink=$(readlink -f "$headersdir")
124 elif test -e "/lib/modules/$(uname -r)/build"; then
125 headersdir="/lib/modules/$(uname -r)/build"
126 sourcelink=$(readlink -f "$headersdir")
128 sourcelink=$(ls -1d /usr/src/kernels/* \
130 2>/dev/null | grep -v obj | tail -1)
133 if test -n "$sourcelink" && test -e ${sourcelink}; then
134 kernelsrc=`readlink -f ${sourcelink}`
136 AC_MSG_RESULT([Not found])
138 *** Please make sure the kernel devel package for your distribution
139 *** is installed then try again. If that fails you can specify the
140 *** location of the kernel source with the '--with-linux=PATH' option.])
143 if test "$kernelsrc" = "NONE"; then
148 AC_MSG_RESULT([$kernelsrc])
149 AC_MSG_CHECKING([kernel build directory])
150 if test -z "$kernelbuild"; then
151 if test -e "/lib/modules/$(uname -r)/build"; then
152 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
153 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
154 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
155 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
156 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
157 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
158 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
160 kernelbuild=${kernelsrc}
163 AC_MSG_RESULT([$kernelbuild])
165 AC_MSG_CHECKING([kernel source version])
166 utsrelease1=$kernelbuild/include/linux/version.h
167 utsrelease2=$kernelbuild/include/linux/utsrelease.h
168 utsrelease3=$kernelbuild/include/generated/utsrelease.h
169 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
170 utsrelease=linux/version.h
171 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
172 utsrelease=linux/utsrelease.h
173 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
174 utsrelease=generated/utsrelease.h
177 if test "$utsrelease"; then
178 kernsrcver=`(echo "#include <$utsrelease>";
179 echo "kernsrcver=UTS_RELEASE") |
180 cpp -I $kernelbuild/include |
181 grep "^kernsrcver=" | cut -d \" -f 2`
183 if test -z "$kernsrcver"; then
184 AC_MSG_RESULT([Not found])
185 AC_MSG_ERROR([*** Cannot determine kernel version.])
188 AC_MSG_RESULT([Not found])
189 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
192 AC_MSG_RESULT([$kernsrcver])
195 LINUX_OBJ=${kernelbuild}
196 LINUX_VERSION=${kernsrcver}
200 AC_SUBST(LINUX_VERSION)
202 SPL_AC_MODULE_SYMVERS
205 AC_DEFUN([SPL_AC_KERNEL_CONFIG], [
206 SPL_LINUX_CONFIG([PREEMPT],
208 *** Kernel built with CONFIG_PREEMPT which is not supported.
209 ** You must rebuild your kernel without this option.]), [])
213 dnl # Explicitly check for gawk, we require it for the the usermode
214 dnl # helper. For some reason the standard awk command does not
215 dnl # behave correctly when invoked from the usermode helper.
217 AC_DEFUN([SPL_AC_GAWK], [
218 AS_IF([test "x$AWK" != xgawk], [
220 *** Required util gawk missing. Please install the required
221 *** gawk package for your distribution and try again.])
226 dnl # Default SPL user configuration
228 AC_DEFUN([SPL_AC_CONFIG_USER], [
233 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
234 dnl # are missing it is non-fatal but you will not be able to build
235 dnl # RPM packages and will be warned if you try too.
237 AC_DEFUN([SPL_AC_RPM], [
241 AC_MSG_CHECKING([whether $RPM is available])
242 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
243 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
245 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
248 AC_MSG_RESULT([$HAVE_RPM])
251 AC_MSG_CHECKING([whether $RPMBUILD is available])
252 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
253 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
255 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
258 AC_MSG_RESULT([$HAVE_RPMBUILD])
263 AC_SUBST(RPM_VERSION)
265 AC_SUBST(HAVE_RPMBUILD)
267 AC_SUBST(RPMBUILD_VERSION)
271 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
272 dnl # tools are missing it is non-fatal but you will not be able to build
273 dnl # DEB packages and will be warned if you try too.
275 AC_DEFUN([SPL_AC_DPKG], [
277 DPKGBUILD=dpkg-buildpackage
279 AC_MSG_CHECKING([whether $DPKG is available])
280 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
281 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
283 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
286 AC_MSG_RESULT([$HAVE_DPKG])
289 AC_MSG_CHECKING([whether $DPKGBUILD is available])
290 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
291 DPKGBUILD_VERSION=$(echo $tmp | \
292 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
294 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
297 AC_MSG_RESULT([$HAVE_DPKGBUILD])
302 AC_SUBST(DPKG_VERSION)
304 AC_SUBST(HAVE_DPKGBUILD)
306 AC_SUBST(DPKGBUILD_VERSION)
310 dnl # Until native packaging for various different packing systems
311 dnl # can be added the least we can do is attempt to use alien to
312 dnl # convert the RPM packages to the needed package type. This is
313 dnl # a hack but so far it has worked reasonable well.
315 AC_DEFUN([SPL_AC_ALIEN], [
318 AC_MSG_CHECKING([whether $ALIEN is available])
319 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
320 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
322 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
325 AC_MSG_RESULT([$HAVE_ALIEN])
330 AC_SUBST(ALIEN_VERSION)
334 dnl # Using the VENDOR tag from config.guess set the default
335 dnl # package type for 'make pkg': (rpm | deb | tgz)
337 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
338 AC_MSG_CHECKING([linux distribution])
339 if test -f /etc/redhat-release ; then
341 elif test -f /etc/fedora-release ; then
343 elif test -f /etc/lsb-release ; then
345 elif test -f /etc/debian_version ; then
347 elif test -f /etc/SuSE-release ; then
349 elif test -f /etc/slackware-version ; then
351 elif test -f /etc/gentoo-release ; then
356 AC_MSG_RESULT([$VENDOR])
359 AC_MSG_CHECKING([default package type])
361 fedora) DEFAULT_PACKAGE=rpm ;;
362 redhat) DEFAULT_PACKAGE=rpm ;;
363 sles) DEFAULT_PACKAGE=rpm ;;
364 ubuntu) DEFAULT_PACKAGE=deb ;;
365 debian) DEFAULT_PACKAGE=deb ;;
366 slackware) DEFAULT_PACKAGE=tgz ;;
367 *) DEFAULT_PACKAGE=rpm ;;
370 AC_MSG_RESULT([$DEFAULT_PACKAGE])
371 AC_SUBST(DEFAULT_PACKAGE)
375 dnl # Default SPL user configuration
377 AC_DEFUN([SPL_AC_PACKAGE], [
381 SPL_AC_DEFAULT_PACKAGE
384 AC_DEFUN([SPL_AC_LICENSE], [
385 AC_MSG_CHECKING([spl license])
387 AC_MSG_RESULT([$LICENSE])
388 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
392 AC_DEFUN([SPL_AC_CONFIG], [
394 AC_ARG_WITH([config],
395 AS_HELP_STRING([--with-config=CONFIG],
396 [Config file 'kernel|user|all|srpm']),
397 [SPL_CONFIG="$withval"])
399 AC_MSG_CHECKING([spl config])
400 AC_MSG_RESULT([$SPL_CONFIG]);
403 case "$SPL_CONFIG" in
404 kernel) SPL_AC_CONFIG_KERNEL ;;
405 user) SPL_AC_CONFIG_USER ;;
406 all) SPL_AC_CONFIG_KERNEL
407 SPL_AC_CONFIG_USER ;;
410 AC_MSG_RESULT([Error!])
411 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
412 user kernel|user|all|srpm]) ;;
415 AM_CONDITIONAL([CONFIG_USER],
416 [test "$SPL_CONFIG" = user] ||
417 [test "$SPL_CONFIG" = all])
418 AM_CONDITIONAL([CONFIG_KERNEL],
419 [test "$SPL_CONFIG" = kernel] ||
420 [test "$SPL_CONFIG" = all])
424 dnl # Enable if the SPL should be compiled with internal debugging enabled.
425 dnl # By default this support is disabled.
427 AC_DEFUN([SPL_AC_DEBUG], [
428 AC_MSG_CHECKING([whether debugging is enabled])
429 AC_ARG_ENABLE([debug],
430 [AS_HELP_STRING([--enable-debug],
431 [Enable generic debug support @<:@default=no@:>@])],
435 AS_IF([test "x$enable_debug" = xyes],
437 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
438 DEBUG_CFLAGS="-DDEBUG -Werror"
441 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
442 DEBUG_CFLAGS="-DNDEBUG"
445 AC_SUBST(DEBUG_CFLAGS)
446 AC_MSG_RESULT([$enable_debug])
450 dnl # Enabled by default it provides a minimal level of memory tracking.
451 dnl # A total count of bytes allocated is kept for each alloc and free.
452 dnl # Then at module unload time a report to the console will be printed
453 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
454 dnl # and provide an easy way to inspect the kmem based slab.
456 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
457 AC_ARG_ENABLE([debug-kmem],
458 [AS_HELP_STRING([--enable-debug-kmem],
459 [Enable basic kmem accounting @<:@default=yes@:>@])],
461 [enable_debug_kmem=yes])
463 AS_IF([test "x$enable_debug_kmem" = xyes],
464 [AC_DEFINE([DEBUG_KMEM], [1],
465 [Define to 1 to enable basic kmem accounting])
466 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"])
468 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
469 AC_MSG_RESULT([$enable_debug_kmem])
473 dnl # Disabled by default it provides detailed memory tracking. This
474 dnl # feature also requires --enable-debug-kmem to be set. When enabled
475 dnl # not only will total bytes be tracked but also the location of every
476 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
477 dnl # addresses and where they were allocated will be dumped to the console.
478 dnl # Enabling this feature has a significant impact on performance but it
479 dnl # makes finding memory leaks pretty straight forward.
481 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
482 AC_ARG_ENABLE([debug-kmem-tracking],
483 [AS_HELP_STRING([--enable-debug-kmem-tracking],
484 [Enable detailed kmem tracking @<:@default=no@:>@])],
486 [enable_debug_kmem_tracking=no])
488 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
489 [AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
490 [Define to 1 to enable detailed kmem tracking])
491 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"])
493 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
494 AC_MSG_RESULT([$enable_debug_kmem_tracking])
498 dnl # SPL_LINUX_CONFTEST
500 AC_DEFUN([SPL_LINUX_CONFTEST], [
501 cat confdefs.h - <<_ACEOF >conftest.c
507 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
509 m4_define([SPL_LANG_PROGRAM], [
514 dnl Do *not* indent the following line: there may be CPP directives.
515 dnl Don't move the `;' right after for the same reason.
523 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
525 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
526 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
527 rm -Rf build && mkdir -p build
528 echo "obj-m := conftest.o" >build/Makefile
530 [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])],
532 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
538 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
540 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
541 [SPL_LINUX_COMPILE_IFELSE(
542 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
544 [test -s build/conftest.o],
549 dnl # SPL_LINUX_CONFIG
551 AC_DEFUN([SPL_LINUX_CONFIG],
552 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
553 SPL_LINUX_TRY_COMPILE([
554 #ifndef AUTOCONF_INCLUDED
555 #include <linux/config.h>
559 #error CONFIG_$1 not #defined
571 dnl # SPL_CHECK_SYMBOL_EXPORT
572 dnl # check symbol exported or not
574 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
575 [AC_MSG_CHECKING([whether symbol $1 is exported])
576 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
577 $LINUX_OBJ/Module*.symvers 2>/dev/null
579 if test $rc -ne 0; then
582 grep -q -E "EXPORT_SYMBOL.*($1)" \
583 "$LINUX_OBJ/$file" 2>/dev/null
585 if test $rc -eq 0; then
590 if test $export -eq 0; then
604 dnl # SPL_CHECK_HEADER
605 dnl # check whether header exists and define HAVE_$2_HEADER
607 AC_DEFUN([SPL_CHECK_HEADER],
608 [AC_MSG_CHECKING([whether header $1 exists])
609 SPL_LINUX_TRY_COMPILE([
614 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
624 dnl # Use the atomic implemenation based on global spinlocks. This
625 dnl # should only be needed by 32-bit kernels which do not provide
626 dnl # the atomic64_* API. It may be optionally enabled as a fallback
627 dnl # if problems are observed with the direct mapping to the native
628 dnl # Linux atomic operations. You may not disable atomic spinlocks
629 dnl # if you kernel does not an atomic64_* API.
631 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
632 AC_ARG_ENABLE([atomic-spinlocks],
633 [AS_HELP_STRING([--enable-atomic-spinlocks],
634 [Atomic types use spinlocks @<:@default=check@:>@])],
636 [enable_atomic_spinlocks=check])
638 SPL_LINUX_TRY_COMPILE([
639 #include <asm/atomic.h>
644 AC_DEFINE(HAVE_ATOMIC64_T, 1,
645 [kernel defines atomic64_t])
650 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
651 AS_IF([test "x$have_atomic64_t" = xyes], [
652 enable_atomic_spinlocks=no
654 enable_atomic_spinlocks=yes
658 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
659 AC_DEFINE([ATOMIC_SPINLOCK], [1],
660 [Atomic types use spinlocks])
662 AS_IF([test "x$have_atomic64_t" = xno], [
664 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
668 AC_MSG_CHECKING([whether atomic types use spinlocks])
669 AC_MSG_RESULT([$enable_atomic_spinlocks])
671 AC_MSG_CHECKING([whether kernel defines atomic64_t])
672 AC_MSG_RESULT([$have_atomic64_t])
676 dnl # 2.6.24 API change,
677 dnl # check if atomic64_cmpxchg is defined
679 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
680 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
681 SPL_LINUX_TRY_COMPILE([
682 #include <asm/atomic.h>
683 #include <asm/system.h>
685 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
688 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
689 [kernel defines atomic64_cmpxchg])
696 dnl # 2.6.24 API change,
697 dnl # check if atomic64_xchg is defined
699 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
700 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
701 SPL_LINUX_TRY_COMPILE([
702 #include <asm/atomic.h>
704 atomic64_xchg((atomic64_t *)NULL, 0);
707 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
708 [kernel defines atomic64_xchg])
715 dnl # 2.6.24 API change,
716 dnl # check if uintptr_t typedef is defined
718 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
719 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
720 SPL_LINUX_TRY_COMPILE([
721 #include <linux/types.h>
726 AC_DEFINE(HAVE_UINTPTR_T, 1,
727 [kernel defines uintptr_t])
734 dnl # 2.6.20 API change,
735 dnl # INIT_WORK use 2 args and not store data inside
737 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
738 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
739 SPL_LINUX_TRY_COMPILE([
740 #include <linux/workqueue.h>
742 struct work_struct work;
743 INIT_WORK(&work, NULL, NULL);
746 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
747 [INIT_WORK wants 3 args])
754 dnl # 2.6.21 API change,
755 dnl # 'register_sysctl_table' use only one argument instead of two
757 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
758 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
759 SPL_LINUX_TRY_COMPILE([
760 #include <linux/sysctl.h>
762 return register_sysctl_table(NULL,0);
765 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
766 [register_sysctl_table() wants 2 args])
773 dnl # 2.6.23 API change
774 dnl # Old set_shrinker API replaced with register_shrinker
776 AC_DEFUN([SPL_AC_SET_SHRINKER], [
777 AC_MSG_CHECKING([whether set_shrinker() available])
778 SPL_LINUX_TRY_COMPILE([
779 #include <linux/mm.h>
781 return set_shrinker(DEFAULT_SEEKS, NULL);
784 AC_DEFINE(HAVE_SET_SHRINKER, 1,
785 [set_shrinker() available])
792 dnl # 2.6.35 API change,
793 dnl # Add context to shrinker callback
795 AC_DEFUN([SPL_AC_3ARGS_SHRINKER_CALLBACK],
796 [AC_MSG_CHECKING([whether shrinker callback wants 3 args])
797 tmp_flags="$EXTRA_KCFLAGS"
798 EXTRA_KCFLAGS="-Werror"
799 SPL_LINUX_TRY_COMPILE([
800 #include <linux/mm.h>
802 int shrinker_cb(struct shrinker *, int, unsigned int);
804 struct shrinker cache_shrinker = {
805 .shrink = shrinker_cb,
806 .seeks = DEFAULT_SEEKS,
808 register_shrinker(&cache_shrinker);
811 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
812 [shrinker callback wants 3 args])
816 EXTRA_KCFLAGS="$tmp_flags"
820 dnl # 2.6.25 API change,
821 dnl # struct path entry added to struct nameidata
823 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
824 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
825 SPL_LINUX_TRY_COMPILE([
826 #include <linux/namei.h>
831 nd.path.dentry = NULL;
834 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
835 [struct path used in struct nameidata])
842 dnl # Custom SPL patch may export this system it is not required
844 AC_DEFUN([SPL_AC_TASK_CURR], [
845 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
846 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
851 dnl # 2.6.19 API change,
852 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
854 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
855 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
856 SPL_LINUX_TRY_COMPILE([
857 #include <linux/sysctl.h>
859 #ifndef CTL_UNNUMBERED
860 #error CTL_UNNUMBERED undefined
864 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
865 [unnumbered sysctl support exists])
872 dnl # 2.6.33 API change,
873 dnl # Removed .ctl_name from struct ctl_table.
875 AC_DEFUN([SPL_AC_CTL_NAME], [
876 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
877 SPL_LINUX_TRY_COMPILE([
878 #include <linux/sysctl.h>
880 struct ctl_table ctl;
884 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
891 dnl # 2.6.16 API change.
892 dnl # Check if 'fls64()' is available
894 AC_DEFUN([SPL_AC_FLS64],
895 [AC_MSG_CHECKING([whether fls64() is available])
896 SPL_LINUX_TRY_COMPILE([
897 #include <linux/bitops.h>
902 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
909 dnl # 2.6.18 API change, check whether device_create() is available.
910 dnl # Device_create() was introduced in 2.6.18 and depricated
911 dnl # class_device_create() which was fully removed in 2.6.26.
913 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
914 SPL_CHECK_SYMBOL_EXPORT(
916 [drivers/base/core.c],
917 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
918 [device_create() is available])],
923 dnl # 2.6.27 API change,
924 dnl # device_create() uses 5 args, new 'drvdata' argument.
926 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
927 AC_MSG_CHECKING([whether device_create() wants 5 args])
928 tmp_flags="$EXTRA_KCFLAGS"
929 EXTRA_KCFLAGS="-Werror"
930 SPL_LINUX_TRY_COMPILE([
931 #include <linux/device.h>
933 device_create(NULL, NULL, 0, NULL, "%d", 1);
936 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
937 [device_create wants 5 args])
941 EXTRA_KCFLAGS="$tmp_flags"
945 dnl # 2.6.13 API change, check whether class_device_create() is available.
946 dnl # Class_device_create() was introduced in 2.6.13 and depricated
947 dnl # class_simple_device_add() which was fully removed in 2.6.13.
949 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
950 SPL_CHECK_SYMBOL_EXPORT(
951 [class_device_create],
952 [drivers/base/class.c],
953 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
954 [class_device_create() is available])],
959 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
961 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
962 SPL_CHECK_SYMBOL_EXPORT(
963 [set_normalized_timespec],
965 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
966 [set_normalized_timespec() is available as export])],
971 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
972 dnl # previously it was available in time.h as an inline.
974 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
975 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
976 SPL_LINUX_TRY_COMPILE([
977 #include <linux/time.h>
978 void set_normalized_timespec(struct timespec *ts,
979 time_t sec, long nsec) { }
986 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
987 [set_normalized_timespec() is available as inline])
992 dnl # 2.6.18 API change,
993 dnl # timespec_sub() inline function available in linux/time.h
995 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
996 AC_MSG_CHECKING([whether timespec_sub() is available])
997 SPL_LINUX_TRY_COMPILE([
998 #include <linux/time.h>
1000 struct timespec a, b, c = { 0 };
1001 c = timespec_sub(a, b);
1004 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1011 dnl # 2.6.19 API change,
1012 dnl # check if init_utsname() is available in linux/utsname.h
1014 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
1015 AC_MSG_CHECKING([whether init_utsname() is available])
1016 SPL_LINUX_TRY_COMPILE([
1017 #include <linux/utsname.h>
1019 struct new_utsname *a = init_utsname();
1022 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1029 dnl # 2.6.26 API change,
1030 dnl # definition of struct fdtable relocated to linux/fdtable.h
1032 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
1033 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
1037 dnl # 2.6.14 API change,
1038 dnl # check whether 'files_fdtable()' exists
1040 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
1041 AC_MSG_CHECKING([whether files_fdtable() is available])
1042 SPL_LINUX_TRY_COMPILE([
1043 #include <linux/sched.h>
1044 #include <linux/file.h>
1045 #ifdef HAVE_FDTABLE_HEADER
1046 #include <linux/fdtable.h>
1049 struct files_struct *files = current->files;
1050 struct fdtable *fdt = files_fdtable(files);
1053 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
1060 dnl # 2.6.18 API change,
1061 dnl # added linux/uaccess.h
1063 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1064 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1068 dnl # 2.6.12 API change,
1069 dnl # check whether 'kmalloc_node()' is available.
1071 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1072 AC_MSG_CHECKING([whether kmalloc_node() is available])
1073 SPL_LINUX_TRY_COMPILE([
1074 #include <linux/slab.h>
1076 void *a = kmalloc_node(1, GFP_KERNEL, 0);
1079 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1086 dnl # 2.6.9 API change,
1087 dnl # check whether 'monotonic_clock()' is available it may
1088 dnl # be available for some archs but not others.
1090 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
1091 SPL_CHECK_SYMBOL_EXPORT(
1094 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1095 [monotonic_clock() is available])],
1100 dnl # 2.6.16 API change,
1101 dnl # check whether 'struct inode' has i_mutex
1103 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1104 AC_MSG_CHECKING([whether struct inode has i_mutex])
1105 SPL_LINUX_TRY_COMPILE([
1106 #include <linux/fs.h>
1107 #include <linux/mutex.h>
1110 mutex_init(&i.i_mutex);
1113 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1120 dnl # 2.6.29 API change,
1121 dnl # Adaptive mutexs introduced.
1123 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1124 AC_MSG_CHECKING([whether struct mutex has owner])
1125 SPL_LINUX_TRY_COMPILE([
1126 #include <linux/mutex.h>
1132 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1139 dnl # 2.6.18 API change,
1140 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1141 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1142 dnl # if the mutex validator is disabled or otherwise unavailable.
1144 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1145 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1146 SPL_LINUX_TRY_COMPILE([
1147 #include <linux/mutex.h>
1151 mutex_lock_nested(&mutex, 0);
1154 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1155 [mutex_lock_nested() is available])
1162 dnl # 2.6.27 API change,
1163 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1165 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1166 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1167 SPL_LINUX_TRY_COMPILE([
1168 #include <linux/smp.h>
1170 on_each_cpu(NULL, NULL, 0);
1173 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1174 [on_each_cpu wants 3 args])
1181 dnl # 2.6.18 API change,
1182 dnl # kallsyms_lookup_name no longer exported
1184 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
1185 SPL_CHECK_SYMBOL_EXPORT(
1186 [kallsyms_lookup_name],
1188 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1189 [kallsyms_lookup_name() is available])],
1194 dnl # Proposed API change,
1195 dnl # This symbol is not available in stock kernels. You may build a
1196 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1197 dnl # these symbols for use. If your already rolling a custom kernel for
1198 dnl # your environment this is recommended.
1200 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
1201 SPL_CHECK_SYMBOL_EXPORT(
1204 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1205 [get_vmalloc_info() is available])],
1210 dnl # 2.6.17 API change
1211 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1212 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1213 dnl # were exported in 2.6.17 for use by modules which was consistent with
1214 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1215 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1216 dnl # were dropped entirely leaving modules no way to directly iterate over
1217 dnl # the zone list. Because we need access to the zone helpers we check
1218 dnl # if the kernel contains the old or new implementation. Then we check
1219 dnl # to see if the symbols we need for each version are available. If they
1220 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1222 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1223 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1224 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1226 if test $rc -eq 0; then
1227 AC_MSG_RESULT([yes])
1228 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1235 dnl # Proposed API change,
1236 dnl # This symbol is not available in stock kernels. You may build a
1237 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1238 dnl # these symbols for use. If your already rolling a custom kernel for
1239 dnl # your environment this is recommended.
1241 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
1242 SPL_CHECK_SYMBOL_EXPORT(
1243 [first_online_pgdat],
1245 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1246 [first_online_pgdat() is available])],
1251 dnl # Proposed API change,
1252 dnl # This symbol is not available in stock kernels. You may build a
1253 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1254 dnl # these symbols for use. If your already rolling a custom kernel for
1255 dnl # your environment this is recommended.
1257 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
1258 SPL_CHECK_SYMBOL_EXPORT(
1259 [next_online_pgdat],
1261 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1262 [next_online_pgdat() is available])],
1267 dnl # Proposed API change,
1268 dnl # This symbol is not available in stock kernels. You may build a
1269 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1270 dnl # these symbols for use. If your already rolling a custom kernel for
1271 dnl # your environment this is recommended.
1273 AC_DEFUN([SPL_AC_NEXT_ZONE], [
1274 SPL_CHECK_SYMBOL_EXPORT(
1277 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1278 [next_zone() is available])],
1283 dnl # 2.6.17 API change,
1284 dnl # See SPL_AC_PGDAT_HELPERS for details.
1286 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1287 SPL_CHECK_SYMBOL_EXPORT(
1290 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1291 [pgdat_list is available])],
1296 dnl # 2.6.18 API change,
1297 dnl # First introduced global_page_state() support as an inline.
1299 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1300 AC_MSG_CHECKING([whether global_page_state() is available])
1301 SPL_LINUX_TRY_COMPILE([
1302 #include <linux/mm.h>
1304 unsigned long state;
1305 state = global_page_state(0);
1308 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1309 [global_page_state() is available])
1316 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1317 dnl # Public global zone stats now include a free page count. However
1318 dnl # the enumerated names of the counters have changed since this API
1319 dnl # was introduced. We need to deduce the corrent name to use. This
1320 dnl # replaces the priviate get_zone_counts() interface.
1322 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1323 dnl # is 2.6.30 as of when this was written.
1325 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1326 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1327 SPL_LINUX_TRY_COMPILE([
1328 #include <linux/mm.h>
1330 enum zone_stat_item zsi;
1331 zsi = NR_FREE_PAGES;
1334 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1335 [Page state NR_FREE_PAGES is available])
1342 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1343 dnl # Public global zone stats now include an inactive page count. However
1344 dnl # the enumerated names of the counters have changed since this API
1345 dnl # was introduced. We need to deduce the corrent name to use. This
1346 dnl # replaces the priviate get_zone_counts() interface.
1348 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1349 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1350 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1352 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1353 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1354 SPL_LINUX_TRY_COMPILE([
1355 #include <linux/mm.h>
1357 enum zone_stat_item zsi;
1361 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1362 [Page state NR_INACTIVE is available])
1367 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1368 SPL_LINUX_TRY_COMPILE([
1369 #include <linux/mm.h>
1371 enum zone_stat_item zsi;
1372 zsi = NR_INACTIVE_ANON;
1375 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1376 [Page state NR_INACTIVE_ANON is available])
1381 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1382 SPL_LINUX_TRY_COMPILE([
1383 #include <linux/mm.h>
1385 enum zone_stat_item zsi;
1386 zsi = NR_INACTIVE_FILE;
1389 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1390 [Page state NR_INACTIVE_FILE is available])
1397 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1398 dnl # Public global zone stats now include an active page count. However
1399 dnl # the enumerated names of the counters have changed since this API
1400 dnl # was introduced. We need to deduce the corrent name to use. This
1401 dnl # replaces the priviate get_zone_counts() interface.
1403 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1404 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1405 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1407 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1408 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1409 SPL_LINUX_TRY_COMPILE([
1410 #include <linux/mm.h>
1412 enum zone_stat_item zsi;
1416 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1417 [Page state NR_ACTIVE is available])
1422 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1423 SPL_LINUX_TRY_COMPILE([
1424 #include <linux/mm.h>
1426 enum zone_stat_item zsi;
1427 zsi = NR_ACTIVE_ANON;
1430 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1431 [Page state NR_ACTIVE_ANON is available])
1436 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1437 SPL_LINUX_TRY_COMPILE([
1438 #include <linux/mm.h>
1440 enum zone_stat_item zsi;
1441 zsi = NR_ACTIVE_FILE;
1444 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1445 [Page state NR_ACTIVE_FILE is available])
1452 dnl # Proposed API change for legacy kernels.
1453 dnl # This symbol is not available in older kernels. For kernels post
1454 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1455 dnl # page state information. This symbol is only used in legacy kernels
1456 dnl # any only as a last resort.
1458 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1459 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1460 SPL_LINUX_TRY_COMPILE([
1462 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1463 #error "global_page_state needs NR_FREE_PAGES"
1466 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1467 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1468 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1469 #error "global_page_state needs NR_ACTIVE*"
1472 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1473 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1474 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1475 #error "global_page_state needs NR_INACTIVE*"
1481 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1482 [get_zone_counts() is needed])
1484 SPL_CHECK_SYMBOL_EXPORT(
1487 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1488 [get_zone_counts() is available])],
1494 dnl # 2.6.27 API change,
1495 dnl # The user_path_dir() replaces __user_walk()
1497 AC_DEFUN([SPL_AC_USER_PATH_DIR], [
1498 SPL_CHECK_SYMBOL_EXPORT(
1501 [AC_DEFINE(HAVE_USER_PATH_DIR, 1,
1502 [user_path_dir() is available])],
1507 dnl # Symbol available in RHEL kernels not in stock kernels.
1509 AC_DEFUN([SPL_AC_SET_FS_PWD], [
1510 SPL_CHECK_SYMBOL_EXPORT(
1513 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1514 [set_fs_pwd() is available])],
1519 dnl # 2.6.25 API change,
1520 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1522 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1523 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1524 SPL_LINUX_TRY_COMPILE([
1525 #include <linux/sched.h>
1526 #include <linux/fs_struct.h>
1528 set_fs_pwd(NULL, NULL);
1531 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1532 [set_fs_pwd() wants 2 args])
1539 dnl # SLES API change, never adopted in mainline,
1540 dnl # Third 'struct vfsmount *' argument removed.
1542 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1543 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1544 SPL_LINUX_TRY_COMPILE([
1545 #include <linux/fs.h>
1547 vfs_unlink(NULL, NULL);
1550 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1551 [vfs_unlink() wants 2 args])
1558 dnl # SLES API change, never adopted in mainline,
1559 dnl # Third and sixth 'struct vfsmount *' argument removed.
1561 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1562 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1563 SPL_LINUX_TRY_COMPILE([
1564 #include <linux/fs.h>
1566 vfs_rename(NULL, NULL, NULL, NULL);
1569 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1570 [vfs_rename() wants 4 args])
1577 dnl # 2.6.36 API change,
1578 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1579 dnl # a spinlock_t to improve the fastpath performance.
1581 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1582 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1583 SPL_LINUX_TRY_COMPILE([
1584 #include <linux/sched.h>
1585 #include <linux/fs_struct.h>
1587 struct fs_struct fs;
1588 spin_lock_init(&fs.lock);
1591 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1592 [struct fs_struct uses spinlock_t])
1599 dnl # 2.6.29 API change,
1600 dnl # check whether 'struct cred' exists
1602 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1603 AC_MSG_CHECKING([whether struct cred exists])
1604 SPL_LINUX_TRY_COMPILE([
1605 #include <linux/cred.h>
1611 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1618 dnl # Custom SPL patch may export this symbol.
1620 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1621 SPL_CHECK_SYMBOL_EXPORT(
1624 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1625 [groups_search() is available])],
1630 dnl # 2.6.x API change,
1631 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1633 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1634 SPL_CHECK_SYMBOL_EXPORT(
1635 [__put_task_struct],
1637 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1638 [__put_task_struct() is available])],
1643 dnl # 2.6.32 API change,
1644 dnl # Unused 'struct file *' removed from prototype.
1646 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1647 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1648 SPL_LINUX_TRY_COMPILE([
1649 #include <linux/sysctl.h>
1651 proc_dostring(NULL, 0, NULL, NULL, NULL);
1654 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1655 [proc_handler() wants 5 args])
1662 dnl # 2.6.x API change,
1663 dnl # kvasprintf() function added.
1665 AC_DEFUN([SPL_AC_KVASPRINTF], [
1666 SPL_CHECK_SYMBOL_EXPORT(
1669 [AC_DEFINE(HAVE_KVASPRINTF, 1,
1670 [kvasprintf() is available])],
1675 dnl # 2.6.35 API change,
1676 dnl # Unused 'struct dentry *' removed from prototype.
1678 AC_DEFUN([SPL_AC_3ARGS_FILE_FSYNC], [
1679 AC_MSG_CHECKING([whether file_fsync() wants 3 args])
1680 SPL_LINUX_TRY_COMPILE([
1681 #include <linux/buffer_head.h>
1683 file_fsync(NULL, NULL, 0);
1686 AC_DEFINE(HAVE_3ARGS_FILE_FSYNC, 1,
1687 [file_fsync() wants 3 args])
1694 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
1695 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
1696 dnl # condition. The fixed version is exported as a symbol. The race
1697 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
1698 dnl # call that version while holding sem->wait_lock.
1700 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED], [
1701 SPL_CHECK_SYMBOL_EXPORT(
1703 [lib/rwsem-spinlock.c],
1704 [AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
1705 [rwsem_is_locked() acquires sem->wait_lock])],
1710 dnl # 2.6.37 API compat,
1711 dnl # The function invalidate_inodes() is no longer exported by the kernel.
1712 dnl # The prototype however is still available which means it is safe
1713 dnl # to acquire the symbol's address using spl_kallsyms_lookup_name().
1715 AC_DEFUN([SPL_AC_KERNEL_INVALIDATE_INODES], [
1716 SPL_CHECK_SYMBOL_EXPORT(
1717 [invalidate_inodes],
1719 [AC_DEFINE(HAVE_INVALIDATE_INODES, 1,
1720 [invalidate_inodes() is available])],
1725 dnl # 2.6.39 API compat,
1726 dnl # The function invalidate_inodes() now take 2 arguments. The second
1727 dnl # 'kill_dirty' argument describes how invalidate_inodes() should
1728 dnl # handle dirty inodes. Only when set will dirty inodes be discarded,
1729 dnl # otherwise they will be handled as busy.
1731 dnl # Unfortunately, we don't have access to the invalidate_inodes()
1732 dnl # prototype so it's not easy to check how many arguments it takes.
1733 dnl # However, this change was done for the benefit of invalidate_device()
1734 dnl # which also added an argument. The invalidate_device() symbol does
1735 dnl # exist in the development headers so if it takes two arguments we
1736 dnl # can fairly safely infer that invalidate_inodes() takes two arguments
1737 dnl # as well. See commit 93b270f76e7ef3b81001576860c2701931cdc78b.
1739 AC_DEFUN([SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES],
1740 [AC_MSG_CHECKING([whether invalidate_inodes() wants 2 args])
1741 SPL_LINUX_TRY_COMPILE([
1742 #include <linux/fs.h>
1744 return __invalidate_device(NULL, 0);
1747 AC_DEFINE(HAVE_2ARGS_INVALIDATE_INODES, 1,
1748 [invalidate_inodes() wants 2 args])
1755 dnl # 2.6.xx API compat,
1756 dnl # There currently exists no exposed API to partially shrink the dcache.
1757 dnl # The expected mechanism to shrink the cache is a registered shrinker
1758 dnl # which is called during memory pressure.
1760 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY], [
1761 SPL_CHECK_SYMBOL_EXPORT(
1762 [shrink_dcache_memory],
1764 [AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
1765 [shrink_dcache_memory() is available])],
1770 dnl # 2.6.xx API compat,
1771 dnl # There currently exists no exposed API to partially shrink the icache.
1772 dnl # The expected mechanism to shrink the cache is a registered shrinker
1773 dnl # which is called during memory pressure.
1775 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY], [
1776 SPL_CHECK_SYMBOL_EXPORT(
1777 [shrink_icache_memory],
1779 [AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
1780 [shrink_icache_memory() is available])],