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
72 SPL_AC_2ARGS_VFS_FSYNC
73 SPL_AC_FS_STRUCT_SPINLOCK
76 SPL_AC_PUT_TASK_STRUCT
77 SPL_AC_5ARGS_PROC_HANDLER
79 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
80 SPL_AC_KERNEL_INVALIDATE_INODES
81 SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES
82 SPL_AC_SHRINK_DCACHE_MEMORY
83 SPL_AC_SHRINK_ICACHE_MEMORY
84 SPL_AC_KERN_PATH_PARENT_HEADER
85 SPL_AC_KERN_PATH_PARENT_SYMBOL
86 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
87 SPL_AC_SHRINK_CONTROL_STRUCT
88 SPL_AC_RWSEM_SPINLOCK_IS_RAW
91 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
92 modpost=$LINUX/scripts/Makefile.modpost
93 AC_MSG_CHECKING([kernel file name for module symbols])
94 if test -f "$modpost"; then
95 if grep -q Modules.symvers $modpost; then
96 LINUX_SYMBOLS=Modules.symvers
98 LINUX_SYMBOLS=Module.symvers
101 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
103 *** Please make sure the kernel devel package for your distribution
104 *** is installed. If your building with a custom kernel make sure the
105 *** kernel is configured, built, and the '--with-linux=PATH' configure
106 *** option refers to the location of the kernel source.])
111 AC_MSG_RESULT($LINUX_SYMBOLS)
112 AC_SUBST(LINUX_SYMBOLS)
115 AC_DEFUN([SPL_AC_KERNEL], [
117 AS_HELP_STRING([--with-linux=PATH],
118 [Path to kernel source]),
119 [kernelsrc="$withval"])
121 AC_ARG_WITH([linux-obj],
122 AS_HELP_STRING([--with-linux-obj=PATH],
123 [Path to kernel build objects]),
124 [kernelbuild="$withval"])
126 AC_MSG_CHECKING([kernel source directory])
127 if test -z "$kernelsrc"; then
128 if test -e "/lib/modules/$(uname -r)/source"; then
129 headersdir="/lib/modules/$(uname -r)/source"
130 sourcelink=$(readlink -f "$headersdir")
131 elif test -e "/lib/modules/$(uname -r)/build"; then
132 headersdir="/lib/modules/$(uname -r)/build"
133 sourcelink=$(readlink -f "$headersdir")
135 sourcelink=$(ls -1d /usr/src/kernels/* \
137 2>/dev/null | grep -v obj | tail -1)
140 if test -n "$sourcelink" && test -e ${sourcelink}; then
141 kernelsrc=`readlink -f ${sourcelink}`
143 AC_MSG_RESULT([Not found])
145 *** Please make sure the kernel devel package for your distribution
146 *** is installed then try again. If that fails you can specify the
147 *** location of the kernel source with the '--with-linux=PATH' option.])
150 if test "$kernelsrc" = "NONE"; then
155 AC_MSG_RESULT([$kernelsrc])
156 AC_MSG_CHECKING([kernel build directory])
157 if test -z "$kernelbuild"; then
158 if test -e "/lib/modules/$(uname -r)/build"; then
159 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
160 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
161 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
162 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
163 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
164 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
165 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
167 kernelbuild=${kernelsrc}
170 AC_MSG_RESULT([$kernelbuild])
172 AC_MSG_CHECKING([kernel source version])
173 utsrelease1=$kernelbuild/include/linux/version.h
174 utsrelease2=$kernelbuild/include/linux/utsrelease.h
175 utsrelease3=$kernelbuild/include/generated/utsrelease.h
176 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
177 utsrelease=linux/version.h
178 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
179 utsrelease=linux/utsrelease.h
180 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
181 utsrelease=generated/utsrelease.h
184 if test "$utsrelease"; then
185 kernsrcver=`(echo "#include <$utsrelease>";
186 echo "kernsrcver=UTS_RELEASE") |
187 cpp -I $kernelbuild/include |
188 grep "^kernsrcver=" | cut -d \" -f 2`
190 if test -z "$kernsrcver"; then
191 AC_MSG_RESULT([Not found])
192 AC_MSG_ERROR([*** Cannot determine kernel version.])
195 AC_MSG_RESULT([Not found])
196 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
199 AC_MSG_RESULT([$kernsrcver])
202 LINUX_OBJ=${kernelbuild}
203 LINUX_VERSION=${kernsrcver}
207 AC_SUBST(LINUX_VERSION)
209 SPL_AC_MODULE_SYMVERS
212 AC_DEFUN([SPL_AC_KERNEL_CONFIG], [
213 SPL_LINUX_CONFIG([PREEMPT],
215 *** Kernel built with CONFIG_PREEMPT which is not supported.
216 ** You must rebuild your kernel without this option.]), [])
220 dnl # Default SPL user configuration
222 AC_DEFUN([SPL_AC_CONFIG_USER], [])
225 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
226 dnl # are missing it is non-fatal but you will not be able to build
227 dnl # RPM packages and will be warned if you try too.
229 AC_DEFUN([SPL_AC_RPM], [
233 AC_MSG_CHECKING([whether $RPM is available])
234 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
235 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
237 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
240 AC_MSG_RESULT([$HAVE_RPM])
243 AC_MSG_CHECKING([whether $RPMBUILD is available])
244 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
245 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
247 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
250 AC_MSG_RESULT([$HAVE_RPMBUILD])
255 AC_SUBST(RPM_VERSION)
257 AC_SUBST(HAVE_RPMBUILD)
259 AC_SUBST(RPMBUILD_VERSION)
263 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
264 dnl # tools are missing it is non-fatal but you will not be able to build
265 dnl # DEB packages and will be warned if you try too.
267 AC_DEFUN([SPL_AC_DPKG], [
269 DPKGBUILD=dpkg-buildpackage
271 AC_MSG_CHECKING([whether $DPKG is available])
272 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
273 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
275 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
278 AC_MSG_RESULT([$HAVE_DPKG])
281 AC_MSG_CHECKING([whether $DPKGBUILD is available])
282 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
283 DPKGBUILD_VERSION=$(echo $tmp | \
284 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
286 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
289 AC_MSG_RESULT([$HAVE_DPKGBUILD])
294 AC_SUBST(DPKG_VERSION)
296 AC_SUBST(HAVE_DPKGBUILD)
298 AC_SUBST(DPKGBUILD_VERSION)
302 dnl # Check for pacman+makepkg to build Arch Linux packages. If these
303 dnl # tools are missing it is non-fatal but you will not be able to
304 dnl # build Arch Linux packages and will be warned if you try too.
306 AC_DEFUN([SPL_AC_PACMAN], [
310 AC_MSG_CHECKING([whether $PACMAN is available])
311 tmp=$($PACMAN --version 2>/dev/null)
312 AS_IF([test -n "$tmp"], [
313 PACMAN_VERSION=$(echo $tmp |
314 $AWK '/Pacman/ { print $[3] }' |
317 AC_MSG_RESULT([$HAVE_PACMAN ($PACMAN_VERSION)])
320 AC_MSG_RESULT([$HAVE_PACMAN])
323 AC_MSG_CHECKING([whether $MAKEPKG is available])
324 tmp=$($MAKEPKG --version 2>/dev/null)
325 AS_IF([test -n "$tmp"], [
326 MAKEPKG_VERSION=$(echo $tmp | $AWK '/makepkg/ { print $[3] }')
328 AC_MSG_RESULT([$HAVE_MAKEPKG ($MAKEPKG_VERSION)])
331 AC_MSG_RESULT([$HAVE_MAKEPKG])
334 AC_SUBST(HAVE_PACMAN)
336 AC_SUBST(PACMAN_VERSION)
338 AC_SUBST(HAVE_MAKEPKG)
340 AC_SUBST(MAKEPKG_VERSION)
344 dnl # Until native packaging for various different packing systems
345 dnl # can be added the least we can do is attempt to use alien to
346 dnl # convert the RPM packages to the needed package type. This is
347 dnl # a hack but so far it has worked reasonable well.
349 AC_DEFUN([SPL_AC_ALIEN], [
352 AC_MSG_CHECKING([whether $ALIEN is available])
353 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
354 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
356 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
359 AC_MSG_RESULT([$HAVE_ALIEN])
364 AC_SUBST(ALIEN_VERSION)
368 dnl # Using the VENDOR tag from config.guess set the default
369 dnl # package type for 'make pkg': (rpm | deb | tgz)
371 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
372 AC_MSG_CHECKING([linux distribution])
373 if test -f /etc/redhat-release ; then
375 elif test -f /etc/fedora-release ; then
377 elif test -f /etc/arch-release ; then
379 elif test -f /etc/lsb-release ; then
381 elif test -f /etc/debian_version ; then
383 elif test -f /etc/SuSE-release ; then
385 elif test -f /etc/slackware-version ; then
387 elif test -f /etc/gentoo-release ; then
392 AC_MSG_RESULT([$VENDOR])
395 AC_MSG_CHECKING([default package type])
397 fedora) DEFAULT_PACKAGE=rpm ;;
398 redhat) DEFAULT_PACKAGE=rpm ;;
399 sles) DEFAULT_PACKAGE=rpm ;;
400 ubuntu) DEFAULT_PACKAGE=deb ;;
401 debian) DEFAULT_PACKAGE=deb ;;
402 slackware) DEFAULT_PACKAGE=tgz ;;
403 arch) DEFAULT_PACKAGE=arch;;
404 *) DEFAULT_PACKAGE=rpm ;;
407 AC_MSG_RESULT([$DEFAULT_PACKAGE])
408 AC_SUBST(DEFAULT_PACKAGE)
412 dnl # Default SPL user configuration
414 AC_DEFUN([SPL_AC_PACKAGE], [
419 SPL_AC_DEFAULT_PACKAGE
422 AC_DEFUN([SPL_AC_LICENSE], [
423 AC_MSG_CHECKING([spl license])
425 AC_MSG_RESULT([$LICENSE])
426 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
430 AC_DEFUN([SPL_AC_CONFIG], [
432 AC_ARG_WITH([config],
433 AS_HELP_STRING([--with-config=CONFIG],
434 [Config file 'kernel|user|all|srpm']),
435 [SPL_CONFIG="$withval"])
437 AC_MSG_CHECKING([spl config])
438 AC_MSG_RESULT([$SPL_CONFIG]);
441 case "$SPL_CONFIG" in
442 kernel) SPL_AC_CONFIG_KERNEL ;;
443 user) SPL_AC_CONFIG_USER ;;
444 all) SPL_AC_CONFIG_KERNEL
445 SPL_AC_CONFIG_USER ;;
448 AC_MSG_RESULT([Error!])
449 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
450 user kernel|user|all|srpm]) ;;
453 AM_CONDITIONAL([CONFIG_USER],
454 [test "$SPL_CONFIG" = user] ||
455 [test "$SPL_CONFIG" = all])
456 AM_CONDITIONAL([CONFIG_KERNEL],
457 [test "$SPL_CONFIG" = kernel] ||
458 [test "$SPL_CONFIG" = all])
462 dnl # Enable if the SPL should be compiled with internal debugging enabled.
463 dnl # By default this support is disabled.
465 AC_DEFUN([SPL_AC_DEBUG], [
466 AC_MSG_CHECKING([whether debugging is enabled])
467 AC_ARG_ENABLE([debug],
468 [AS_HELP_STRING([--enable-debug],
469 [Enable generic debug support @<:@default=no@:>@])],
473 AS_IF([test "x$enable_debug" = xyes],
475 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
476 DEBUG_CFLAGS="-DDEBUG -Werror"
479 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
480 DEBUG_CFLAGS="-DNDEBUG"
483 AC_SUBST(DEBUG_CFLAGS)
484 AC_MSG_RESULT([$enable_debug])
488 dnl # Enabled by default it provides a minimal level of memory tracking.
489 dnl # A total count of bytes allocated is kept for each alloc and free.
490 dnl # Then at module unload time a report to the console will be printed
491 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
492 dnl # and provide an easy way to inspect the kmem based slab.
494 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
495 AC_ARG_ENABLE([debug-kmem],
496 [AS_HELP_STRING([--enable-debug-kmem],
497 [Enable basic kmem accounting @<:@default=yes@:>@])],
499 [enable_debug_kmem=yes])
501 AS_IF([test "x$enable_debug_kmem" = xyes],
502 [AC_DEFINE([DEBUG_KMEM], [1],
503 [Define to 1 to enable basic kmem accounting])
504 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"])
506 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
507 AC_MSG_RESULT([$enable_debug_kmem])
511 dnl # Disabled by default it provides detailed memory tracking. This
512 dnl # feature also requires --enable-debug-kmem to be set. When enabled
513 dnl # not only will total bytes be tracked but also the location of every
514 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
515 dnl # addresses and where they were allocated will be dumped to the console.
516 dnl # Enabling this feature has a significant impact on performance but it
517 dnl # makes finding memory leaks pretty straight forward.
519 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
520 AC_ARG_ENABLE([debug-kmem-tracking],
521 [AS_HELP_STRING([--enable-debug-kmem-tracking],
522 [Enable detailed kmem tracking @<:@default=no@:>@])],
524 [enable_debug_kmem_tracking=no])
526 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
527 [AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
528 [Define to 1 to enable detailed kmem tracking])
529 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"])
531 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
532 AC_MSG_RESULT([$enable_debug_kmem_tracking])
536 dnl # SPL_LINUX_CONFTEST
538 AC_DEFUN([SPL_LINUX_CONFTEST], [
539 cat confdefs.h - <<_ACEOF >conftest.c
545 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
547 m4_define([SPL_LANG_PROGRAM], [
552 dnl Do *not* indent the following line: there may be CPP directives.
553 dnl Don't move the `;' right after for the same reason.
561 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
563 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
564 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
565 rm -Rf build && mkdir -p build
566 echo "obj-m := conftest.o" >build/Makefile
568 [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])],
570 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
576 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
578 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
579 [SPL_LINUX_COMPILE_IFELSE(
580 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
582 [test -s build/conftest.o],
587 dnl # SPL_LINUX_CONFIG
589 AC_DEFUN([SPL_LINUX_CONFIG],
590 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
591 SPL_LINUX_TRY_COMPILE([
592 #include <linux/module.h>
595 #error CONFIG_$1 not #defined
607 dnl # SPL_CHECK_SYMBOL_EXPORT
608 dnl # check symbol exported or not
610 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
611 [AC_MSG_CHECKING([whether symbol $1 is exported])
612 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
613 $LINUX_OBJ/Module*.symvers 2>/dev/null
615 if test $rc -ne 0; then
618 grep -q -E "EXPORT_SYMBOL.*($1)" \
619 "$LINUX_OBJ/$file" 2>/dev/null
621 if test $rc -eq 0; then
626 if test $export -eq 0; then
640 dnl # SPL_CHECK_SYMBOL_HEADER
641 dnl # check if a symbol prototype is defined in listed headers.
643 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
644 AC_MSG_CHECKING([whether symbol $1 exists in header])
647 grep -q "$2" "$LINUX/$file" 2>/dev/null
649 if test $rc -eq 0; then
654 if test $header -eq 0; then
664 dnl # SPL_CHECK_HEADER
665 dnl # check whether header exists and define HAVE_$2_HEADER
667 AC_DEFUN([SPL_CHECK_HEADER],
668 [AC_MSG_CHECKING([whether header $1 exists])
669 SPL_LINUX_TRY_COMPILE([
674 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
684 dnl # Use the atomic implemenation based on global spinlocks. This
685 dnl # should only be needed by 32-bit kernels which do not provide
686 dnl # the atomic64_* API. It may be optionally enabled as a fallback
687 dnl # if problems are observed with the direct mapping to the native
688 dnl # Linux atomic operations. You may not disable atomic spinlocks
689 dnl # if you kernel does not an atomic64_* API.
691 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
692 AC_ARG_ENABLE([atomic-spinlocks],
693 [AS_HELP_STRING([--enable-atomic-spinlocks],
694 [Atomic types use spinlocks @<:@default=check@:>@])],
696 [enable_atomic_spinlocks=check])
698 SPL_LINUX_TRY_COMPILE([
699 #include <asm/atomic.h>
701 atomic64_t *ptr __attribute__ ((unused));
704 AC_DEFINE(HAVE_ATOMIC64_T, 1,
705 [kernel defines atomic64_t])
710 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
711 AS_IF([test "x$have_atomic64_t" = xyes], [
712 enable_atomic_spinlocks=no
714 enable_atomic_spinlocks=yes
718 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
719 AC_DEFINE([ATOMIC_SPINLOCK], [1],
720 [Atomic types use spinlocks])
722 AS_IF([test "x$have_atomic64_t" = xno], [
724 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
728 AC_MSG_CHECKING([whether atomic types use spinlocks])
729 AC_MSG_RESULT([$enable_atomic_spinlocks])
731 AC_MSG_CHECKING([whether kernel defines atomic64_t])
732 AC_MSG_RESULT([$have_atomic64_t])
736 dnl # 2.6.24 API change,
737 dnl # check if atomic64_cmpxchg is defined
739 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
740 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
741 SPL_LINUX_TRY_COMPILE([
742 #include <asm/atomic.h>
743 #include <asm/system.h>
745 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
748 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
749 [kernel defines atomic64_cmpxchg])
756 dnl # 2.6.24 API change,
757 dnl # check if atomic64_xchg is defined
759 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
760 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
761 SPL_LINUX_TRY_COMPILE([
762 #include <asm/atomic.h>
764 atomic64_xchg((atomic64_t *)NULL, 0);
767 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
768 [kernel defines atomic64_xchg])
775 dnl # 2.6.24 API change,
776 dnl # check if uintptr_t typedef is defined
778 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
779 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
780 SPL_LINUX_TRY_COMPILE([
781 #include <linux/types.h>
783 uintptr_t *ptr __attribute__ ((unused));
786 AC_DEFINE(HAVE_UINTPTR_T, 1,
787 [kernel defines uintptr_t])
794 dnl # 2.6.20 API change,
795 dnl # INIT_WORK use 2 args and not store data inside
797 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
798 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
799 SPL_LINUX_TRY_COMPILE([
800 #include <linux/workqueue.h>
802 struct work_struct work __attribute__ ((unused));
803 INIT_WORK(&work, NULL, NULL);
806 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
807 [INIT_WORK wants 3 args])
814 dnl # 2.6.21 API change,
815 dnl # 'register_sysctl_table' use only one argument instead of two
817 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
818 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
819 SPL_LINUX_TRY_COMPILE([
820 #include <linux/sysctl.h>
822 (void) register_sysctl_table(NULL, 0);
825 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
826 [register_sysctl_table() wants 2 args])
833 dnl # 2.6.23 API change
834 dnl # Old set_shrinker API replaced with register_shrinker
836 AC_DEFUN([SPL_AC_SET_SHRINKER], [
837 AC_MSG_CHECKING([whether set_shrinker() available])
838 SPL_LINUX_TRY_COMPILE([
839 #include <linux/mm.h>
841 return set_shrinker(DEFAULT_SEEKS, NULL);
844 AC_DEFINE(HAVE_SET_SHRINKER, 1,
845 [set_shrinker() available])
852 dnl # 2.6.35 API change,
853 dnl # Add context to shrinker callback
855 AC_DEFUN([SPL_AC_3ARGS_SHRINKER_CALLBACK],
856 [AC_MSG_CHECKING([whether shrinker callback wants 3 args])
857 tmp_flags="$EXTRA_KCFLAGS"
858 EXTRA_KCFLAGS="-Werror"
859 SPL_LINUX_TRY_COMPILE([
860 #include <linux/mm.h>
862 int shrinker_cb(struct shrinker *, int, unsigned int);
864 struct shrinker cache_shrinker = {
865 .shrink = shrinker_cb,
866 .seeks = DEFAULT_SEEKS,
868 register_shrinker(&cache_shrinker);
871 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
872 [shrinker callback wants 3 args])
876 EXTRA_KCFLAGS="$tmp_flags"
880 dnl # 2.6.25 API change,
881 dnl # struct path entry added to struct nameidata
883 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
884 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
885 SPL_LINUX_TRY_COMPILE([
886 #include <linux/namei.h>
888 struct nameidata nd __attribute__ ((unused));
891 nd.path.dentry = NULL;
894 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
895 [struct path used in struct nameidata])
902 dnl # Custom SPL patch may export this system it is not required
904 AC_DEFUN([SPL_AC_TASK_CURR], [
905 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
906 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
911 dnl # 2.6.19 API change,
912 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
914 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
915 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
916 SPL_LINUX_TRY_COMPILE([
917 #include <linux/sysctl.h>
919 #ifndef CTL_UNNUMBERED
920 #error CTL_UNNUMBERED undefined
924 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
925 [unnumbered sysctl support exists])
932 dnl # 2.6.33 API change,
933 dnl # Removed .ctl_name from struct ctl_table.
935 AC_DEFUN([SPL_AC_CTL_NAME], [
936 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
937 SPL_LINUX_TRY_COMPILE([
938 #include <linux/sysctl.h>
940 struct ctl_table ctl __attribute__ ((unused));
944 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
951 dnl # 2.6.16 API change.
952 dnl # Check if 'fls64()' is available
954 AC_DEFUN([SPL_AC_FLS64],
955 [AC_MSG_CHECKING([whether fls64() is available])
956 SPL_LINUX_TRY_COMPILE([
957 #include <linux/bitops.h>
962 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
969 dnl # 2.6.18 API change, check whether device_create() is available.
970 dnl # Device_create() was introduced in 2.6.18 and depricated
971 dnl # class_device_create() which was fully removed in 2.6.26.
973 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
974 SPL_CHECK_SYMBOL_EXPORT(
976 [drivers/base/core.c],
977 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
978 [device_create() is available])],
983 dnl # 2.6.27 API change,
984 dnl # device_create() uses 5 args, new 'drvdata' argument.
986 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
987 AC_MSG_CHECKING([whether device_create() wants 5 args])
988 tmp_flags="$EXTRA_KCFLAGS"
989 EXTRA_KCFLAGS="-Werror"
990 SPL_LINUX_TRY_COMPILE([
991 #include <linux/device.h>
993 device_create(NULL, NULL, 0, NULL, "%d", 1);
996 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
997 [device_create wants 5 args])
1001 EXTRA_KCFLAGS="$tmp_flags"
1005 dnl # 2.6.13 API change, check whether class_device_create() is available.
1006 dnl # Class_device_create() was introduced in 2.6.13 and depricated
1007 dnl # class_simple_device_add() which was fully removed in 2.6.13.
1009 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
1010 SPL_CHECK_SYMBOL_EXPORT(
1011 [class_device_create],
1012 [drivers/base/class.c],
1013 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
1014 [class_device_create() is available])],
1019 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
1021 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
1022 SPL_CHECK_SYMBOL_EXPORT(
1023 [set_normalized_timespec],
1025 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
1026 [set_normalized_timespec() is available as export])],
1031 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
1032 dnl # previously it was available in time.h as an inline.
1034 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
1035 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
1036 SPL_LINUX_TRY_COMPILE([
1037 #include <linux/time.h>
1038 void set_normalized_timespec(struct timespec *ts,
1039 time_t sec, long nsec) { }
1046 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
1047 [set_normalized_timespec() is available as inline])
1052 dnl # 2.6.18 API change,
1053 dnl # timespec_sub() inline function available in linux/time.h
1055 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
1056 AC_MSG_CHECKING([whether timespec_sub() is available])
1057 SPL_LINUX_TRY_COMPILE([
1058 #include <linux/time.h>
1060 struct timespec a = { 0 };
1061 struct timespec b = { 0 };
1062 struct timespec c __attribute__ ((unused));
1063 c = timespec_sub(a, b);
1066 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1073 dnl # 2.6.19 API change,
1074 dnl # check if init_utsname() is available in linux/utsname.h
1076 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
1077 AC_MSG_CHECKING([whether init_utsname() is available])
1078 SPL_LINUX_TRY_COMPILE([
1079 #include <linux/utsname.h>
1081 struct new_utsname *a __attribute__ ((unused));
1085 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1092 dnl # 2.6.26 API change,
1093 dnl # definition of struct fdtable relocated to linux/fdtable.h
1095 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
1096 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
1100 dnl # 2.6.14 API change,
1101 dnl # check whether 'files_fdtable()' exists
1103 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
1104 AC_MSG_CHECKING([whether files_fdtable() is available])
1105 SPL_LINUX_TRY_COMPILE([
1106 #include <linux/sched.h>
1107 #include <linux/file.h>
1108 #ifdef HAVE_FDTABLE_HEADER
1109 #include <linux/fdtable.h>
1112 struct files_struct *files = current->files;
1113 struct fdtable *fdt __attribute__ ((unused));
1114 fdt = files_fdtable(files);
1117 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
1124 dnl # 2.6.18 API change,
1125 dnl # added linux/uaccess.h
1127 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1128 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1132 dnl # 2.6.12 API change,
1133 dnl # check whether 'kmalloc_node()' is available.
1135 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1136 AC_MSG_CHECKING([whether kmalloc_node() is available])
1137 SPL_LINUX_TRY_COMPILE([
1138 #include <linux/slab.h>
1140 void *a __attribute__ ((unused));
1141 a = kmalloc_node(1, GFP_KERNEL, 0);
1144 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1151 dnl # 2.6.9 API change,
1152 dnl # check whether 'monotonic_clock()' is available it may
1153 dnl # be available for some archs but not others.
1155 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
1156 SPL_CHECK_SYMBOL_EXPORT(
1159 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1160 [monotonic_clock() is available])],
1165 dnl # 2.6.16 API change,
1166 dnl # check whether 'struct inode' has i_mutex
1168 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1169 AC_MSG_CHECKING([whether struct inode has i_mutex])
1170 SPL_LINUX_TRY_COMPILE([
1171 #include <linux/fs.h>
1172 #include <linux/mutex.h>
1175 mutex_init(&i.i_mutex);
1178 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1185 dnl # 2.6.29 API change,
1186 dnl # Adaptive mutexs introduced.
1188 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1189 AC_MSG_CHECKING([whether struct mutex has owner])
1190 SPL_LINUX_TRY_COMPILE([
1191 #include <linux/mutex.h>
1193 struct mutex mtx __attribute__ ((unused));
1197 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1204 dnl # 2.6.39 API change,
1205 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
1206 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
1207 dnl # was defined. As of 2.6.39 this was changed to a task_struct
1208 dnl # pointer which frankly makes a lot more sense.
1210 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
1211 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
1212 tmp_flags="$EXTRA_KCFLAGS"
1213 EXTRA_KCFLAGS="-Werror"
1214 SPL_LINUX_TRY_COMPILE([
1215 #include <linux/mutex.h>
1217 struct mutex mtx __attribute__ ((unused));
1218 mtx.owner = current;
1221 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
1222 [struct mutex owner is a task_struct])
1226 EXTRA_KCFLAGS="$tmp_flags"
1230 dnl # 2.6.18 API change,
1231 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1232 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1233 dnl # if the mutex validator is disabled or otherwise unavailable.
1235 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1236 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1237 SPL_LINUX_TRY_COMPILE([
1238 #include <linux/mutex.h>
1242 mutex_lock_nested(&mutex, 0);
1245 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1246 [mutex_lock_nested() is available])
1253 dnl # 2.6.27 API change,
1254 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1256 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1257 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1258 SPL_LINUX_TRY_COMPILE([
1259 #include <linux/smp.h>
1261 on_each_cpu(NULL, NULL, 0);
1264 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1265 [on_each_cpu wants 3 args])
1272 dnl # 2.6.18 API change,
1273 dnl # kallsyms_lookup_name no longer exported
1275 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
1276 SPL_CHECK_SYMBOL_EXPORT(
1277 [kallsyms_lookup_name],
1279 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1280 [kallsyms_lookup_name() 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_GET_VMALLOC_INFO], [
1292 SPL_CHECK_SYMBOL_EXPORT(
1295 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1296 [get_vmalloc_info() is available])],
1301 dnl # 2.6.17 API change
1302 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1303 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1304 dnl # were exported in 2.6.17 for use by modules which was consistent with
1305 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1306 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1307 dnl # were dropped entirely leaving modules no way to directly iterate over
1308 dnl # the zone list. Because we need access to the zone helpers we check
1309 dnl # if the kernel contains the old or new implementation. Then we check
1310 dnl # to see if the symbols we need for each version are available. If they
1311 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1313 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1314 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1315 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1317 if test $rc -eq 0; then
1318 AC_MSG_RESULT([yes])
1319 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1326 dnl # Proposed API change,
1327 dnl # This symbol is not available in stock kernels. You may build a
1328 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1329 dnl # these symbols for use. If your already rolling a custom kernel for
1330 dnl # your environment this is recommended.
1332 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
1333 SPL_CHECK_SYMBOL_EXPORT(
1334 [first_online_pgdat],
1336 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1337 [first_online_pgdat() is available])],
1342 dnl # Proposed API change,
1343 dnl # This symbol is not available in stock kernels. You may build a
1344 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1345 dnl # these symbols for use. If your already rolling a custom kernel for
1346 dnl # your environment this is recommended.
1348 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
1349 SPL_CHECK_SYMBOL_EXPORT(
1350 [next_online_pgdat],
1352 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1353 [next_online_pgdat() is available])],
1358 dnl # Proposed API change,
1359 dnl # This symbol is not available in stock kernels. You may build a
1360 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1361 dnl # these symbols for use. If your already rolling a custom kernel for
1362 dnl # your environment this is recommended.
1364 AC_DEFUN([SPL_AC_NEXT_ZONE], [
1365 SPL_CHECK_SYMBOL_EXPORT(
1368 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1369 [next_zone() is available])],
1374 dnl # 2.6.17 API change,
1375 dnl # See SPL_AC_PGDAT_HELPERS for details.
1377 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1378 SPL_CHECK_SYMBOL_EXPORT(
1381 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1382 [pgdat_list is available])],
1387 dnl # 2.6.18 API change,
1388 dnl # First introduced global_page_state() support as an inline.
1390 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1391 AC_MSG_CHECKING([whether global_page_state() is available])
1392 SPL_LINUX_TRY_COMPILE([
1393 #include <linux/mm.h>
1395 unsigned long state __attribute__ ((unused));
1396 state = global_page_state(0);
1399 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1400 [global_page_state() is available])
1407 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1408 dnl # Public global zone stats now include a free page count. However
1409 dnl # the enumerated names of the counters have changed since this API
1410 dnl # was introduced. We need to deduce the corrent name to use. This
1411 dnl # replaces the priviate get_zone_counts() interface.
1413 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1414 dnl # is 2.6.30 as of when this was written.
1416 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1417 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1418 SPL_LINUX_TRY_COMPILE([
1419 #include <linux/mm.h>
1421 enum zone_stat_item zsi __attribute__ ((unused));
1422 zsi = NR_FREE_PAGES;
1425 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1426 [Page state NR_FREE_PAGES is available])
1433 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1434 dnl # Public global zone stats now include an inactive page count. However
1435 dnl # the enumerated names of the counters have changed since this API
1436 dnl # was introduced. We need to deduce the corrent name to use. This
1437 dnl # replaces the priviate get_zone_counts() interface.
1439 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1440 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1441 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1443 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1444 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1445 SPL_LINUX_TRY_COMPILE([
1446 #include <linux/mm.h>
1448 enum zone_stat_item zsi __attribute__ ((unused));
1452 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1453 [Page state NR_INACTIVE is available])
1458 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1459 SPL_LINUX_TRY_COMPILE([
1460 #include <linux/mm.h>
1462 enum zone_stat_item zsi __attribute__ ((unused));
1463 zsi = NR_INACTIVE_ANON;
1466 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1467 [Page state NR_INACTIVE_ANON is available])
1472 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1473 SPL_LINUX_TRY_COMPILE([
1474 #include <linux/mm.h>
1476 enum zone_stat_item zsi __attribute__ ((unused));
1477 zsi = NR_INACTIVE_FILE;
1480 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1481 [Page state NR_INACTIVE_FILE is available])
1488 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1489 dnl # Public global zone stats now include an active page count. However
1490 dnl # the enumerated names of the counters have changed since this API
1491 dnl # was introduced. We need to deduce the corrent name to use. This
1492 dnl # replaces the priviate get_zone_counts() interface.
1494 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1495 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1496 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1498 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1499 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1500 SPL_LINUX_TRY_COMPILE([
1501 #include <linux/mm.h>
1503 enum zone_stat_item zsi __attribute__ ((unused));
1507 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1508 [Page state NR_ACTIVE is available])
1513 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1514 SPL_LINUX_TRY_COMPILE([
1515 #include <linux/mm.h>
1517 enum zone_stat_item zsi __attribute__ ((unused));
1518 zsi = NR_ACTIVE_ANON;
1521 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1522 [Page state NR_ACTIVE_ANON is available])
1527 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1528 SPL_LINUX_TRY_COMPILE([
1529 #include <linux/mm.h>
1531 enum zone_stat_item zsi __attribute__ ((unused));
1532 zsi = NR_ACTIVE_FILE;
1535 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1536 [Page state NR_ACTIVE_FILE is available])
1543 dnl # Proposed API change for legacy kernels.
1544 dnl # This symbol is not available in older kernels. For kernels post
1545 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1546 dnl # page state information. This symbol is only used in legacy kernels
1547 dnl # any only as a last resort.
1549 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1550 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1551 SPL_LINUX_TRY_COMPILE([
1553 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1554 #error "global_page_state needs NR_FREE_PAGES"
1557 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1558 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1559 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1560 #error "global_page_state needs NR_ACTIVE*"
1563 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1564 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1565 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1566 #error "global_page_state needs NR_INACTIVE*"
1572 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1573 [get_zone_counts() is needed])
1575 SPL_CHECK_SYMBOL_EXPORT(
1578 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1579 [get_zone_counts() is available])],
1585 dnl # 2.6.27 API change,
1586 dnl # The user_path_dir() replaces __user_walk()
1588 AC_DEFUN([SPL_AC_USER_PATH_DIR], [
1589 SPL_CHECK_SYMBOL_EXPORT(
1592 [AC_DEFINE(HAVE_USER_PATH_DIR, 1,
1593 [user_path_dir() is available])],
1598 dnl # Symbol available in RHEL kernels not in stock kernels.
1600 AC_DEFUN([SPL_AC_SET_FS_PWD], [
1601 SPL_CHECK_SYMBOL_EXPORT(
1604 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1605 [set_fs_pwd() is available])],
1610 dnl # 2.6.25 API change,
1611 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1613 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1614 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1615 SPL_LINUX_TRY_COMPILE([
1616 #include <linux/sched.h>
1617 #include <linux/fs_struct.h>
1619 set_fs_pwd(NULL, NULL);
1622 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1623 [set_fs_pwd() wants 2 args])
1630 dnl # SLES API change, never adopted in mainline,
1631 dnl # Third 'struct vfsmount *' argument removed.
1633 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1634 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1635 SPL_LINUX_TRY_COMPILE([
1636 #include <linux/fs.h>
1638 vfs_unlink(NULL, NULL);
1641 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1642 [vfs_unlink() wants 2 args])
1649 dnl # SLES API change, never adopted in mainline,
1650 dnl # Third and sixth 'struct vfsmount *' argument removed.
1652 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1653 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1654 SPL_LINUX_TRY_COMPILE([
1655 #include <linux/fs.h>
1657 vfs_rename(NULL, NULL, NULL, NULL);
1660 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1661 [vfs_rename() wants 4 args])
1668 dnl # 2.6.36 API change,
1669 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1670 dnl # a spinlock_t to improve the fastpath performance.
1672 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1673 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1674 tmp_flags="$EXTRA_KCFLAGS"
1675 EXTRA_KCFLAGS="-Werror"
1676 SPL_LINUX_TRY_COMPILE([
1677 #include <linux/sched.h>
1678 #include <linux/fs_struct.h>
1680 struct fs_struct fs;
1681 spin_lock_init(&fs.lock);
1684 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1685 [struct fs_struct uses spinlock_t])
1689 EXTRA_KCFLAGS="$tmp_flags"
1693 dnl # 2.6.29 API change,
1694 dnl # check whether 'struct cred' exists
1696 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1697 AC_MSG_CHECKING([whether struct cred exists])
1698 SPL_LINUX_TRY_COMPILE([
1699 #include <linux/cred.h>
1701 struct cred *cr __attribute__ ((unused));
1705 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1712 dnl # Custom SPL patch may export this symbol.
1714 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1715 SPL_CHECK_SYMBOL_EXPORT(
1718 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1719 [groups_search() is available])],
1724 dnl # 2.6.x API change,
1725 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1727 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1728 SPL_CHECK_SYMBOL_EXPORT(
1729 [__put_task_struct],
1731 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1732 [__put_task_struct() is available])],
1737 dnl # 2.6.32 API change,
1738 dnl # Unused 'struct file *' removed from prototype.
1740 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1741 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1742 SPL_LINUX_TRY_COMPILE([
1743 #include <linux/sysctl.h>
1745 proc_dostring(NULL, 0, NULL, NULL, NULL);
1748 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1749 [proc_handler() wants 5 args])
1756 dnl # 2.6.x API change,
1757 dnl # kvasprintf() function added.
1759 AC_DEFUN([SPL_AC_KVASPRINTF], [
1760 SPL_CHECK_SYMBOL_EXPORT(
1763 [AC_DEFINE(HAVE_KVASPRINTF, 1,
1764 [kvasprintf() is available])],
1769 dnl # 2.6.29 API change,
1770 dnl # vfs_fsync() funcation added, prior to this use file_fsync().
1772 AC_DEFUN([SPL_AC_VFS_FSYNC], [
1773 SPL_CHECK_SYMBOL_EXPORT(
1776 [AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])],
1781 dnl # 2.6.35 API change,
1782 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
1784 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
1785 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
1786 SPL_LINUX_TRY_COMPILE([
1787 #include <linux/fs.h>
1792 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
1799 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
1800 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
1801 dnl # condition. The fixed version is exported as a symbol. The race
1802 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
1803 dnl # call that version while holding sem->wait_lock.
1805 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED], [
1806 SPL_CHECK_SYMBOL_EXPORT(
1808 [lib/rwsem-spinlock.c],
1809 [AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
1810 [rwsem_is_locked() acquires sem->wait_lock])],
1815 dnl # 2.6.37 API compat,
1816 dnl # The function invalidate_inodes() is no longer exported by the kernel.
1817 dnl # The prototype however is still available which means it is safe
1818 dnl # to acquire the symbol's address using spl_kallsyms_lookup_name().
1820 dnl # The Proxmox VE kernel contains a patch which renames the function
1821 dnl # invalidate_inodes() to invalidate_inodes_check(). In the process
1822 dnl # it adds a 'check' argument and a '#define invalidate_inodes(x)'
1823 dnl # compatibility wrapper for legacy callers. Therefore, if either
1824 dnl # of these functions are exported invalidate_inodes() can be
1827 AC_DEFUN([SPL_AC_KERNEL_INVALIDATE_INODES], [
1828 SPL_CHECK_SYMBOL_EXPORT(
1829 [invalidate_inodes],
1831 [AC_DEFINE(HAVE_INVALIDATE_INODES, 1,
1832 [invalidate_inodes() is available])],
1834 SPL_CHECK_SYMBOL_EXPORT(
1835 [invalidate_inodes_check],
1837 [AC_DEFINE(HAVE_INVALIDATE_INODES_CHECK, 1,
1838 [invalidate_inodes_check() is available])],
1843 dnl # 2.6.39 API compat,
1844 dnl # The function invalidate_inodes() now take 2 arguments. The second
1845 dnl # 'kill_dirty' argument describes how invalidate_inodes() should
1846 dnl # handle dirty inodes. Only when set will dirty inodes be discarded,
1847 dnl # otherwise they will be handled as busy.
1849 dnl # Unfortunately, we don't have access to the invalidate_inodes()
1850 dnl # prototype so it's not easy to check how many arguments it takes.
1851 dnl # However, this change was done for the benefit of invalidate_device()
1852 dnl # which also added an argument. The invalidate_device() symbol does
1853 dnl # exist in the development headers so if it takes two arguments we
1854 dnl # can fairly safely infer that invalidate_inodes() takes two arguments
1855 dnl # as well. See commit 93b270f76e7ef3b81001576860c2701931cdc78b.
1857 AC_DEFUN([SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES],
1858 [AC_MSG_CHECKING([whether invalidate_inodes() wants 2 args])
1859 SPL_LINUX_TRY_COMPILE([
1860 #include <linux/fs.h>
1862 return __invalidate_device(NULL, 0);
1865 AC_DEFINE(HAVE_2ARGS_INVALIDATE_INODES, 1,
1866 [invalidate_inodes() wants 2 args])
1873 dnl # 2.6.xx API compat,
1874 dnl # There currently exists no exposed API to partially shrink the dcache.
1875 dnl # The expected mechanism to shrink the cache is a registered shrinker
1876 dnl # which is called during memory pressure.
1878 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY], [
1879 SPL_CHECK_SYMBOL_EXPORT(
1880 [shrink_dcache_memory],
1882 [AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
1883 [shrink_dcache_memory() is available])],
1888 dnl # 2.6.xx API compat,
1889 dnl # There currently exists no exposed API to partially shrink the icache.
1890 dnl # The expected mechanism to shrink the cache is a registered shrinker
1891 dnl # which is called during memory pressure.
1893 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY], [
1894 SPL_CHECK_SYMBOL_EXPORT(
1895 [shrink_icache_memory],
1897 [AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
1898 [shrink_icache_memory() is available])],
1903 dnl # 2.6.39 API compat,
1904 dnl # The path_lookup() function has been renamed to kern_path_parent()
1905 dnl # and the flags argument has been removed. The only behavior now
1906 dnl # offered is that of LOOKUP_PARENT. The spl already always passed
1907 dnl # this flag so dropping the flag does not impact us.
1909 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_HEADER], [
1910 SPL_CHECK_SYMBOL_HEADER(
1912 [int kern_path_parent(const char \*, struct nameidata \*)],
1913 [include/linux/namei.h],
1914 [AC_DEFINE(HAVE_KERN_PATH_PARENT_HEADER, 1,
1915 [kern_path_parent() is available])],
1920 dnl # 3.1 API compat,
1921 dnl # The kern_path_parent() symbol is no longer exported by the kernel.
1922 dnl # However, it remains the prefered interface and since we still have
1923 dnl # access to the prototype we dynamically lookup the required address.
1925 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_SYMBOL], [
1926 SPL_CHECK_SYMBOL_EXPORT(
1929 [AC_DEFINE(HAVE_KERN_PATH_PARENT_SYMBOL, 1,
1930 [kern_path_parent() is available])],
1935 dnl # 2.6.39 API compat,
1936 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
1937 dnl # This was done to avoid always having to allocate the maximum size
1938 dnl # workspace (268K). The caller can now specific the windowBits and
1939 dnl # memLevel compression parameters to get a smaller workspace.
1941 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
1942 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
1943 SPL_LINUX_TRY_COMPILE([
1944 #include <linux/zlib.h>
1946 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
1949 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
1950 [zlib_deflate_workspacesize() wants 2 args])
1957 dnl # 2.6.39 API change,
1958 dnl # Shrinker adjust to use common shrink_control structure.
1960 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
1961 AC_MSG_CHECKING([whether struct shrink_control exists])
1962 SPL_LINUX_TRY_COMPILE([
1963 #include <linux/mm.h>
1965 struct shrink_control sc __attribute__ ((unused));
1968 sc.gfp_mask = GFP_KERNEL;
1971 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
1972 [struct shrink_control exists])
1979 dnl # 3.1 API Change
1981 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
1982 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
1984 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
1985 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
1986 tmp_flags="$EXTRA_KCFLAGS"
1987 EXTRA_KCFLAGS="-Werror"
1988 SPL_LINUX_TRY_COMPILE([
1989 #include <linux/rwsem.h>
1991 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
1992 raw_spinlock_t dummy_lock __attribute__ ((unused));
1993 dummy_semaphore.wait_lock = dummy_lock;
1996 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
1997 [struct rw_semaphore member wait_lock is raw_spinlock_t])
2001 EXTRA_KCFLAGS="$tmp_flags"