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>
641 atomic64_t *ptr __attribute__ ((unused));
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>
723 uintptr_t *ptr __attribute__ ((unused));
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 __attribute__ ((unused));
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 (void) 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>
828 struct nameidata nd __attribute__ ((unused));
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 __attribute__ ((unused));
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 = { 0 };
1001 struct timespec b = { 0 };
1002 struct timespec c __attribute__ ((unused));
1003 c = timespec_sub(a, b);
1006 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1013 dnl # 2.6.19 API change,
1014 dnl # check if init_utsname() is available in linux/utsname.h
1016 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
1017 AC_MSG_CHECKING([whether init_utsname() is available])
1018 SPL_LINUX_TRY_COMPILE([
1019 #include <linux/utsname.h>
1021 struct new_utsname *a __attribute__ ((unused));
1025 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1032 dnl # 2.6.26 API change,
1033 dnl # definition of struct fdtable relocated to linux/fdtable.h
1035 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
1036 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
1040 dnl # 2.6.14 API change,
1041 dnl # check whether 'files_fdtable()' exists
1043 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
1044 AC_MSG_CHECKING([whether files_fdtable() is available])
1045 SPL_LINUX_TRY_COMPILE([
1046 #include <linux/sched.h>
1047 #include <linux/file.h>
1048 #ifdef HAVE_FDTABLE_HEADER
1049 #include <linux/fdtable.h>
1052 struct files_struct *files = current->files;
1053 struct fdtable *fdt __attribute__ ((unused));
1054 fdt = files_fdtable(files);
1057 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
1064 dnl # 2.6.18 API change,
1065 dnl # added linux/uaccess.h
1067 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1068 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1072 dnl # 2.6.12 API change,
1073 dnl # check whether 'kmalloc_node()' is available.
1075 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1076 AC_MSG_CHECKING([whether kmalloc_node() is available])
1077 SPL_LINUX_TRY_COMPILE([
1078 #include <linux/slab.h>
1080 void *a __attribute__ ((unused));
1081 a = kmalloc_node(1, GFP_KERNEL, 0);
1084 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1091 dnl # 2.6.9 API change,
1092 dnl # check whether 'monotonic_clock()' is available it may
1093 dnl # be available for some archs but not others.
1095 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
1096 SPL_CHECK_SYMBOL_EXPORT(
1099 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1100 [monotonic_clock() is available])],
1105 dnl # 2.6.16 API change,
1106 dnl # check whether 'struct inode' has i_mutex
1108 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1109 AC_MSG_CHECKING([whether struct inode has i_mutex])
1110 SPL_LINUX_TRY_COMPILE([
1111 #include <linux/fs.h>
1112 #include <linux/mutex.h>
1115 mutex_init(&i.i_mutex);
1118 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1125 dnl # 2.6.29 API change,
1126 dnl # Adaptive mutexs introduced.
1128 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1129 AC_MSG_CHECKING([whether struct mutex has owner])
1130 SPL_LINUX_TRY_COMPILE([
1131 #include <linux/mutex.h>
1133 struct mutex mtx __attribute__ ((unused));
1137 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1144 dnl # 2.6.18 API change,
1145 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1146 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1147 dnl # if the mutex validator is disabled or otherwise unavailable.
1149 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1150 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1151 SPL_LINUX_TRY_COMPILE([
1152 #include <linux/mutex.h>
1156 mutex_lock_nested(&mutex, 0);
1159 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1160 [mutex_lock_nested() is available])
1167 dnl # 2.6.27 API change,
1168 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1170 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1171 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1172 SPL_LINUX_TRY_COMPILE([
1173 #include <linux/smp.h>
1175 on_each_cpu(NULL, NULL, 0);
1178 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1179 [on_each_cpu wants 3 args])
1186 dnl # 2.6.18 API change,
1187 dnl # kallsyms_lookup_name no longer exported
1189 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
1190 SPL_CHECK_SYMBOL_EXPORT(
1191 [kallsyms_lookup_name],
1193 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1194 [kallsyms_lookup_name() is available])],
1199 dnl # Proposed API change,
1200 dnl # This symbol is not available in stock kernels. You may build a
1201 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1202 dnl # these symbols for use. If your already rolling a custom kernel for
1203 dnl # your environment this is recommended.
1205 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
1206 SPL_CHECK_SYMBOL_EXPORT(
1209 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1210 [get_vmalloc_info() is available])],
1215 dnl # 2.6.17 API change
1216 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1217 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1218 dnl # were exported in 2.6.17 for use by modules which was consistent with
1219 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1220 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1221 dnl # were dropped entirely leaving modules no way to directly iterate over
1222 dnl # the zone list. Because we need access to the zone helpers we check
1223 dnl # if the kernel contains the old or new implementation. Then we check
1224 dnl # to see if the symbols we need for each version are available. If they
1225 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1227 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1228 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1229 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1231 if test $rc -eq 0; then
1232 AC_MSG_RESULT([yes])
1233 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1240 dnl # Proposed API change,
1241 dnl # This symbol is not available in stock kernels. You may build a
1242 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1243 dnl # these symbols for use. If your already rolling a custom kernel for
1244 dnl # your environment this is recommended.
1246 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
1247 SPL_CHECK_SYMBOL_EXPORT(
1248 [first_online_pgdat],
1250 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1251 [first_online_pgdat() is available])],
1256 dnl # Proposed API change,
1257 dnl # This symbol is not available in stock kernels. You may build a
1258 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1259 dnl # these symbols for use. If your already rolling a custom kernel for
1260 dnl # your environment this is recommended.
1262 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
1263 SPL_CHECK_SYMBOL_EXPORT(
1264 [next_online_pgdat],
1266 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1267 [next_online_pgdat() is available])],
1272 dnl # Proposed API change,
1273 dnl # This symbol is not available in stock kernels. You may build a
1274 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1275 dnl # these symbols for use. If your already rolling a custom kernel for
1276 dnl # your environment this is recommended.
1278 AC_DEFUN([SPL_AC_NEXT_ZONE], [
1279 SPL_CHECK_SYMBOL_EXPORT(
1282 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1283 [next_zone() is available])],
1288 dnl # 2.6.17 API change,
1289 dnl # See SPL_AC_PGDAT_HELPERS for details.
1291 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1292 SPL_CHECK_SYMBOL_EXPORT(
1295 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1296 [pgdat_list is available])],
1301 dnl # 2.6.18 API change,
1302 dnl # First introduced global_page_state() support as an inline.
1304 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1305 AC_MSG_CHECKING([whether global_page_state() is available])
1306 SPL_LINUX_TRY_COMPILE([
1307 #include <linux/mm.h>
1309 unsigned long state __attribute__ ((unused));
1310 state = global_page_state(0);
1313 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1314 [global_page_state() is available])
1321 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1322 dnl # Public global zone stats now include a free page count. However
1323 dnl # the enumerated names of the counters have changed since this API
1324 dnl # was introduced. We need to deduce the corrent name to use. This
1325 dnl # replaces the priviate get_zone_counts() interface.
1327 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1328 dnl # is 2.6.30 as of when this was written.
1330 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1331 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1332 SPL_LINUX_TRY_COMPILE([
1333 #include <linux/mm.h>
1335 enum zone_stat_item zsi __attribute__ ((unused));
1336 zsi = NR_FREE_PAGES;
1339 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1340 [Page state NR_FREE_PAGES is available])
1347 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1348 dnl # Public global zone stats now include an inactive page count. However
1349 dnl # the enumerated names of the counters have changed since this API
1350 dnl # was introduced. We need to deduce the corrent name to use. This
1351 dnl # replaces the priviate get_zone_counts() interface.
1353 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1354 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1355 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1357 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1358 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1359 SPL_LINUX_TRY_COMPILE([
1360 #include <linux/mm.h>
1362 enum zone_stat_item zsi __attribute__ ((unused));
1366 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1367 [Page state NR_INACTIVE is available])
1372 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1373 SPL_LINUX_TRY_COMPILE([
1374 #include <linux/mm.h>
1376 enum zone_stat_item zsi __attribute__ ((unused));
1377 zsi = NR_INACTIVE_ANON;
1380 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1381 [Page state NR_INACTIVE_ANON is available])
1386 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1387 SPL_LINUX_TRY_COMPILE([
1388 #include <linux/mm.h>
1390 enum zone_stat_item zsi __attribute__ ((unused));
1391 zsi = NR_INACTIVE_FILE;
1394 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1395 [Page state NR_INACTIVE_FILE is available])
1402 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1403 dnl # Public global zone stats now include an active page count. However
1404 dnl # the enumerated names of the counters have changed since this API
1405 dnl # was introduced. We need to deduce the corrent name to use. This
1406 dnl # replaces the priviate get_zone_counts() interface.
1408 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1409 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1410 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1412 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1413 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1414 SPL_LINUX_TRY_COMPILE([
1415 #include <linux/mm.h>
1417 enum zone_stat_item zsi __attribute__ ((unused));
1421 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1422 [Page state NR_ACTIVE is available])
1427 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1428 SPL_LINUX_TRY_COMPILE([
1429 #include <linux/mm.h>
1431 enum zone_stat_item zsi __attribute__ ((unused));
1432 zsi = NR_ACTIVE_ANON;
1435 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1436 [Page state NR_ACTIVE_ANON is available])
1441 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1442 SPL_LINUX_TRY_COMPILE([
1443 #include <linux/mm.h>
1445 enum zone_stat_item zsi __attribute__ ((unused));
1446 zsi = NR_ACTIVE_FILE;
1449 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1450 [Page state NR_ACTIVE_FILE is available])
1457 dnl # Proposed API change for legacy kernels.
1458 dnl # This symbol is not available in older kernels. For kernels post
1459 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1460 dnl # page state information. This symbol is only used in legacy kernels
1461 dnl # any only as a last resort.
1463 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1464 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1465 SPL_LINUX_TRY_COMPILE([
1467 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1468 #error "global_page_state needs NR_FREE_PAGES"
1471 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1472 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1473 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1474 #error "global_page_state needs NR_ACTIVE*"
1477 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1478 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1479 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1480 #error "global_page_state needs NR_INACTIVE*"
1486 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1487 [get_zone_counts() is needed])
1489 SPL_CHECK_SYMBOL_EXPORT(
1492 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1493 [get_zone_counts() is available])],
1499 dnl # 2.6.27 API change,
1500 dnl # The user_path_dir() replaces __user_walk()
1502 AC_DEFUN([SPL_AC_USER_PATH_DIR], [
1503 SPL_CHECK_SYMBOL_EXPORT(
1506 [AC_DEFINE(HAVE_USER_PATH_DIR, 1,
1507 [user_path_dir() is available])],
1512 dnl # Symbol available in RHEL kernels not in stock kernels.
1514 AC_DEFUN([SPL_AC_SET_FS_PWD], [
1515 SPL_CHECK_SYMBOL_EXPORT(
1518 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1519 [set_fs_pwd() is available])],
1524 dnl # 2.6.25 API change,
1525 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1527 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1528 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1529 SPL_LINUX_TRY_COMPILE([
1530 #include <linux/sched.h>
1531 #include <linux/fs_struct.h>
1533 set_fs_pwd(NULL, NULL);
1536 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1537 [set_fs_pwd() wants 2 args])
1544 dnl # SLES API change, never adopted in mainline,
1545 dnl # Third 'struct vfsmount *' argument removed.
1547 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1548 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1549 SPL_LINUX_TRY_COMPILE([
1550 #include <linux/fs.h>
1552 vfs_unlink(NULL, NULL);
1555 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1556 [vfs_unlink() wants 2 args])
1563 dnl # SLES API change, never adopted in mainline,
1564 dnl # Third and sixth 'struct vfsmount *' argument removed.
1566 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1567 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1568 SPL_LINUX_TRY_COMPILE([
1569 #include <linux/fs.h>
1571 vfs_rename(NULL, NULL, NULL, NULL);
1574 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1575 [vfs_rename() wants 4 args])
1582 dnl # 2.6.36 API change,
1583 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1584 dnl # a spinlock_t to improve the fastpath performance.
1586 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1587 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1588 SPL_LINUX_TRY_COMPILE([
1589 #include <linux/sched.h>
1590 #include <linux/fs_struct.h>
1592 struct fs_struct fs;
1593 spin_lock_init(&fs.lock);
1596 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1597 [struct fs_struct uses spinlock_t])
1604 dnl # 2.6.29 API change,
1605 dnl # check whether 'struct cred' exists
1607 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1608 AC_MSG_CHECKING([whether struct cred exists])
1609 SPL_LINUX_TRY_COMPILE([
1610 #include <linux/cred.h>
1612 struct cred *cr __attribute__ ((unused));
1616 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1623 dnl # Custom SPL patch may export this symbol.
1625 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1626 SPL_CHECK_SYMBOL_EXPORT(
1629 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1630 [groups_search() is available])],
1635 dnl # 2.6.x API change,
1636 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1638 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1639 SPL_CHECK_SYMBOL_EXPORT(
1640 [__put_task_struct],
1642 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1643 [__put_task_struct() is available])],
1648 dnl # 2.6.32 API change,
1649 dnl # Unused 'struct file *' removed from prototype.
1651 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1652 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1653 SPL_LINUX_TRY_COMPILE([
1654 #include <linux/sysctl.h>
1656 proc_dostring(NULL, 0, NULL, NULL, NULL);
1659 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1660 [proc_handler() wants 5 args])
1667 dnl # 2.6.x API change,
1668 dnl # kvasprintf() function added.
1670 AC_DEFUN([SPL_AC_KVASPRINTF], [
1671 SPL_CHECK_SYMBOL_EXPORT(
1674 [AC_DEFINE(HAVE_KVASPRINTF, 1,
1675 [kvasprintf() is available])],
1680 dnl # 2.6.35 API change,
1681 dnl # Unused 'struct dentry *' removed from prototype.
1683 AC_DEFUN([SPL_AC_3ARGS_FILE_FSYNC], [
1684 AC_MSG_CHECKING([whether file_fsync() wants 3 args])
1685 SPL_LINUX_TRY_COMPILE([
1686 #include <linux/buffer_head.h>
1688 file_fsync(NULL, NULL, 0);
1691 AC_DEFINE(HAVE_3ARGS_FILE_FSYNC, 1,
1692 [file_fsync() wants 3 args])
1699 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
1700 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
1701 dnl # condition. The fixed version is exported as a symbol. The race
1702 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
1703 dnl # call that version while holding sem->wait_lock.
1705 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED], [
1706 SPL_CHECK_SYMBOL_EXPORT(
1708 [lib/rwsem-spinlock.c],
1709 [AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
1710 [rwsem_is_locked() acquires sem->wait_lock])],
1715 dnl # 2.6.37 API compat,
1716 dnl # The function invalidate_inodes() is no longer exported by the kernel.
1717 dnl # The prototype however is still available which means it is safe
1718 dnl # to acquire the symbol's address using spl_kallsyms_lookup_name().
1720 AC_DEFUN([SPL_AC_KERNEL_INVALIDATE_INODES], [
1721 SPL_CHECK_SYMBOL_EXPORT(
1722 [invalidate_inodes],
1724 [AC_DEFINE(HAVE_INVALIDATE_INODES, 1,
1725 [invalidate_inodes() is available])],
1730 dnl # 2.6.39 API compat,
1731 dnl # The function invalidate_inodes() now take 2 arguments. The second
1732 dnl # 'kill_dirty' argument describes how invalidate_inodes() should
1733 dnl # handle dirty inodes. Only when set will dirty inodes be discarded,
1734 dnl # otherwise they will be handled as busy.
1736 dnl # Unfortunately, we don't have access to the invalidate_inodes()
1737 dnl # prototype so it's not easy to check how many arguments it takes.
1738 dnl # However, this change was done for the benefit of invalidate_device()
1739 dnl # which also added an argument. The invalidate_device() symbol does
1740 dnl # exist in the development headers so if it takes two arguments we
1741 dnl # can fairly safely infer that invalidate_inodes() takes two arguments
1742 dnl # as well. See commit 93b270f76e7ef3b81001576860c2701931cdc78b.
1744 AC_DEFUN([SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES],
1745 [AC_MSG_CHECKING([whether invalidate_inodes() wants 2 args])
1746 SPL_LINUX_TRY_COMPILE([
1747 #include <linux/fs.h>
1749 return __invalidate_device(NULL, 0);
1752 AC_DEFINE(HAVE_2ARGS_INVALIDATE_INODES, 1,
1753 [invalidate_inodes() wants 2 args])
1760 dnl # 2.6.xx API compat,
1761 dnl # There currently exists no exposed API to partially shrink the dcache.
1762 dnl # The expected mechanism to shrink the cache is a registered shrinker
1763 dnl # which is called during memory pressure.
1765 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY], [
1766 SPL_CHECK_SYMBOL_EXPORT(
1767 [shrink_dcache_memory],
1769 [AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
1770 [shrink_dcache_memory() is available])],
1775 dnl # 2.6.xx API compat,
1776 dnl # There currently exists no exposed API to partially shrink the icache.
1777 dnl # The expected mechanism to shrink the cache is a registered shrinker
1778 dnl # which is called during memory pressure.
1780 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY], [
1781 SPL_CHECK_SYMBOL_EXPORT(
1782 [shrink_icache_memory],
1784 [AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
1785 [shrink_icache_memory() is available])],