1 ###############################################################################
2 # Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
3 # Copyright (C) 2007 The Regents of the University of California.
4 # Written by Brian Behlendorf <behlendorf1@llnl.gov>.
5 ###############################################################################
6 # SPL_AC_CONFIG_KERNEL: Default SPL kernel configuration.
7 ###############################################################################
9 AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
13 if test "${LINUX_OBJ}" != "${LINUX}"; then
14 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
16 AC_SUBST(KERNELMAKE_PARAMS)
18 KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes"
19 AC_SUBST(KERNELCPPFLAGS)
23 SPL_AC_DEBUG_KMEM_TRACKING
24 SPL_AC_ATOMIC_SPINLOCK
25 SPL_AC_TYPE_ATOMIC64_CMPXCHG
26 SPL_AC_TYPE_ATOMIC64_XCHG
28 SPL_AC_3ARGS_INIT_WORK
29 SPL_AC_2ARGS_REGISTER_SYSCTL
31 SPL_AC_3ARGS_SHRINKER_CALLBACK
32 SPL_AC_PATH_IN_NAMEIDATA
38 SPL_AC_5ARGS_DEVICE_CREATE
39 SPL_AC_CLASS_DEVICE_CREATE
40 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
41 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
48 SPL_AC_MONOTONIC_CLOCK
51 SPL_AC_MUTEX_LOCK_NESTED
52 SPL_AC_3ARGS_ON_EACH_CPU
53 SPL_AC_KALLSYMS_LOOKUP_NAME
54 SPL_AC_GET_VMALLOC_INFO
56 SPL_AC_FIRST_ONLINE_PGDAT
57 SPL_AC_NEXT_ONLINE_PGDAT
60 SPL_AC_GLOBAL_PAGE_STATE
61 SPL_AC_ZONE_STAT_ITEM_FREE
62 SPL_AC_ZONE_STAT_ITEM_INACTIVE
63 SPL_AC_ZONE_STAT_ITEM_ACTIVE
64 SPL_AC_GET_ZONE_COUNTS
67 SPL_AC_2ARGS_SET_FS_PWD
68 SPL_AC_2ARGS_VFS_UNLINK
69 SPL_AC_4ARGS_VFS_RENAME
70 SPL_AC_FS_STRUCT_SPINLOCK
73 SPL_AC_PUT_TASK_STRUCT
74 SPL_AC_5ARGS_PROC_HANDLER
76 SPL_AC_3ARGS_FILE_FSYNC
77 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
78 SPL_AC_KERNEL_INVALIDATE_INODES
79 SPL_AC_SHRINK_DCACHE_MEMORY
80 SPL_AC_SHRINK_ICACHE_MEMORY
83 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
84 modpost=$LINUX/scripts/Makefile.modpost
85 AC_MSG_CHECKING([kernel file name for module symbols])
86 if test -f "$modpost"; then
87 if grep -q Modules.symvers $modpost; then
88 LINUX_SYMBOLS=Modules.symvers
90 LINUX_SYMBOLS=Module.symvers
93 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
95 *** Please make sure the kernel devel package for your distribution
96 *** is installed. If your building with a custom kernel make sure the
97 *** kernel is configured, built, and the '--with-linux=PATH' configure
98 *** option refers to the location of the kernel source.])
103 AC_MSG_RESULT($LINUX_SYMBOLS)
104 AC_SUBST(LINUX_SYMBOLS)
107 AC_DEFUN([SPL_AC_KERNEL], [
109 AS_HELP_STRING([--with-linux=PATH],
110 [Path to kernel source]),
111 [kernelsrc="$withval"])
113 AC_ARG_WITH([linux-obj],
114 AS_HELP_STRING([--with-linux-obj=PATH],
115 [Path to kernel build objects]),
116 [kernelbuild="$withval"])
118 AC_MSG_CHECKING([kernel source directory])
119 if test -z "$kernelsrc"; then
120 if test -e "/lib/modules/$(uname -r)/source"; then
121 headersdir="/lib/modules/$(uname -r)/source"
122 sourcelink=$(readlink -f "$headersdir")
123 elif test -e "/lib/modules/$(uname -r)/build"; then
124 headersdir="/lib/modules/$(uname -r)/build"
125 sourcelink=$(readlink -f "$headersdir")
127 sourcelink=$(ls -1d /usr/src/kernels/* \
129 2>/dev/null | grep -v obj | tail -1)
132 if test -n "$sourcelink" && test -e ${sourcelink}; then
133 kernelsrc=`readlink -f ${sourcelink}`
135 AC_MSG_RESULT([Not found])
137 *** Please make sure the kernel devel package for your distribution
138 *** is installed then try again. If that fails you can specify the
139 *** location of the kernel source with the '--with-linux=PATH' option.])
142 if test "$kernelsrc" = "NONE"; then
147 AC_MSG_RESULT([$kernelsrc])
148 AC_MSG_CHECKING([kernel build directory])
149 if test -z "$kernelbuild"; then
150 if test -e "/lib/modules/$(uname -r)/build"; then
151 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
152 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
153 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
154 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
155 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
156 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
157 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
159 kernelbuild=${kernelsrc}
162 AC_MSG_RESULT([$kernelbuild])
164 AC_MSG_CHECKING([kernel source version])
165 utsrelease1=$kernelbuild/include/linux/version.h
166 utsrelease2=$kernelbuild/include/linux/utsrelease.h
167 utsrelease3=$kernelbuild/include/generated/utsrelease.h
168 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
169 utsrelease=linux/version.h
170 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
171 utsrelease=linux/utsrelease.h
172 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
173 utsrelease=generated/utsrelease.h
176 if test "$utsrelease"; then
177 kernsrcver=`(echo "#include <$utsrelease>";
178 echo "kernsrcver=UTS_RELEASE") |
179 cpp -I $kernelbuild/include |
180 grep "^kernsrcver=" | cut -d \" -f 2`
182 if test -z "$kernsrcver"; then
183 AC_MSG_RESULT([Not found])
184 AC_MSG_ERROR([*** Cannot determine kernel version.])
187 AC_MSG_RESULT([Not found])
188 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
191 AC_MSG_RESULT([$kernsrcver])
194 LINUX_OBJ=${kernelbuild}
195 LINUX_VERSION=${kernsrcver}
199 AC_SUBST(LINUX_VERSION)
201 SPL_AC_MODULE_SYMVERS
204 AC_DEFUN([SPL_AC_KERNEL_CONFIG], [
205 SPL_LINUX_CONFIG([PREEMPT],
207 *** Kernel built with CONFIG_PREEMPT which is not supported.
208 ** You must rebuild your kernel without this option.]), [])
212 dnl # Explicitly check for gawk, we require it for the the usermode
213 dnl # helper. For some reason the standard awk command does not
214 dnl # behave correctly when invoked from the usermode helper.
216 AC_DEFUN([SPL_AC_GAWK], [
217 AS_IF([test "x$AWK" != xgawk], [
219 *** Required util gawk missing. Please install the required
220 *** gawk package for your distribution and try again.])
225 dnl # Default SPL user configuration
227 AC_DEFUN([SPL_AC_CONFIG_USER], [
232 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
233 dnl # are missing it is non-fatal but you will not be able to build
234 dnl # RPM packages and will be warned if you try too.
236 AC_DEFUN([SPL_AC_RPM], [
240 AC_MSG_CHECKING([whether $RPM is available])
241 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
242 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
244 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
247 AC_MSG_RESULT([$HAVE_RPM])
250 AC_MSG_CHECKING([whether $RPMBUILD is available])
251 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
252 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
254 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
257 AC_MSG_RESULT([$HAVE_RPMBUILD])
262 AC_SUBST(RPM_VERSION)
264 AC_SUBST(HAVE_RPMBUILD)
266 AC_SUBST(RPMBUILD_VERSION)
270 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
271 dnl # tools are missing it is non-fatal but you will not be able to build
272 dnl # DEB packages and will be warned if you try too.
274 AC_DEFUN([SPL_AC_DPKG], [
276 DPKGBUILD=dpkg-buildpackage
278 AC_MSG_CHECKING([whether $DPKG is available])
279 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
280 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
282 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
285 AC_MSG_RESULT([$HAVE_DPKG])
288 AC_MSG_CHECKING([whether $DPKGBUILD is available])
289 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
290 DPKGBUILD_VERSION=$(echo $tmp | \
291 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
293 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
296 AC_MSG_RESULT([$HAVE_DPKGBUILD])
301 AC_SUBST(DPKG_VERSION)
303 AC_SUBST(HAVE_DPKGBUILD)
305 AC_SUBST(DPKGBUILD_VERSION)
309 dnl # Until native packaging for various different packing systems
310 dnl # can be added the least we can do is attempt to use alien to
311 dnl # convert the RPM packages to the needed package type. This is
312 dnl # a hack but so far it has worked reasonable well.
314 AC_DEFUN([SPL_AC_ALIEN], [
317 AC_MSG_CHECKING([whether $ALIEN is available])
318 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
319 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
321 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
324 AC_MSG_RESULT([$HAVE_ALIEN])
329 AC_SUBST(ALIEN_VERSION)
333 dnl # Using the VENDOR tag from config.guess set the default
334 dnl # package type for 'make pkg': (rpm | deb | tgz)
336 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
337 AC_MSG_CHECKING([linux distribution])
338 if test -f /etc/redhat-release ; then
340 elif test -f /etc/fedora-release ; then
342 elif test -f /etc/lsb-release ; then
344 elif test -f /etc/debian_version ; then
346 elif test -f /etc/SuSE-release ; then
348 elif test -f /etc/slackware-version ; then
350 elif test -f /etc/gentoo-release ; then
355 AC_MSG_RESULT([$VENDOR])
358 AC_MSG_CHECKING([default package type])
360 fedora) DEFAULT_PACKAGE=rpm ;;
361 redhat) DEFAULT_PACKAGE=rpm ;;
362 sles) DEFAULT_PACKAGE=rpm ;;
363 ubuntu) DEFAULT_PACKAGE=deb ;;
364 debian) DEFAULT_PACKAGE=deb ;;
365 slackware) DEFAULT_PACKAGE=tgz ;;
366 *) DEFAULT_PACKAGE=rpm ;;
369 AC_MSG_RESULT([$DEFAULT_PACKAGE])
370 AC_SUBST(DEFAULT_PACKAGE)
374 dnl # Default SPL user configuration
376 AC_DEFUN([SPL_AC_PACKAGE], [
380 SPL_AC_DEFAULT_PACKAGE
383 AC_DEFUN([SPL_AC_LICENSE], [
384 AC_MSG_CHECKING([spl license])
386 AC_MSG_RESULT([$LICENSE])
387 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
391 AC_DEFUN([SPL_AC_CONFIG], [
393 AC_ARG_WITH([config],
394 AS_HELP_STRING([--with-config=CONFIG],
395 [Config file 'kernel|user|all|srpm']),
396 [SPL_CONFIG="$withval"])
398 AC_MSG_CHECKING([spl config])
399 AC_MSG_RESULT([$SPL_CONFIG]);
402 case "$SPL_CONFIG" in
403 kernel) SPL_AC_CONFIG_KERNEL ;;
404 user) SPL_AC_CONFIG_USER ;;
405 all) SPL_AC_CONFIG_KERNEL
406 SPL_AC_CONFIG_USER ;;
409 AC_MSG_RESULT([Error!])
410 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
411 user kernel|user|all|srpm]) ;;
414 AM_CONDITIONAL([CONFIG_USER],
415 [test "$SPL_CONFIG" = user] ||
416 [test "$SPL_CONFIG" = all])
417 AM_CONDITIONAL([CONFIG_KERNEL],
418 [test "$SPL_CONFIG" = kernel] ||
419 [test "$SPL_CONFIG" = all])
423 dnl # Enable if the SPL should be compiled with internal debugging enabled.
424 dnl # By default this support is disabled.
426 AC_DEFUN([SPL_AC_DEBUG], [
427 AC_MSG_CHECKING([whether debugging is enabled])
428 AC_ARG_ENABLE([debug],
429 [AS_HELP_STRING([--enable-debug],
430 [Enable generic debug support @<:@default=no@:>@])],
434 AS_IF([test "x$enable_debug" = xyes],
436 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
437 DEBUG_CFLAGS="-DDEBUG -Werror"
440 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
441 DEBUG_CFLAGS="-DNDEBUG"
444 AC_SUBST(DEBUG_CFLAGS)
445 AC_MSG_RESULT([$enable_debug])
449 dnl # Enabled by default it provides a minimal level of memory tracking.
450 dnl # A total count of bytes allocated is kept for each alloc and free.
451 dnl # Then at module unload time a report to the console will be printed
452 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
453 dnl # and provide an easy way to inspect the kmem based slab.
455 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
456 AC_ARG_ENABLE([debug-kmem],
457 [AS_HELP_STRING([--enable-debug-kmem],
458 [Enable basic kmem accounting @<:@default=yes@:>@])],
460 [enable_debug_kmem=yes])
462 AS_IF([test "x$enable_debug_kmem" = xyes],
463 [AC_DEFINE([DEBUG_KMEM], [1],
464 [Define to 1 to enable basic kmem accounting])
465 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"])
467 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
468 AC_MSG_RESULT([$enable_debug_kmem])
472 dnl # Disabled by default it provides detailed memory tracking. This
473 dnl # feature also requires --enable-debug-kmem to be set. When enabled
474 dnl # not only will total bytes be tracked but also the location of every
475 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
476 dnl # addresses and where they were allocated will be dumped to the console.
477 dnl # Enabling this feature has a significant impact on performance but it
478 dnl # makes finding memory leaks pretty straight forward.
480 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
481 AC_ARG_ENABLE([debug-kmem-tracking],
482 [AS_HELP_STRING([--enable-debug-kmem-tracking],
483 [Enable detailed kmem tracking @<:@default=no@:>@])],
485 [enable_debug_kmem_tracking=no])
487 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
488 [AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
489 [Define to 1 to enable detailed kmem tracking])
490 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"])
492 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
493 AC_MSG_RESULT([$enable_debug_kmem_tracking])
497 dnl # SPL_LINUX_CONFTEST
499 AC_DEFUN([SPL_LINUX_CONFTEST], [
500 cat confdefs.h - <<_ACEOF >conftest.c
506 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
508 m4_define([SPL_LANG_PROGRAM], [
513 dnl Do *not* indent the following line: there may be CPP directives.
514 dnl Don't move the `;' right after for the same reason.
522 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
524 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
525 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
526 rm -Rf build && mkdir -p build
527 echo "obj-m := conftest.o" >build/Makefile
529 [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])],
531 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
537 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
539 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
540 [SPL_LINUX_COMPILE_IFELSE(
541 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
543 [test -s build/conftest.o],
548 dnl # SPL_LINUX_CONFIG
550 AC_DEFUN([SPL_LINUX_CONFIG],
551 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
552 SPL_LINUX_TRY_COMPILE([
553 #ifndef AUTOCONF_INCLUDED
554 #include <linux/config.h>
558 #error CONFIG_$1 not #defined
570 dnl # SPL_CHECK_SYMBOL_EXPORT
571 dnl # check symbol exported or not
573 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
574 [AC_MSG_CHECKING([whether symbol $1 is exported])
575 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
576 $LINUX_OBJ/Module*.symvers 2>/dev/null
578 if test $rc -ne 0; then
581 grep -q -E "EXPORT_SYMBOL.*($1)" \
582 "$LINUX_OBJ/$file" 2>/dev/null
584 if test $rc -eq 0; then
589 if test $export -eq 0; then
603 dnl # SPL_CHECK_HEADER
604 dnl # check whether header exists and define HAVE_$2_HEADER
606 AC_DEFUN([SPL_CHECK_HEADER],
607 [AC_MSG_CHECKING([whether header $1 exists])
608 SPL_LINUX_TRY_COMPILE([
613 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
623 dnl # Use the atomic implemenation based on global spinlocks. This
624 dnl # should only be needed by 32-bit kernels which do not provide
625 dnl # the atomic64_* API. It may be optionally enabled as a fallback
626 dnl # if problems are observed with the direct mapping to the native
627 dnl # Linux atomic operations. You may not disable atomic spinlocks
628 dnl # if you kernel does not an atomic64_* API.
630 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
631 AC_ARG_ENABLE([atomic-spinlocks],
632 [AS_HELP_STRING([--enable-atomic-spinlocks],
633 [Atomic types use spinlocks @<:@default=check@:>@])],
635 [enable_atomic_spinlocks=check])
637 SPL_LINUX_TRY_COMPILE([
638 #include <asm/atomic.h>
643 AC_DEFINE(HAVE_ATOMIC64_T, 1,
644 [kernel defines atomic64_t])
649 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
650 AS_IF([test "x$have_atomic64_t" = xyes], [
651 enable_atomic_spinlocks=no
653 enable_atomic_spinlocks=yes
657 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
658 AC_DEFINE([ATOMIC_SPINLOCK], [1],
659 [Atomic types use spinlocks])
661 AS_IF([test "x$have_atomic64_t" = xno], [
663 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
667 AC_MSG_CHECKING([whether atomic types use spinlocks])
668 AC_MSG_RESULT([$enable_atomic_spinlocks])
670 AC_MSG_CHECKING([whether kernel defines atomic64_t])
671 AC_MSG_RESULT([$have_atomic64_t])
675 dnl # 2.6.24 API change,
676 dnl # check if atomic64_cmpxchg is defined
678 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
679 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
680 SPL_LINUX_TRY_COMPILE([
681 #include <asm/atomic.h>
682 #include <asm/system.h>
684 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
687 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
688 [kernel defines atomic64_cmpxchg])
695 dnl # 2.6.24 API change,
696 dnl # check if atomic64_xchg is defined
698 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
699 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
700 SPL_LINUX_TRY_COMPILE([
701 #include <asm/atomic.h>
703 atomic64_xchg((atomic64_t *)NULL, 0);
706 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
707 [kernel defines atomic64_xchg])
714 dnl # 2.6.24 API change,
715 dnl # check if uintptr_t typedef is defined
717 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
718 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
719 SPL_LINUX_TRY_COMPILE([
720 #include <linux/types.h>
725 AC_DEFINE(HAVE_UINTPTR_T, 1,
726 [kernel defines uintptr_t])
733 dnl # 2.6.20 API change,
734 dnl # INIT_WORK use 2 args and not store data inside
736 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
737 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
738 SPL_LINUX_TRY_COMPILE([
739 #include <linux/workqueue.h>
741 struct work_struct work;
742 INIT_WORK(&work, NULL, NULL);
745 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
746 [INIT_WORK wants 3 args])
753 dnl # 2.6.21 API change,
754 dnl # 'register_sysctl_table' use only one argument instead of two
756 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
757 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
758 SPL_LINUX_TRY_COMPILE([
759 #include <linux/sysctl.h>
761 return register_sysctl_table(NULL,0);
764 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
765 [register_sysctl_table() wants 2 args])
772 dnl # 2.6.23 API change
773 dnl # Old set_shrinker API replaced with register_shrinker
775 AC_DEFUN([SPL_AC_SET_SHRINKER], [
776 AC_MSG_CHECKING([whether set_shrinker() available])
777 SPL_LINUX_TRY_COMPILE([
778 #include <linux/mm.h>
780 return set_shrinker(DEFAULT_SEEKS, NULL);
783 AC_DEFINE(HAVE_SET_SHRINKER, 1,
784 [set_shrinker() available])
791 dnl # 2.6.35 API change,
792 dnl # Add context to shrinker callback
794 AC_DEFUN([SPL_AC_3ARGS_SHRINKER_CALLBACK],
795 [AC_MSG_CHECKING([whether shrinker callback wants 3 args])
796 tmp_flags="$EXTRA_KCFLAGS"
797 EXTRA_KCFLAGS="-Werror"
798 SPL_LINUX_TRY_COMPILE([
799 #include <linux/mm.h>
801 int shrinker_cb(struct shrinker *, int, unsigned int);
803 struct shrinker cache_shrinker = {
804 .shrink = shrinker_cb,
805 .seeks = DEFAULT_SEEKS,
807 register_shrinker(&cache_shrinker);
810 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
811 [shrinker callback wants 3 args])
815 EXTRA_KCFLAGS="$tmp_flags"
819 dnl # 2.6.25 API change,
820 dnl # struct path entry added to struct nameidata
822 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
823 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
824 SPL_LINUX_TRY_COMPILE([
825 #include <linux/namei.h>
830 nd.path.dentry = NULL;
833 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
834 [struct path used in struct nameidata])
841 dnl # Custom SPL patch may export this system it is not required
843 AC_DEFUN([SPL_AC_TASK_CURR], [
844 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
845 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
850 dnl # 2.6.19 API change,
851 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
853 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
854 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
855 SPL_LINUX_TRY_COMPILE([
856 #include <linux/sysctl.h>
858 #ifndef CTL_UNNUMBERED
859 #error CTL_UNNUMBERED undefined
863 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
864 [unnumbered sysctl support exists])
871 dnl # 2.6.33 API change,
872 dnl # Removed .ctl_name from struct ctl_table.
874 AC_DEFUN([SPL_AC_CTL_NAME], [
875 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
876 SPL_LINUX_TRY_COMPILE([
877 #include <linux/sysctl.h>
879 struct ctl_table ctl;
883 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
890 dnl # 2.6.16 API change.
891 dnl # Check if 'fls64()' is available
893 AC_DEFUN([SPL_AC_FLS64],
894 [AC_MSG_CHECKING([whether fls64() is available])
895 SPL_LINUX_TRY_COMPILE([
896 #include <linux/bitops.h>
901 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
908 dnl # 2.6.18 API change, check whether device_create() is available.
909 dnl # Device_create() was introduced in 2.6.18 and depricated
910 dnl # class_device_create() which was fully removed in 2.6.26.
912 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
913 SPL_CHECK_SYMBOL_EXPORT(
915 [drivers/base/core.c],
916 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
917 [device_create() is available])],
922 dnl # 2.6.27 API change,
923 dnl # device_create() uses 5 args, new 'drvdata' argument.
925 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
926 AC_MSG_CHECKING([whether device_create() wants 5 args])
927 tmp_flags="$EXTRA_KCFLAGS"
928 EXTRA_KCFLAGS="-Werror"
929 SPL_LINUX_TRY_COMPILE([
930 #include <linux/device.h>
932 device_create(NULL, NULL, 0, NULL, "%d", 1);
935 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
936 [device_create wants 5 args])
940 EXTRA_KCFLAGS="$tmp_flags"
944 dnl # 2.6.13 API change, check whether class_device_create() is available.
945 dnl # Class_device_create() was introduced in 2.6.13 and depricated
946 dnl # class_simple_device_add() which was fully removed in 2.6.13.
948 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
949 SPL_CHECK_SYMBOL_EXPORT(
950 [class_device_create],
951 [drivers/base/class.c],
952 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
953 [class_device_create() is available])],
958 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
960 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
961 SPL_CHECK_SYMBOL_EXPORT(
962 [set_normalized_timespec],
964 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
965 [set_normalized_timespec() is available as export])],
970 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
971 dnl # previously it was available in time.h as an inline.
973 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
974 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
975 SPL_LINUX_TRY_COMPILE([
976 #include <linux/time.h>
977 void set_normalized_timespec(struct timespec *ts,
978 time_t sec, long nsec) { }
985 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
986 [set_normalized_timespec() is available as inline])
991 dnl # 2.6.18 API change,
992 dnl # timespec_sub() inline function available in linux/time.h
994 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
995 AC_MSG_CHECKING([whether timespec_sub() is available])
996 SPL_LINUX_TRY_COMPILE([
997 #include <linux/time.h>
999 struct timespec a, b, c = { 0 };
1000 c = timespec_sub(a, b);
1003 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1010 dnl # 2.6.19 API change,
1011 dnl # check if init_utsname() is available in linux/utsname.h
1013 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
1014 AC_MSG_CHECKING([whether init_utsname() is available])
1015 SPL_LINUX_TRY_COMPILE([
1016 #include <linux/utsname.h>
1018 struct new_utsname *a = init_utsname();
1021 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1028 dnl # 2.6.26 API change,
1029 dnl # definition of struct fdtable relocated to linux/fdtable.h
1031 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
1032 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
1036 dnl # 2.6.14 API change,
1037 dnl # check whether 'files_fdtable()' exists
1039 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
1040 AC_MSG_CHECKING([whether files_fdtable() is available])
1041 SPL_LINUX_TRY_COMPILE([
1042 #include <linux/sched.h>
1043 #include <linux/file.h>
1044 #ifdef HAVE_FDTABLE_HEADER
1045 #include <linux/fdtable.h>
1048 struct files_struct *files = current->files;
1049 struct fdtable *fdt = files_fdtable(files);
1052 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
1059 dnl # 2.6.18 API change,
1060 dnl # added linux/uaccess.h
1062 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1063 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1067 dnl # 2.6.12 API change,
1068 dnl # check whether 'kmalloc_node()' is available.
1070 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1071 AC_MSG_CHECKING([whether kmalloc_node() is available])
1072 SPL_LINUX_TRY_COMPILE([
1073 #include <linux/slab.h>
1075 void *a = kmalloc_node(1, GFP_KERNEL, 0);
1078 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1085 dnl # 2.6.9 API change,
1086 dnl # check whether 'monotonic_clock()' is available it may
1087 dnl # be available for some archs but not others.
1089 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
1090 SPL_CHECK_SYMBOL_EXPORT(
1093 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1094 [monotonic_clock() is available])],
1099 dnl # 2.6.16 API change,
1100 dnl # check whether 'struct inode' has i_mutex
1102 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1103 AC_MSG_CHECKING([whether struct inode has i_mutex])
1104 SPL_LINUX_TRY_COMPILE([
1105 #include <linux/fs.h>
1106 #include <linux/mutex.h>
1109 mutex_init(&i.i_mutex);
1112 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1119 dnl # 2.6.29 API change,
1120 dnl # Adaptive mutexs introduced.
1122 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1123 AC_MSG_CHECKING([whether struct mutex has owner])
1124 SPL_LINUX_TRY_COMPILE([
1125 #include <linux/mutex.h>
1131 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1138 dnl # 2.6.18 API change,
1139 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1140 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1141 dnl # if the mutex validator is disabled or otherwise unavailable.
1143 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1144 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1145 SPL_LINUX_TRY_COMPILE([
1146 #include <linux/mutex.h>
1150 mutex_lock_nested(&mutex, 0);
1153 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1154 [mutex_lock_nested() is available])
1161 dnl # 2.6.27 API change,
1162 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1164 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1165 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1166 SPL_LINUX_TRY_COMPILE([
1167 #include <linux/smp.h>
1169 on_each_cpu(NULL, NULL, 0);
1172 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1173 [on_each_cpu wants 3 args])
1180 dnl # 2.6.18 API change,
1181 dnl # kallsyms_lookup_name no longer exported
1183 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
1184 SPL_CHECK_SYMBOL_EXPORT(
1185 [kallsyms_lookup_name],
1187 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1188 [kallsyms_lookup_name() is available])],
1193 dnl # Proposed API change,
1194 dnl # This symbol is not available in stock kernels. You may build a
1195 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1196 dnl # these symbols for use. If your already rolling a custom kernel for
1197 dnl # your environment this is recommended.
1199 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
1200 SPL_CHECK_SYMBOL_EXPORT(
1203 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1204 [get_vmalloc_info() is available])],
1209 dnl # 2.6.17 API change
1210 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1211 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1212 dnl # were exported in 2.6.17 for use by modules which was consistent with
1213 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1214 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1215 dnl # were dropped entirely leaving modules no way to directly iterate over
1216 dnl # the zone list. Because we need access to the zone helpers we check
1217 dnl # if the kernel contains the old or new implementation. Then we check
1218 dnl # to see if the symbols we need for each version are available. If they
1219 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1221 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1222 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1223 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1225 if test $rc -eq 0; then
1226 AC_MSG_RESULT([yes])
1227 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1234 dnl # Proposed API change,
1235 dnl # This symbol is not available in stock kernels. You may build a
1236 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1237 dnl # these symbols for use. If your already rolling a custom kernel for
1238 dnl # your environment this is recommended.
1240 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
1241 SPL_CHECK_SYMBOL_EXPORT(
1242 [first_online_pgdat],
1244 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1245 [first_online_pgdat() is available])],
1250 dnl # Proposed API change,
1251 dnl # This symbol is not available in stock kernels. You may build a
1252 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1253 dnl # these symbols for use. If your already rolling a custom kernel for
1254 dnl # your environment this is recommended.
1256 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
1257 SPL_CHECK_SYMBOL_EXPORT(
1258 [next_online_pgdat],
1260 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1261 [next_online_pgdat() is available])],
1266 dnl # Proposed API change,
1267 dnl # This symbol is not available in stock kernels. You may build a
1268 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1269 dnl # these symbols for use. If your already rolling a custom kernel for
1270 dnl # your environment this is recommended.
1272 AC_DEFUN([SPL_AC_NEXT_ZONE], [
1273 SPL_CHECK_SYMBOL_EXPORT(
1276 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1277 [next_zone() is available])],
1282 dnl # 2.6.17 API change,
1283 dnl # See SPL_AC_PGDAT_HELPERS for details.
1285 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1286 SPL_CHECK_SYMBOL_EXPORT(
1289 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1290 [pgdat_list is available])],
1295 dnl # 2.6.18 API change,
1296 dnl # First introduced global_page_state() support as an inline.
1298 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1299 AC_MSG_CHECKING([whether global_page_state() is available])
1300 SPL_LINUX_TRY_COMPILE([
1301 #include <linux/mm.h>
1303 unsigned long state;
1304 state = global_page_state(0);
1307 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1308 [global_page_state() is available])
1315 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1316 dnl # Public global zone stats now include a free page count. However
1317 dnl # the enumerated names of the counters have changed since this API
1318 dnl # was introduced. We need to deduce the corrent name to use. This
1319 dnl # replaces the priviate get_zone_counts() interface.
1321 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1322 dnl # is 2.6.30 as of when this was written.
1324 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1325 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1326 SPL_LINUX_TRY_COMPILE([
1327 #include <linux/mm.h>
1329 enum zone_stat_item zsi;
1330 zsi = NR_FREE_PAGES;
1333 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1334 [Page state NR_FREE_PAGES is available])
1341 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1342 dnl # Public global zone stats now include an inactive page count. However
1343 dnl # the enumerated names of the counters have changed since this API
1344 dnl # was introduced. We need to deduce the corrent name to use. This
1345 dnl # replaces the priviate get_zone_counts() interface.
1347 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1348 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1349 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1351 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1352 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1353 SPL_LINUX_TRY_COMPILE([
1354 #include <linux/mm.h>
1356 enum zone_stat_item zsi;
1360 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1361 [Page state NR_INACTIVE is available])
1366 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1367 SPL_LINUX_TRY_COMPILE([
1368 #include <linux/mm.h>
1370 enum zone_stat_item zsi;
1371 zsi = NR_INACTIVE_ANON;
1374 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1375 [Page state NR_INACTIVE_ANON is available])
1380 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1381 SPL_LINUX_TRY_COMPILE([
1382 #include <linux/mm.h>
1384 enum zone_stat_item zsi;
1385 zsi = NR_INACTIVE_FILE;
1388 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1389 [Page state NR_INACTIVE_FILE is available])
1396 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1397 dnl # Public global zone stats now include an active page count. However
1398 dnl # the enumerated names of the counters have changed since this API
1399 dnl # was introduced. We need to deduce the corrent name to use. This
1400 dnl # replaces the priviate get_zone_counts() interface.
1402 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1403 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1404 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1406 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1407 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1408 SPL_LINUX_TRY_COMPILE([
1409 #include <linux/mm.h>
1411 enum zone_stat_item zsi;
1415 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1416 [Page state NR_ACTIVE is available])
1421 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1422 SPL_LINUX_TRY_COMPILE([
1423 #include <linux/mm.h>
1425 enum zone_stat_item zsi;
1426 zsi = NR_ACTIVE_ANON;
1429 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1430 [Page state NR_ACTIVE_ANON is available])
1435 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1436 SPL_LINUX_TRY_COMPILE([
1437 #include <linux/mm.h>
1439 enum zone_stat_item zsi;
1440 zsi = NR_ACTIVE_FILE;
1443 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1444 [Page state NR_ACTIVE_FILE is available])
1451 dnl # Proposed API change for legacy kernels.
1452 dnl # This symbol is not available in older kernels. For kernels post
1453 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1454 dnl # page state information. This symbol is only used in legacy kernels
1455 dnl # any only as a last resort.
1457 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1458 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1459 SPL_LINUX_TRY_COMPILE([
1461 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1462 #error "global_page_state needs NR_FREE_PAGES"
1465 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1466 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1467 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1468 #error "global_page_state needs NR_ACTIVE*"
1471 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1472 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1473 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1474 #error "global_page_state needs NR_INACTIVE*"
1480 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1481 [get_zone_counts() is needed])
1483 SPL_CHECK_SYMBOL_EXPORT(
1486 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1487 [get_zone_counts() is available])],
1493 dnl # 2.6.27 API change,
1494 dnl # The user_path_dir() replaces __user_walk()
1496 AC_DEFUN([SPL_AC_USER_PATH_DIR], [
1497 SPL_CHECK_SYMBOL_EXPORT(
1500 [AC_DEFINE(HAVE_USER_PATH_DIR, 1,
1501 [user_path_dir() is available])],
1506 dnl # Symbol available in RHEL kernels not in stock kernels.
1508 AC_DEFUN([SPL_AC_SET_FS_PWD], [
1509 SPL_CHECK_SYMBOL_EXPORT(
1512 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1513 [set_fs_pwd() is available])],
1518 dnl # 2.6.25 API change,
1519 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1521 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1522 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1523 SPL_LINUX_TRY_COMPILE([
1524 #include <linux/sched.h>
1525 #include <linux/fs_struct.h>
1527 set_fs_pwd(NULL, NULL);
1530 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1531 [set_fs_pwd() wants 2 args])
1538 dnl # SLES API change, never adopted in mainline,
1539 dnl # Third 'struct vfsmount *' argument removed.
1541 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1542 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1543 SPL_LINUX_TRY_COMPILE([
1544 #include <linux/fs.h>
1546 vfs_unlink(NULL, NULL);
1549 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1550 [vfs_unlink() wants 2 args])
1557 dnl # SLES API change, never adopted in mainline,
1558 dnl # Third and sixth 'struct vfsmount *' argument removed.
1560 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1561 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1562 SPL_LINUX_TRY_COMPILE([
1563 #include <linux/fs.h>
1565 vfs_rename(NULL, NULL, NULL, NULL);
1568 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1569 [vfs_rename() wants 4 args])
1576 dnl # 2.6.36 API change,
1577 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1578 dnl # a spinlock_t to improve the fastpath performance.
1580 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1581 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1582 SPL_LINUX_TRY_COMPILE([
1583 #include <linux/sched.h>
1584 #include <linux/fs_struct.h>
1586 struct fs_struct fs;
1587 spin_lock_init(&fs.lock);
1590 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1591 [struct fs_struct uses spinlock_t])
1598 dnl # 2.6.29 API change,
1599 dnl # check whether 'struct cred' exists
1601 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1602 AC_MSG_CHECKING([whether struct cred exists])
1603 SPL_LINUX_TRY_COMPILE([
1604 #include <linux/cred.h>
1610 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1617 dnl # Custom SPL patch may export this symbol.
1619 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1620 SPL_CHECK_SYMBOL_EXPORT(
1623 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1624 [groups_search() is available])],
1629 dnl # 2.6.x API change,
1630 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1632 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1633 SPL_CHECK_SYMBOL_EXPORT(
1634 [__put_task_struct],
1636 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1637 [__put_task_struct() is available])],
1642 dnl # 2.6.32 API change,
1643 dnl # Unused 'struct file *' removed from prototype.
1645 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1646 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1647 SPL_LINUX_TRY_COMPILE([
1648 #include <linux/sysctl.h>
1650 proc_dostring(NULL, 0, NULL, NULL, NULL);
1653 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1654 [proc_handler() wants 5 args])
1661 dnl # 2.6.x API change,
1662 dnl # kvasprintf() function added.
1664 AC_DEFUN([SPL_AC_KVASPRINTF], [
1665 SPL_CHECK_SYMBOL_EXPORT(
1668 [AC_DEFINE(HAVE_KVASPRINTF, 1,
1669 [kvasprintf() is available])],
1674 dnl # 2.6.35 API change,
1675 dnl # Unused 'struct dentry *' removed from prototype.
1677 AC_DEFUN([SPL_AC_3ARGS_FILE_FSYNC], [
1678 AC_MSG_CHECKING([whether file_fsync() wants 3 args])
1679 SPL_LINUX_TRY_COMPILE([
1680 #include <linux/buffer_head.h>
1682 file_fsync(NULL, NULL, 0);
1685 AC_DEFINE(HAVE_3ARGS_FILE_FSYNC, 1,
1686 [file_fsync() wants 3 args])
1693 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
1694 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
1695 dnl # condition. The fixed version is exported as a symbol. The race
1696 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
1697 dnl # call that version while holding sem->wait_lock.
1699 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED], [
1700 SPL_CHECK_SYMBOL_EXPORT(
1702 [lib/rwsem-spinlock.c],
1703 [AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
1704 [rwsem_is_locked() acquires sem->wait_lock])],
1709 dnl # 2.6.37 API compat,
1710 dnl # The function invalidate_inodes() is no longer exported by the kernel.
1711 dnl # The prototype however is still available which means it is safe
1712 dnl # to acquire the symbol's address using spl_kallsyms_lookup_name().
1714 AC_DEFUN([SPL_AC_KERNEL_INVALIDATE_INODES], [
1715 SPL_CHECK_SYMBOL_EXPORT(
1716 [invalidate_inodes],
1718 [AC_DEFINE(HAVE_INVALIDATE_INODES, 1,
1719 [invalidate_inodes() is available])],
1724 dnl # 2.6.xx API compat,
1725 dnl # There currently exists no exposed API to partially shrink the dcache.
1726 dnl # The expected mechanism to shrink the cache is a registered shrinker
1727 dnl # which is called during memory pressure.
1729 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY], [
1730 SPL_CHECK_SYMBOL_EXPORT(
1731 [shrink_dcache_memory],
1733 [AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
1734 [shrink_dcache_memory() is available])],
1739 dnl # 2.6.xx API compat,
1740 dnl # There currently exists no exposed API to partially shrink the icache.
1741 dnl # The expected mechanism to shrink the cache is a registered shrinker
1742 dnl # which is called during memory pressure.
1744 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY], [
1745 SPL_CHECK_SYMBOL_EXPORT(
1746 [shrink_icache_memory],
1748 [AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
1749 [shrink_icache_memory() is available])],