1 ###############################################################################
2 # Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
3 # Copyright (C) 2007 The Regents of the University of California.
4 # Written by Brian Behlendorf <behlendorf1@llnl.gov>.
5 ###############################################################################
6 # SPL_AC_CONFIG_KERNEL: Default SPL kernel configuration.
7 ###############################################################################
9 AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
13 if test "${LINUX_OBJ}" != "${LINUX}"; then
14 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
16 AC_SUBST(KERNELMAKE_PARAMS)
18 KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes"
19 AC_SUBST(KERNELCPPFLAGS)
23 SPL_AC_DEBUG_KMEM_TRACKING
24 SPL_AC_ATOMIC_SPINLOCK
25 SPL_AC_TYPE_ATOMIC64_CMPXCHG
26 SPL_AC_TYPE_ATOMIC64_XCHG
28 SPL_AC_3ARGS_INIT_WORK
29 SPL_AC_2ARGS_REGISTER_SYSCTL
31 SPL_AC_3ARGS_SHRINKER_CALLBACK
32 SPL_AC_PATH_IN_NAMEIDATA
38 SPL_AC_5ARGS_DEVICE_CREATE
39 SPL_AC_CLASS_DEVICE_CREATE
40 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
41 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
48 SPL_AC_MONOTONIC_CLOCK
51 SPL_AC_MUTEX_OWNER_TASK_STRUCT
52 SPL_AC_MUTEX_LOCK_NESTED
53 SPL_AC_3ARGS_ON_EACH_CPU
54 SPL_AC_KALLSYMS_LOOKUP_NAME
55 SPL_AC_GET_VMALLOC_INFO
57 SPL_AC_FIRST_ONLINE_PGDAT
58 SPL_AC_NEXT_ONLINE_PGDAT
61 SPL_AC_GLOBAL_PAGE_STATE
62 SPL_AC_ZONE_STAT_ITEM_FREE
63 SPL_AC_ZONE_STAT_ITEM_INACTIVE
64 SPL_AC_ZONE_STAT_ITEM_ACTIVE
65 SPL_AC_GET_ZONE_COUNTS
68 SPL_AC_2ARGS_SET_FS_PWD
69 SPL_AC_2ARGS_VFS_UNLINK
70 SPL_AC_4ARGS_VFS_RENAME
71 SPL_AC_FS_STRUCT_SPINLOCK
74 SPL_AC_PUT_TASK_STRUCT
75 SPL_AC_5ARGS_PROC_HANDLER
77 SPL_AC_3ARGS_FILE_FSYNC
78 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
79 SPL_AC_KERNEL_INVALIDATE_INODES
80 SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES
81 SPL_AC_SHRINK_DCACHE_MEMORY
82 SPL_AC_SHRINK_ICACHE_MEMORY
83 SPL_AC_KERN_PATH_PARENT
84 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
85 SPL_AC_SHRINK_CONTROL_STRUCT
88 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
89 modpost=$LINUX/scripts/Makefile.modpost
90 AC_MSG_CHECKING([kernel file name for module symbols])
91 if test -f "$modpost"; then
92 if grep -q Modules.symvers $modpost; then
93 LINUX_SYMBOLS=Modules.symvers
95 LINUX_SYMBOLS=Module.symvers
98 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
100 *** Please make sure the kernel devel package for your distribution
101 *** is installed. If your building with a custom kernel make sure the
102 *** kernel is configured, built, and the '--with-linux=PATH' configure
103 *** option refers to the location of the kernel source.])
108 AC_MSG_RESULT($LINUX_SYMBOLS)
109 AC_SUBST(LINUX_SYMBOLS)
112 AC_DEFUN([SPL_AC_KERNEL], [
114 AS_HELP_STRING([--with-linux=PATH],
115 [Path to kernel source]),
116 [kernelsrc="$withval"])
118 AC_ARG_WITH([linux-obj],
119 AS_HELP_STRING([--with-linux-obj=PATH],
120 [Path to kernel build objects]),
121 [kernelbuild="$withval"])
123 AC_MSG_CHECKING([kernel source directory])
124 if test -z "$kernelsrc"; then
125 if test -e "/lib/modules/$(uname -r)/source"; then
126 headersdir="/lib/modules/$(uname -r)/source"
127 sourcelink=$(readlink -f "$headersdir")
128 elif test -e "/lib/modules/$(uname -r)/build"; then
129 headersdir="/lib/modules/$(uname -r)/build"
130 sourcelink=$(readlink -f "$headersdir")
132 sourcelink=$(ls -1d /usr/src/kernels/* \
134 2>/dev/null | grep -v obj | tail -1)
137 if test -n "$sourcelink" && test -e ${sourcelink}; then
138 kernelsrc=`readlink -f ${sourcelink}`
140 AC_MSG_RESULT([Not found])
142 *** Please make sure the kernel devel package for your distribution
143 *** is installed then try again. If that fails you can specify the
144 *** location of the kernel source with the '--with-linux=PATH' option.])
147 if test "$kernelsrc" = "NONE"; then
152 AC_MSG_RESULT([$kernelsrc])
153 AC_MSG_CHECKING([kernel build directory])
154 if test -z "$kernelbuild"; then
155 if test -e "/lib/modules/$(uname -r)/build"; then
156 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
157 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
158 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
159 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
160 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
161 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
162 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
164 kernelbuild=${kernelsrc}
167 AC_MSG_RESULT([$kernelbuild])
169 AC_MSG_CHECKING([kernel source version])
170 utsrelease1=$kernelbuild/include/linux/version.h
171 utsrelease2=$kernelbuild/include/linux/utsrelease.h
172 utsrelease3=$kernelbuild/include/generated/utsrelease.h
173 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
174 utsrelease=linux/version.h
175 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
176 utsrelease=linux/utsrelease.h
177 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
178 utsrelease=generated/utsrelease.h
181 if test "$utsrelease"; then
182 kernsrcver=`(echo "#include <$utsrelease>";
183 echo "kernsrcver=UTS_RELEASE") |
184 cpp -I $kernelbuild/include |
185 grep "^kernsrcver=" | cut -d \" -f 2`
187 if test -z "$kernsrcver"; then
188 AC_MSG_RESULT([Not found])
189 AC_MSG_ERROR([*** Cannot determine kernel version.])
192 AC_MSG_RESULT([Not found])
193 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
196 AC_MSG_RESULT([$kernsrcver])
199 LINUX_OBJ=${kernelbuild}
200 LINUX_VERSION=${kernsrcver}
204 AC_SUBST(LINUX_VERSION)
206 SPL_AC_MODULE_SYMVERS
209 AC_DEFUN([SPL_AC_KERNEL_CONFIG], [
210 SPL_LINUX_CONFIG([PREEMPT],
212 *** Kernel built with CONFIG_PREEMPT which is not supported.
213 ** You must rebuild your kernel without this option.]), [])
217 dnl # Default SPL user configuration
219 AC_DEFUN([SPL_AC_CONFIG_USER], [])
222 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
223 dnl # are missing it is non-fatal but you will not be able to build
224 dnl # RPM packages and will be warned if you try too.
226 AC_DEFUN([SPL_AC_RPM], [
230 AC_MSG_CHECKING([whether $RPM is available])
231 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
232 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
234 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
237 AC_MSG_RESULT([$HAVE_RPM])
240 AC_MSG_CHECKING([whether $RPMBUILD is available])
241 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
242 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
244 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
247 AC_MSG_RESULT([$HAVE_RPMBUILD])
252 AC_SUBST(RPM_VERSION)
254 AC_SUBST(HAVE_RPMBUILD)
256 AC_SUBST(RPMBUILD_VERSION)
260 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
261 dnl # tools are missing it is non-fatal but you will not be able to build
262 dnl # DEB packages and will be warned if you try too.
264 AC_DEFUN([SPL_AC_DPKG], [
266 DPKGBUILD=dpkg-buildpackage
268 AC_MSG_CHECKING([whether $DPKG is available])
269 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
270 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
272 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
275 AC_MSG_RESULT([$HAVE_DPKG])
278 AC_MSG_CHECKING([whether $DPKGBUILD is available])
279 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
280 DPKGBUILD_VERSION=$(echo $tmp | \
281 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
283 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
286 AC_MSG_RESULT([$HAVE_DPKGBUILD])
291 AC_SUBST(DPKG_VERSION)
293 AC_SUBST(HAVE_DPKGBUILD)
295 AC_SUBST(DPKGBUILD_VERSION)
299 dnl # Until native packaging for various different packing systems
300 dnl # can be added the least we can do is attempt to use alien to
301 dnl # convert the RPM packages to the needed package type. This is
302 dnl # a hack but so far it has worked reasonable well.
304 AC_DEFUN([SPL_AC_ALIEN], [
307 AC_MSG_CHECKING([whether $ALIEN is available])
308 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
309 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
311 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
314 AC_MSG_RESULT([$HAVE_ALIEN])
319 AC_SUBST(ALIEN_VERSION)
323 dnl # Using the VENDOR tag from config.guess set the default
324 dnl # package type for 'make pkg': (rpm | deb | tgz)
326 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
327 AC_MSG_CHECKING([linux distribution])
328 if test -f /etc/redhat-release ; then
330 elif test -f /etc/fedora-release ; then
332 elif test -f /etc/lsb-release ; then
334 elif test -f /etc/debian_version ; then
336 elif test -f /etc/SuSE-release ; then
338 elif test -f /etc/slackware-version ; then
340 elif test -f /etc/gentoo-release ; then
345 AC_MSG_RESULT([$VENDOR])
348 AC_MSG_CHECKING([default package type])
350 fedora) DEFAULT_PACKAGE=rpm ;;
351 redhat) DEFAULT_PACKAGE=rpm ;;
352 sles) DEFAULT_PACKAGE=rpm ;;
353 ubuntu) DEFAULT_PACKAGE=deb ;;
354 debian) DEFAULT_PACKAGE=deb ;;
355 slackware) DEFAULT_PACKAGE=tgz ;;
356 *) DEFAULT_PACKAGE=rpm ;;
359 AC_MSG_RESULT([$DEFAULT_PACKAGE])
360 AC_SUBST(DEFAULT_PACKAGE)
364 dnl # Default SPL user configuration
366 AC_DEFUN([SPL_AC_PACKAGE], [
370 SPL_AC_DEFAULT_PACKAGE
373 AC_DEFUN([SPL_AC_LICENSE], [
374 AC_MSG_CHECKING([spl license])
376 AC_MSG_RESULT([$LICENSE])
377 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
381 AC_DEFUN([SPL_AC_CONFIG], [
383 AC_ARG_WITH([config],
384 AS_HELP_STRING([--with-config=CONFIG],
385 [Config file 'kernel|user|all|srpm']),
386 [SPL_CONFIG="$withval"])
388 AC_MSG_CHECKING([spl config])
389 AC_MSG_RESULT([$SPL_CONFIG]);
392 case "$SPL_CONFIG" in
393 kernel) SPL_AC_CONFIG_KERNEL ;;
394 user) SPL_AC_CONFIG_USER ;;
395 all) SPL_AC_CONFIG_KERNEL
396 SPL_AC_CONFIG_USER ;;
399 AC_MSG_RESULT([Error!])
400 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
401 user kernel|user|all|srpm]) ;;
404 AM_CONDITIONAL([CONFIG_USER],
405 [test "$SPL_CONFIG" = user] ||
406 [test "$SPL_CONFIG" = all])
407 AM_CONDITIONAL([CONFIG_KERNEL],
408 [test "$SPL_CONFIG" = kernel] ||
409 [test "$SPL_CONFIG" = all])
413 dnl # Enable if the SPL should be compiled with internal debugging enabled.
414 dnl # By default this support is disabled.
416 AC_DEFUN([SPL_AC_DEBUG], [
417 AC_MSG_CHECKING([whether debugging is enabled])
418 AC_ARG_ENABLE([debug],
419 [AS_HELP_STRING([--enable-debug],
420 [Enable generic debug support @<:@default=no@:>@])],
424 AS_IF([test "x$enable_debug" = xyes],
426 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
427 DEBUG_CFLAGS="-DDEBUG -Werror"
430 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
431 DEBUG_CFLAGS="-DNDEBUG"
434 AC_SUBST(DEBUG_CFLAGS)
435 AC_MSG_RESULT([$enable_debug])
439 dnl # Enabled by default it provides a minimal level of memory tracking.
440 dnl # A total count of bytes allocated is kept for each alloc and free.
441 dnl # Then at module unload time a report to the console will be printed
442 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
443 dnl # and provide an easy way to inspect the kmem based slab.
445 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
446 AC_ARG_ENABLE([debug-kmem],
447 [AS_HELP_STRING([--enable-debug-kmem],
448 [Enable basic kmem accounting @<:@default=yes@:>@])],
450 [enable_debug_kmem=yes])
452 AS_IF([test "x$enable_debug_kmem" = xyes],
453 [AC_DEFINE([DEBUG_KMEM], [1],
454 [Define to 1 to enable basic kmem accounting])
455 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"])
457 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
458 AC_MSG_RESULT([$enable_debug_kmem])
462 dnl # Disabled by default it provides detailed memory tracking. This
463 dnl # feature also requires --enable-debug-kmem to be set. When enabled
464 dnl # not only will total bytes be tracked but also the location of every
465 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
466 dnl # addresses and where they were allocated will be dumped to the console.
467 dnl # Enabling this feature has a significant impact on performance but it
468 dnl # makes finding memory leaks pretty straight forward.
470 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
471 AC_ARG_ENABLE([debug-kmem-tracking],
472 [AS_HELP_STRING([--enable-debug-kmem-tracking],
473 [Enable detailed kmem tracking @<:@default=no@:>@])],
475 [enable_debug_kmem_tracking=no])
477 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
478 [AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
479 [Define to 1 to enable detailed kmem tracking])
480 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"])
482 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
483 AC_MSG_RESULT([$enable_debug_kmem_tracking])
487 dnl # SPL_LINUX_CONFTEST
489 AC_DEFUN([SPL_LINUX_CONFTEST], [
490 cat confdefs.h - <<_ACEOF >conftest.c
496 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
498 m4_define([SPL_LANG_PROGRAM], [
503 dnl Do *not* indent the following line: there may be CPP directives.
504 dnl Don't move the `;' right after for the same reason.
512 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
514 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
515 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
516 rm -Rf build && mkdir -p build
517 echo "obj-m := conftest.o" >build/Makefile
519 [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])],
521 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
527 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
529 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
530 [SPL_LINUX_COMPILE_IFELSE(
531 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
533 [test -s build/conftest.o],
538 dnl # SPL_LINUX_CONFIG
540 AC_DEFUN([SPL_LINUX_CONFIG],
541 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
542 SPL_LINUX_TRY_COMPILE([
543 #include <linux/module.h>
546 #error CONFIG_$1 not #defined
558 dnl # SPL_CHECK_SYMBOL_EXPORT
559 dnl # check symbol exported or not
561 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
562 [AC_MSG_CHECKING([whether symbol $1 is exported])
563 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
564 $LINUX_OBJ/Module*.symvers 2>/dev/null
566 if test $rc -ne 0; then
569 grep -q -E "EXPORT_SYMBOL.*($1)" \
570 "$LINUX_OBJ/$file" 2>/dev/null
572 if test $rc -eq 0; then
577 if test $export -eq 0; then
591 dnl # SPL_CHECK_HEADER
592 dnl # check whether header exists and define HAVE_$2_HEADER
594 AC_DEFUN([SPL_CHECK_HEADER],
595 [AC_MSG_CHECKING([whether header $1 exists])
596 SPL_LINUX_TRY_COMPILE([
601 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
611 dnl # Use the atomic implemenation based on global spinlocks. This
612 dnl # should only be needed by 32-bit kernels which do not provide
613 dnl # the atomic64_* API. It may be optionally enabled as a fallback
614 dnl # if problems are observed with the direct mapping to the native
615 dnl # Linux atomic operations. You may not disable atomic spinlocks
616 dnl # if you kernel does not an atomic64_* API.
618 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
619 AC_ARG_ENABLE([atomic-spinlocks],
620 [AS_HELP_STRING([--enable-atomic-spinlocks],
621 [Atomic types use spinlocks @<:@default=check@:>@])],
623 [enable_atomic_spinlocks=check])
625 SPL_LINUX_TRY_COMPILE([
626 #include <asm/atomic.h>
628 atomic64_t *ptr __attribute__ ((unused));
631 AC_DEFINE(HAVE_ATOMIC64_T, 1,
632 [kernel defines atomic64_t])
637 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
638 AS_IF([test "x$have_atomic64_t" = xyes], [
639 enable_atomic_spinlocks=no
641 enable_atomic_spinlocks=yes
645 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
646 AC_DEFINE([ATOMIC_SPINLOCK], [1],
647 [Atomic types use spinlocks])
649 AS_IF([test "x$have_atomic64_t" = xno], [
651 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
655 AC_MSG_CHECKING([whether atomic types use spinlocks])
656 AC_MSG_RESULT([$enable_atomic_spinlocks])
658 AC_MSG_CHECKING([whether kernel defines atomic64_t])
659 AC_MSG_RESULT([$have_atomic64_t])
663 dnl # 2.6.24 API change,
664 dnl # check if atomic64_cmpxchg is defined
666 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
667 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
668 SPL_LINUX_TRY_COMPILE([
669 #include <asm/atomic.h>
670 #include <asm/system.h>
672 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
675 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
676 [kernel defines atomic64_cmpxchg])
683 dnl # 2.6.24 API change,
684 dnl # check if atomic64_xchg is defined
686 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
687 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
688 SPL_LINUX_TRY_COMPILE([
689 #include <asm/atomic.h>
691 atomic64_xchg((atomic64_t *)NULL, 0);
694 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
695 [kernel defines atomic64_xchg])
702 dnl # 2.6.24 API change,
703 dnl # check if uintptr_t typedef is defined
705 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
706 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
707 SPL_LINUX_TRY_COMPILE([
708 #include <linux/types.h>
710 uintptr_t *ptr __attribute__ ((unused));
713 AC_DEFINE(HAVE_UINTPTR_T, 1,
714 [kernel defines uintptr_t])
721 dnl # 2.6.20 API change,
722 dnl # INIT_WORK use 2 args and not store data inside
724 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
725 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
726 SPL_LINUX_TRY_COMPILE([
727 #include <linux/workqueue.h>
729 struct work_struct work __attribute__ ((unused));
730 INIT_WORK(&work, NULL, NULL);
733 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
734 [INIT_WORK wants 3 args])
741 dnl # 2.6.21 API change,
742 dnl # 'register_sysctl_table' use only one argument instead of two
744 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
745 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
746 SPL_LINUX_TRY_COMPILE([
747 #include <linux/sysctl.h>
749 (void) register_sysctl_table(NULL, 0);
752 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
753 [register_sysctl_table() wants 2 args])
760 dnl # 2.6.23 API change
761 dnl # Old set_shrinker API replaced with register_shrinker
763 AC_DEFUN([SPL_AC_SET_SHRINKER], [
764 AC_MSG_CHECKING([whether set_shrinker() available])
765 SPL_LINUX_TRY_COMPILE([
766 #include <linux/mm.h>
768 return set_shrinker(DEFAULT_SEEKS, NULL);
771 AC_DEFINE(HAVE_SET_SHRINKER, 1,
772 [set_shrinker() available])
779 dnl # 2.6.35 API change,
780 dnl # Add context to shrinker callback
782 AC_DEFUN([SPL_AC_3ARGS_SHRINKER_CALLBACK],
783 [AC_MSG_CHECKING([whether shrinker callback wants 3 args])
784 tmp_flags="$EXTRA_KCFLAGS"
785 EXTRA_KCFLAGS="-Werror"
786 SPL_LINUX_TRY_COMPILE([
787 #include <linux/mm.h>
789 int shrinker_cb(struct shrinker *, int, unsigned int);
791 struct shrinker cache_shrinker = {
792 .shrink = shrinker_cb,
793 .seeks = DEFAULT_SEEKS,
795 register_shrinker(&cache_shrinker);
798 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
799 [shrinker callback wants 3 args])
803 EXTRA_KCFLAGS="$tmp_flags"
807 dnl # 2.6.25 API change,
808 dnl # struct path entry added to struct nameidata
810 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
811 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
812 SPL_LINUX_TRY_COMPILE([
813 #include <linux/namei.h>
815 struct nameidata nd __attribute__ ((unused));
818 nd.path.dentry = NULL;
821 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
822 [struct path used in struct nameidata])
829 dnl # Custom SPL patch may export this system it is not required
831 AC_DEFUN([SPL_AC_TASK_CURR], [
832 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
833 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
838 dnl # 2.6.19 API change,
839 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
841 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
842 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
843 SPL_LINUX_TRY_COMPILE([
844 #include <linux/sysctl.h>
846 #ifndef CTL_UNNUMBERED
847 #error CTL_UNNUMBERED undefined
851 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
852 [unnumbered sysctl support exists])
859 dnl # 2.6.33 API change,
860 dnl # Removed .ctl_name from struct ctl_table.
862 AC_DEFUN([SPL_AC_CTL_NAME], [
863 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
864 SPL_LINUX_TRY_COMPILE([
865 #include <linux/sysctl.h>
867 struct ctl_table ctl __attribute__ ((unused));
871 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
878 dnl # 2.6.16 API change.
879 dnl # Check if 'fls64()' is available
881 AC_DEFUN([SPL_AC_FLS64],
882 [AC_MSG_CHECKING([whether fls64() is available])
883 SPL_LINUX_TRY_COMPILE([
884 #include <linux/bitops.h>
889 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
896 dnl # 2.6.18 API change, check whether device_create() is available.
897 dnl # Device_create() was introduced in 2.6.18 and depricated
898 dnl # class_device_create() which was fully removed in 2.6.26.
900 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
901 SPL_CHECK_SYMBOL_EXPORT(
903 [drivers/base/core.c],
904 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
905 [device_create() is available])],
910 dnl # 2.6.27 API change,
911 dnl # device_create() uses 5 args, new 'drvdata' argument.
913 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
914 AC_MSG_CHECKING([whether device_create() wants 5 args])
915 tmp_flags="$EXTRA_KCFLAGS"
916 EXTRA_KCFLAGS="-Werror"
917 SPL_LINUX_TRY_COMPILE([
918 #include <linux/device.h>
920 device_create(NULL, NULL, 0, NULL, "%d", 1);
923 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
924 [device_create wants 5 args])
928 EXTRA_KCFLAGS="$tmp_flags"
932 dnl # 2.6.13 API change, check whether class_device_create() is available.
933 dnl # Class_device_create() was introduced in 2.6.13 and depricated
934 dnl # class_simple_device_add() which was fully removed in 2.6.13.
936 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
937 SPL_CHECK_SYMBOL_EXPORT(
938 [class_device_create],
939 [drivers/base/class.c],
940 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
941 [class_device_create() is available])],
946 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
948 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
949 SPL_CHECK_SYMBOL_EXPORT(
950 [set_normalized_timespec],
952 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
953 [set_normalized_timespec() is available as export])],
958 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
959 dnl # previously it was available in time.h as an inline.
961 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
962 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
963 SPL_LINUX_TRY_COMPILE([
964 #include <linux/time.h>
965 void set_normalized_timespec(struct timespec *ts,
966 time_t sec, long nsec) { }
973 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
974 [set_normalized_timespec() is available as inline])
979 dnl # 2.6.18 API change,
980 dnl # timespec_sub() inline function available in linux/time.h
982 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
983 AC_MSG_CHECKING([whether timespec_sub() is available])
984 SPL_LINUX_TRY_COMPILE([
985 #include <linux/time.h>
987 struct timespec a = { 0 };
988 struct timespec b = { 0 };
989 struct timespec c __attribute__ ((unused));
990 c = timespec_sub(a, b);
993 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1000 dnl # 2.6.19 API change,
1001 dnl # check if init_utsname() is available in linux/utsname.h
1003 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
1004 AC_MSG_CHECKING([whether init_utsname() is available])
1005 SPL_LINUX_TRY_COMPILE([
1006 #include <linux/utsname.h>
1008 struct new_utsname *a __attribute__ ((unused));
1012 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1019 dnl # 2.6.26 API change,
1020 dnl # definition of struct fdtable relocated to linux/fdtable.h
1022 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
1023 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
1027 dnl # 2.6.14 API change,
1028 dnl # check whether 'files_fdtable()' exists
1030 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
1031 AC_MSG_CHECKING([whether files_fdtable() is available])
1032 SPL_LINUX_TRY_COMPILE([
1033 #include <linux/sched.h>
1034 #include <linux/file.h>
1035 #ifdef HAVE_FDTABLE_HEADER
1036 #include <linux/fdtable.h>
1039 struct files_struct *files = current->files;
1040 struct fdtable *fdt __attribute__ ((unused));
1041 fdt = files_fdtable(files);
1044 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
1051 dnl # 2.6.18 API change,
1052 dnl # added linux/uaccess.h
1054 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1055 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1059 dnl # 2.6.12 API change,
1060 dnl # check whether 'kmalloc_node()' is available.
1062 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1063 AC_MSG_CHECKING([whether kmalloc_node() is available])
1064 SPL_LINUX_TRY_COMPILE([
1065 #include <linux/slab.h>
1067 void *a __attribute__ ((unused));
1068 a = kmalloc_node(1, GFP_KERNEL, 0);
1071 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1078 dnl # 2.6.9 API change,
1079 dnl # check whether 'monotonic_clock()' is available it may
1080 dnl # be available for some archs but not others.
1082 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
1083 SPL_CHECK_SYMBOL_EXPORT(
1086 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1087 [monotonic_clock() is available])],
1092 dnl # 2.6.16 API change,
1093 dnl # check whether 'struct inode' has i_mutex
1095 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1096 AC_MSG_CHECKING([whether struct inode has i_mutex])
1097 SPL_LINUX_TRY_COMPILE([
1098 #include <linux/fs.h>
1099 #include <linux/mutex.h>
1102 mutex_init(&i.i_mutex);
1105 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1112 dnl # 2.6.29 API change,
1113 dnl # Adaptive mutexs introduced.
1115 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1116 AC_MSG_CHECKING([whether struct mutex has owner])
1117 SPL_LINUX_TRY_COMPILE([
1118 #include <linux/mutex.h>
1120 struct mutex mtx __attribute__ ((unused));
1124 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1131 dnl # 2.6.39 API change,
1132 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
1133 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
1134 dnl # was defined. As of 2.6.39 this was changed to a task_struct
1135 dnl # pointer which frankly makes a lot more sense.
1137 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
1138 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
1139 tmp_flags="$EXTRA_KCFLAGS"
1140 EXTRA_KCFLAGS="-Werror"
1141 SPL_LINUX_TRY_COMPILE([
1142 #include <linux/mutex.h>
1144 struct mutex mtx __attribute__ ((unused));
1145 mtx.owner = current;
1148 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
1149 [struct mutex owner is a task_struct])
1153 EXTRA_KCFLAGS="$tmp_flags"
1157 dnl # 2.6.18 API change,
1158 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1159 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1160 dnl # if the mutex validator is disabled or otherwise unavailable.
1162 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1163 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1164 SPL_LINUX_TRY_COMPILE([
1165 #include <linux/mutex.h>
1169 mutex_lock_nested(&mutex, 0);
1172 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1173 [mutex_lock_nested() is available])
1180 dnl # 2.6.27 API change,
1181 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1183 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1184 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1185 SPL_LINUX_TRY_COMPILE([
1186 #include <linux/smp.h>
1188 on_each_cpu(NULL, NULL, 0);
1191 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1192 [on_each_cpu wants 3 args])
1199 dnl # 2.6.18 API change,
1200 dnl # kallsyms_lookup_name no longer exported
1202 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
1203 SPL_CHECK_SYMBOL_EXPORT(
1204 [kallsyms_lookup_name],
1206 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1207 [kallsyms_lookup_name() is available])],
1212 dnl # Proposed API change,
1213 dnl # This symbol is not available in stock kernels. You may build a
1214 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1215 dnl # these symbols for use. If your already rolling a custom kernel for
1216 dnl # your environment this is recommended.
1218 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
1219 SPL_CHECK_SYMBOL_EXPORT(
1222 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1223 [get_vmalloc_info() is available])],
1228 dnl # 2.6.17 API change
1229 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1230 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1231 dnl # were exported in 2.6.17 for use by modules which was consistent with
1232 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1233 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1234 dnl # were dropped entirely leaving modules no way to directly iterate over
1235 dnl # the zone list. Because we need access to the zone helpers we check
1236 dnl # if the kernel contains the old or new implementation. Then we check
1237 dnl # to see if the symbols we need for each version are available. If they
1238 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1240 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1241 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1242 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1244 if test $rc -eq 0; then
1245 AC_MSG_RESULT([yes])
1246 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1253 dnl # Proposed API change,
1254 dnl # This symbol is not available in stock kernels. You may build a
1255 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1256 dnl # these symbols for use. If your already rolling a custom kernel for
1257 dnl # your environment this is recommended.
1259 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
1260 SPL_CHECK_SYMBOL_EXPORT(
1261 [first_online_pgdat],
1263 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1264 [first_online_pgdat() is available])],
1269 dnl # Proposed API change,
1270 dnl # This symbol is not available in stock kernels. You may build a
1271 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1272 dnl # these symbols for use. If your already rolling a custom kernel for
1273 dnl # your environment this is recommended.
1275 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
1276 SPL_CHECK_SYMBOL_EXPORT(
1277 [next_online_pgdat],
1279 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1280 [next_online_pgdat() is available])],
1285 dnl # Proposed API change,
1286 dnl # This symbol is not available in stock kernels. You may build a
1287 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1288 dnl # these symbols for use. If your already rolling a custom kernel for
1289 dnl # your environment this is recommended.
1291 AC_DEFUN([SPL_AC_NEXT_ZONE], [
1292 SPL_CHECK_SYMBOL_EXPORT(
1295 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1296 [next_zone() is available])],
1301 dnl # 2.6.17 API change,
1302 dnl # See SPL_AC_PGDAT_HELPERS for details.
1304 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1305 SPL_CHECK_SYMBOL_EXPORT(
1308 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1309 [pgdat_list is available])],
1314 dnl # 2.6.18 API change,
1315 dnl # First introduced global_page_state() support as an inline.
1317 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1318 AC_MSG_CHECKING([whether global_page_state() is available])
1319 SPL_LINUX_TRY_COMPILE([
1320 #include <linux/mm.h>
1322 unsigned long state __attribute__ ((unused));
1323 state = global_page_state(0);
1326 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1327 [global_page_state() is available])
1334 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1335 dnl # Public global zone stats now include a free page count. However
1336 dnl # the enumerated names of the counters have changed since this API
1337 dnl # was introduced. We need to deduce the corrent name to use. This
1338 dnl # replaces the priviate get_zone_counts() interface.
1340 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1341 dnl # is 2.6.30 as of when this was written.
1343 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1344 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1345 SPL_LINUX_TRY_COMPILE([
1346 #include <linux/mm.h>
1348 enum zone_stat_item zsi __attribute__ ((unused));
1349 zsi = NR_FREE_PAGES;
1352 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1353 [Page state NR_FREE_PAGES is available])
1360 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1361 dnl # Public global zone stats now include an inactive page count. However
1362 dnl # the enumerated names of the counters have changed since this API
1363 dnl # was introduced. We need to deduce the corrent name to use. This
1364 dnl # replaces the priviate get_zone_counts() interface.
1366 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1367 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1368 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1370 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1371 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1372 SPL_LINUX_TRY_COMPILE([
1373 #include <linux/mm.h>
1375 enum zone_stat_item zsi __attribute__ ((unused));
1379 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1380 [Page state NR_INACTIVE is available])
1385 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1386 SPL_LINUX_TRY_COMPILE([
1387 #include <linux/mm.h>
1389 enum zone_stat_item zsi __attribute__ ((unused));
1390 zsi = NR_INACTIVE_ANON;
1393 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1394 [Page state NR_INACTIVE_ANON is available])
1399 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1400 SPL_LINUX_TRY_COMPILE([
1401 #include <linux/mm.h>
1403 enum zone_stat_item zsi __attribute__ ((unused));
1404 zsi = NR_INACTIVE_FILE;
1407 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1408 [Page state NR_INACTIVE_FILE is available])
1415 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1416 dnl # Public global zone stats now include an active page count. However
1417 dnl # the enumerated names of the counters have changed since this API
1418 dnl # was introduced. We need to deduce the corrent name to use. This
1419 dnl # replaces the priviate get_zone_counts() interface.
1421 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1422 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1423 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1425 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1426 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1427 SPL_LINUX_TRY_COMPILE([
1428 #include <linux/mm.h>
1430 enum zone_stat_item zsi __attribute__ ((unused));
1434 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1435 [Page state NR_ACTIVE is available])
1440 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1441 SPL_LINUX_TRY_COMPILE([
1442 #include <linux/mm.h>
1444 enum zone_stat_item zsi __attribute__ ((unused));
1445 zsi = NR_ACTIVE_ANON;
1448 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1449 [Page state NR_ACTIVE_ANON is available])
1454 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1455 SPL_LINUX_TRY_COMPILE([
1456 #include <linux/mm.h>
1458 enum zone_stat_item zsi __attribute__ ((unused));
1459 zsi = NR_ACTIVE_FILE;
1462 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1463 [Page state NR_ACTIVE_FILE is available])
1470 dnl # Proposed API change for legacy kernels.
1471 dnl # This symbol is not available in older kernels. For kernels post
1472 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1473 dnl # page state information. This symbol is only used in legacy kernels
1474 dnl # any only as a last resort.
1476 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1477 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1478 SPL_LINUX_TRY_COMPILE([
1480 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1481 #error "global_page_state needs NR_FREE_PAGES"
1484 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1485 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1486 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1487 #error "global_page_state needs NR_ACTIVE*"
1490 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1491 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1492 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1493 #error "global_page_state needs NR_INACTIVE*"
1499 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1500 [get_zone_counts() is needed])
1502 SPL_CHECK_SYMBOL_EXPORT(
1505 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1506 [get_zone_counts() is available])],
1512 dnl # 2.6.27 API change,
1513 dnl # The user_path_dir() replaces __user_walk()
1515 AC_DEFUN([SPL_AC_USER_PATH_DIR], [
1516 SPL_CHECK_SYMBOL_EXPORT(
1519 [AC_DEFINE(HAVE_USER_PATH_DIR, 1,
1520 [user_path_dir() is available])],
1525 dnl # Symbol available in RHEL kernels not in stock kernels.
1527 AC_DEFUN([SPL_AC_SET_FS_PWD], [
1528 SPL_CHECK_SYMBOL_EXPORT(
1531 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1532 [set_fs_pwd() is available])],
1537 dnl # 2.6.25 API change,
1538 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1540 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1541 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1542 SPL_LINUX_TRY_COMPILE([
1543 #include <linux/sched.h>
1544 #include <linux/fs_struct.h>
1546 set_fs_pwd(NULL, NULL);
1549 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1550 [set_fs_pwd() wants 2 args])
1557 dnl # SLES API change, never adopted in mainline,
1558 dnl # Third 'struct vfsmount *' argument removed.
1560 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1561 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1562 SPL_LINUX_TRY_COMPILE([
1563 #include <linux/fs.h>
1565 vfs_unlink(NULL, NULL);
1568 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1569 [vfs_unlink() wants 2 args])
1576 dnl # SLES API change, never adopted in mainline,
1577 dnl # Third and sixth 'struct vfsmount *' argument removed.
1579 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1580 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1581 SPL_LINUX_TRY_COMPILE([
1582 #include <linux/fs.h>
1584 vfs_rename(NULL, NULL, NULL, NULL);
1587 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1588 [vfs_rename() wants 4 args])
1595 dnl # 2.6.36 API change,
1596 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1597 dnl # a spinlock_t to improve the fastpath performance.
1599 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1600 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1601 SPL_LINUX_TRY_COMPILE([
1602 #include <linux/sched.h>
1603 #include <linux/fs_struct.h>
1605 struct fs_struct fs;
1606 spin_lock_init(&fs.lock);
1609 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1610 [struct fs_struct uses spinlock_t])
1617 dnl # 2.6.29 API change,
1618 dnl # check whether 'struct cred' exists
1620 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1621 AC_MSG_CHECKING([whether struct cred exists])
1622 SPL_LINUX_TRY_COMPILE([
1623 #include <linux/cred.h>
1625 struct cred *cr __attribute__ ((unused));
1629 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1636 dnl # Custom SPL patch may export this symbol.
1638 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1639 SPL_CHECK_SYMBOL_EXPORT(
1642 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1643 [groups_search() is available])],
1648 dnl # 2.6.x API change,
1649 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1651 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1652 SPL_CHECK_SYMBOL_EXPORT(
1653 [__put_task_struct],
1655 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1656 [__put_task_struct() is available])],
1661 dnl # 2.6.32 API change,
1662 dnl # Unused 'struct file *' removed from prototype.
1664 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1665 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1666 SPL_LINUX_TRY_COMPILE([
1667 #include <linux/sysctl.h>
1669 proc_dostring(NULL, 0, NULL, NULL, NULL);
1672 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1673 [proc_handler() wants 5 args])
1680 dnl # 2.6.x API change,
1681 dnl # kvasprintf() function added.
1683 AC_DEFUN([SPL_AC_KVASPRINTF], [
1684 SPL_CHECK_SYMBOL_EXPORT(
1687 [AC_DEFINE(HAVE_KVASPRINTF, 1,
1688 [kvasprintf() is available])],
1693 dnl # 2.6.35 API change,
1694 dnl # Unused 'struct dentry *' removed from prototype.
1696 AC_DEFUN([SPL_AC_3ARGS_FILE_FSYNC], [
1697 AC_MSG_CHECKING([whether file_fsync() wants 3 args])
1698 SPL_LINUX_TRY_COMPILE([
1699 #include <linux/buffer_head.h>
1701 file_fsync(NULL, NULL, 0);
1704 AC_DEFINE(HAVE_3ARGS_FILE_FSYNC, 1,
1705 [file_fsync() wants 3 args])
1712 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
1713 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
1714 dnl # condition. The fixed version is exported as a symbol. The race
1715 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
1716 dnl # call that version while holding sem->wait_lock.
1718 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED], [
1719 SPL_CHECK_SYMBOL_EXPORT(
1721 [lib/rwsem-spinlock.c],
1722 [AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
1723 [rwsem_is_locked() acquires sem->wait_lock])],
1728 dnl # 2.6.37 API compat,
1729 dnl # The function invalidate_inodes() is no longer exported by the kernel.
1730 dnl # The prototype however is still available which means it is safe
1731 dnl # to acquire the symbol's address using spl_kallsyms_lookup_name().
1733 AC_DEFUN([SPL_AC_KERNEL_INVALIDATE_INODES], [
1734 SPL_CHECK_SYMBOL_EXPORT(
1735 [invalidate_inodes],
1737 [AC_DEFINE(HAVE_INVALIDATE_INODES, 1,
1738 [invalidate_inodes() is available])],
1743 dnl # 2.6.39 API compat,
1744 dnl # The function invalidate_inodes() now take 2 arguments. The second
1745 dnl # 'kill_dirty' argument describes how invalidate_inodes() should
1746 dnl # handle dirty inodes. Only when set will dirty inodes be discarded,
1747 dnl # otherwise they will be handled as busy.
1749 dnl # Unfortunately, we don't have access to the invalidate_inodes()
1750 dnl # prototype so it's not easy to check how many arguments it takes.
1751 dnl # However, this change was done for the benefit of invalidate_device()
1752 dnl # which also added an argument. The invalidate_device() symbol does
1753 dnl # exist in the development headers so if it takes two arguments we
1754 dnl # can fairly safely infer that invalidate_inodes() takes two arguments
1755 dnl # as well. See commit 93b270f76e7ef3b81001576860c2701931cdc78b.
1757 AC_DEFUN([SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES],
1758 [AC_MSG_CHECKING([whether invalidate_inodes() wants 2 args])
1759 SPL_LINUX_TRY_COMPILE([
1760 #include <linux/fs.h>
1762 return __invalidate_device(NULL, 0);
1765 AC_DEFINE(HAVE_2ARGS_INVALIDATE_INODES, 1,
1766 [invalidate_inodes() wants 2 args])
1773 dnl # 2.6.xx API compat,
1774 dnl # There currently exists no exposed API to partially shrink the dcache.
1775 dnl # The expected mechanism to shrink the cache is a registered shrinker
1776 dnl # which is called during memory pressure.
1778 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY], [
1779 SPL_CHECK_SYMBOL_EXPORT(
1780 [shrink_dcache_memory],
1782 [AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
1783 [shrink_dcache_memory() is available])],
1788 dnl # 2.6.xx API compat,
1789 dnl # There currently exists no exposed API to partially shrink the icache.
1790 dnl # The expected mechanism to shrink the cache is a registered shrinker
1791 dnl # which is called during memory pressure.
1793 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY], [
1794 SPL_CHECK_SYMBOL_EXPORT(
1795 [shrink_icache_memory],
1797 [AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
1798 [shrink_icache_memory() is available])],
1803 dnl # 2.6.39 API compat,
1804 dnl # The path_lookup() function has been renamed to kern_path_parent()
1805 dnl # and the flags argument has been removed. The only behavior now
1806 dnl # offered is that of LOOKUP_PARENT. The spl already always passed
1807 dnl # this flag so dropping the flag does not impact us.
1809 AC_DEFUN([SPL_AC_KERN_PATH_PARENT], [
1810 SPL_CHECK_SYMBOL_EXPORT(
1813 [AC_DEFINE(HAVE_KERN_PATH_PARENT, 1,
1814 [kern_path_parent() is available])],
1819 dnl # 2.6.39 API compat,
1820 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
1821 dnl # This was done to avoid always having to allocate the maximum size
1822 dnl # workspace (268K). The caller can now specific the windowBits and
1823 dnl # memLevel compression parameters to get a smaller workspace.
1825 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
1826 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
1827 SPL_LINUX_TRY_COMPILE([
1828 #include <linux/zlib.h>
1830 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
1833 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
1834 [zlib_deflate_workspacesize() wants 2 args])
1841 dnl # 2.6.39 API change,
1842 dnl # Shrinker adjust to use common shrink_control structure.
1844 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
1845 AC_MSG_CHECKING([whether struct shrink_control exists])
1846 SPL_LINUX_TRY_COMPILE([
1847 #include <linux/mm.h>
1849 struct shrink_control sc __attribute__ ((unused));
1852 sc.gfp_mask = GFP_KERNEL;
1855 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
1856 [struct shrink_control exists])