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
90 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
91 modpost=$LINUX/scripts/Makefile.modpost
92 AC_MSG_CHECKING([kernel file name for module symbols])
93 if test -f "$modpost"; then
94 if grep -q Modules.symvers $modpost; then
95 LINUX_SYMBOLS=Modules.symvers
97 LINUX_SYMBOLS=Module.symvers
100 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
102 *** Please make sure the kernel devel package for your distribution
103 *** is installed. If your building with a custom kernel make sure the
104 *** kernel is configured, built, and the '--with-linux=PATH' configure
105 *** option refers to the location of the kernel source.])
110 AC_MSG_RESULT($LINUX_SYMBOLS)
111 AC_SUBST(LINUX_SYMBOLS)
114 AC_DEFUN([SPL_AC_KERNEL], [
116 AS_HELP_STRING([--with-linux=PATH],
117 [Path to kernel source]),
118 [kernelsrc="$withval"])
120 AC_ARG_WITH([linux-obj],
121 AS_HELP_STRING([--with-linux-obj=PATH],
122 [Path to kernel build objects]),
123 [kernelbuild="$withval"])
125 AC_MSG_CHECKING([kernel source directory])
126 if test -z "$kernelsrc"; then
127 if test -e "/lib/modules/$(uname -r)/source"; then
128 headersdir="/lib/modules/$(uname -r)/source"
129 sourcelink=$(readlink -f "$headersdir")
130 elif test -e "/lib/modules/$(uname -r)/build"; then
131 headersdir="/lib/modules/$(uname -r)/build"
132 sourcelink=$(readlink -f "$headersdir")
134 sourcelink=$(ls -1d /usr/src/kernels/* \
136 2>/dev/null | grep -v obj | tail -1)
139 if test -n "$sourcelink" && test -e ${sourcelink}; then
140 kernelsrc=`readlink -f ${sourcelink}`
142 AC_MSG_RESULT([Not found])
144 *** Please make sure the kernel devel package for your distribution
145 *** is installed then try again. If that fails you can specify the
146 *** location of the kernel source with the '--with-linux=PATH' option.])
149 if test "$kernelsrc" = "NONE"; then
154 AC_MSG_RESULT([$kernelsrc])
155 AC_MSG_CHECKING([kernel build directory])
156 if test -z "$kernelbuild"; then
157 if test -e "/lib/modules/$(uname -r)/build"; then
158 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
159 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
160 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
161 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
162 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
163 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
164 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
166 kernelbuild=${kernelsrc}
169 AC_MSG_RESULT([$kernelbuild])
171 AC_MSG_CHECKING([kernel source version])
172 utsrelease1=$kernelbuild/include/linux/version.h
173 utsrelease2=$kernelbuild/include/linux/utsrelease.h
174 utsrelease3=$kernelbuild/include/generated/utsrelease.h
175 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
176 utsrelease=linux/version.h
177 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
178 utsrelease=linux/utsrelease.h
179 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
180 utsrelease=generated/utsrelease.h
183 if test "$utsrelease"; then
184 kernsrcver=`(echo "#include <$utsrelease>";
185 echo "kernsrcver=UTS_RELEASE") |
186 cpp -I $kernelbuild/include |
187 grep "^kernsrcver=" | cut -d \" -f 2`
189 if test -z "$kernsrcver"; then
190 AC_MSG_RESULT([Not found])
191 AC_MSG_ERROR([*** Cannot determine kernel version.])
194 AC_MSG_RESULT([Not found])
195 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
198 AC_MSG_RESULT([$kernsrcver])
201 LINUX_OBJ=${kernelbuild}
202 LINUX_VERSION=${kernsrcver}
206 AC_SUBST(LINUX_VERSION)
208 SPL_AC_MODULE_SYMVERS
211 AC_DEFUN([SPL_AC_KERNEL_CONFIG], [
212 SPL_LINUX_CONFIG([PREEMPT],
214 *** Kernel built with CONFIG_PREEMPT which is not supported.
215 ** You must rebuild your kernel without this option.]), [])
219 dnl # Default SPL user configuration
221 AC_DEFUN([SPL_AC_CONFIG_USER], [])
224 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
225 dnl # are missing it is non-fatal but you will not be able to build
226 dnl # RPM packages and will be warned if you try too.
228 AC_DEFUN([SPL_AC_RPM], [
232 AC_MSG_CHECKING([whether $RPM is available])
233 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
234 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
236 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
239 AC_MSG_RESULT([$HAVE_RPM])
242 AC_MSG_CHECKING([whether $RPMBUILD is available])
243 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
244 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
246 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
249 AC_MSG_RESULT([$HAVE_RPMBUILD])
254 AC_SUBST(RPM_VERSION)
256 AC_SUBST(HAVE_RPMBUILD)
258 AC_SUBST(RPMBUILD_VERSION)
262 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
263 dnl # tools are missing it is non-fatal but you will not be able to build
264 dnl # DEB packages and will be warned if you try too.
266 AC_DEFUN([SPL_AC_DPKG], [
268 DPKGBUILD=dpkg-buildpackage
270 AC_MSG_CHECKING([whether $DPKG is available])
271 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
272 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
274 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
277 AC_MSG_RESULT([$HAVE_DPKG])
280 AC_MSG_CHECKING([whether $DPKGBUILD is available])
281 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
282 DPKGBUILD_VERSION=$(echo $tmp | \
283 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
285 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
288 AC_MSG_RESULT([$HAVE_DPKGBUILD])
293 AC_SUBST(DPKG_VERSION)
295 AC_SUBST(HAVE_DPKGBUILD)
297 AC_SUBST(DPKGBUILD_VERSION)
301 dnl # Until native packaging for various different packing systems
302 dnl # can be added the least we can do is attempt to use alien to
303 dnl # convert the RPM packages to the needed package type. This is
304 dnl # a hack but so far it has worked reasonable well.
306 AC_DEFUN([SPL_AC_ALIEN], [
309 AC_MSG_CHECKING([whether $ALIEN is available])
310 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
311 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
313 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
316 AC_MSG_RESULT([$HAVE_ALIEN])
321 AC_SUBST(ALIEN_VERSION)
325 dnl # Using the VENDOR tag from config.guess set the default
326 dnl # package type for 'make pkg': (rpm | deb | tgz)
328 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
329 AC_MSG_CHECKING([linux distribution])
330 if test -f /etc/redhat-release ; then
332 elif test -f /etc/fedora-release ; then
334 elif test -f /etc/lsb-release ; then
336 elif test -f /etc/debian_version ; then
338 elif test -f /etc/SuSE-release ; then
340 elif test -f /etc/slackware-version ; then
342 elif test -f /etc/gentoo-release ; then
347 AC_MSG_RESULT([$VENDOR])
350 AC_MSG_CHECKING([default package type])
352 fedora) DEFAULT_PACKAGE=rpm ;;
353 redhat) DEFAULT_PACKAGE=rpm ;;
354 sles) DEFAULT_PACKAGE=rpm ;;
355 ubuntu) DEFAULT_PACKAGE=deb ;;
356 debian) DEFAULT_PACKAGE=deb ;;
357 slackware) DEFAULT_PACKAGE=tgz ;;
358 *) DEFAULT_PACKAGE=rpm ;;
361 AC_MSG_RESULT([$DEFAULT_PACKAGE])
362 AC_SUBST(DEFAULT_PACKAGE)
366 dnl # Default SPL user configuration
368 AC_DEFUN([SPL_AC_PACKAGE], [
372 SPL_AC_DEFAULT_PACKAGE
375 AC_DEFUN([SPL_AC_LICENSE], [
376 AC_MSG_CHECKING([spl license])
378 AC_MSG_RESULT([$LICENSE])
379 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
383 AC_DEFUN([SPL_AC_CONFIG], [
385 AC_ARG_WITH([config],
386 AS_HELP_STRING([--with-config=CONFIG],
387 [Config file 'kernel|user|all|srpm']),
388 [SPL_CONFIG="$withval"])
390 AC_MSG_CHECKING([spl config])
391 AC_MSG_RESULT([$SPL_CONFIG]);
394 case "$SPL_CONFIG" in
395 kernel) SPL_AC_CONFIG_KERNEL ;;
396 user) SPL_AC_CONFIG_USER ;;
397 all) SPL_AC_CONFIG_KERNEL
398 SPL_AC_CONFIG_USER ;;
401 AC_MSG_RESULT([Error!])
402 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
403 user kernel|user|all|srpm]) ;;
406 AM_CONDITIONAL([CONFIG_USER],
407 [test "$SPL_CONFIG" = user] ||
408 [test "$SPL_CONFIG" = all])
409 AM_CONDITIONAL([CONFIG_KERNEL],
410 [test "$SPL_CONFIG" = kernel] ||
411 [test "$SPL_CONFIG" = all])
415 dnl # Enable if the SPL should be compiled with internal debugging enabled.
416 dnl # By default this support is disabled.
418 AC_DEFUN([SPL_AC_DEBUG], [
419 AC_MSG_CHECKING([whether debugging is enabled])
420 AC_ARG_ENABLE([debug],
421 [AS_HELP_STRING([--enable-debug],
422 [Enable generic debug support @<:@default=no@:>@])],
426 AS_IF([test "x$enable_debug" = xyes],
428 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
429 DEBUG_CFLAGS="-DDEBUG -Werror"
432 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
433 DEBUG_CFLAGS="-DNDEBUG"
436 AC_SUBST(DEBUG_CFLAGS)
437 AC_MSG_RESULT([$enable_debug])
441 dnl # Enabled by default it provides a minimal level of memory tracking.
442 dnl # A total count of bytes allocated is kept for each alloc and free.
443 dnl # Then at module unload time a report to the console will be printed
444 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
445 dnl # and provide an easy way to inspect the kmem based slab.
447 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
448 AC_ARG_ENABLE([debug-kmem],
449 [AS_HELP_STRING([--enable-debug-kmem],
450 [Enable basic kmem accounting @<:@default=yes@:>@])],
452 [enable_debug_kmem=yes])
454 AS_IF([test "x$enable_debug_kmem" = xyes],
455 [AC_DEFINE([DEBUG_KMEM], [1],
456 [Define to 1 to enable basic kmem accounting])
457 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"])
459 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
460 AC_MSG_RESULT([$enable_debug_kmem])
464 dnl # Disabled by default it provides detailed memory tracking. This
465 dnl # feature also requires --enable-debug-kmem to be set. When enabled
466 dnl # not only will total bytes be tracked but also the location of every
467 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
468 dnl # addresses and where they were allocated will be dumped to the console.
469 dnl # Enabling this feature has a significant impact on performance but it
470 dnl # makes finding memory leaks pretty straight forward.
472 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
473 AC_ARG_ENABLE([debug-kmem-tracking],
474 [AS_HELP_STRING([--enable-debug-kmem-tracking],
475 [Enable detailed kmem tracking @<:@default=no@:>@])],
477 [enable_debug_kmem_tracking=no])
479 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
480 [AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
481 [Define to 1 to enable detailed kmem tracking])
482 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"])
484 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
485 AC_MSG_RESULT([$enable_debug_kmem_tracking])
489 dnl # SPL_LINUX_CONFTEST
491 AC_DEFUN([SPL_LINUX_CONFTEST], [
492 cat confdefs.h - <<_ACEOF >conftest.c
498 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
500 m4_define([SPL_LANG_PROGRAM], [
505 dnl Do *not* indent the following line: there may be CPP directives.
506 dnl Don't move the `;' right after for the same reason.
514 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
516 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
517 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
518 rm -Rf build && mkdir -p build
519 echo "obj-m := conftest.o" >build/Makefile
521 [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])],
523 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
529 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
531 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
532 [SPL_LINUX_COMPILE_IFELSE(
533 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
535 [test -s build/conftest.o],
540 dnl # SPL_LINUX_CONFIG
542 AC_DEFUN([SPL_LINUX_CONFIG],
543 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
544 SPL_LINUX_TRY_COMPILE([
545 #include <linux/module.h>
548 #error CONFIG_$1 not #defined
560 dnl # SPL_CHECK_SYMBOL_EXPORT
561 dnl # check symbol exported or not
563 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
564 [AC_MSG_CHECKING([whether symbol $1 is exported])
565 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
566 $LINUX_OBJ/Module*.symvers 2>/dev/null
568 if test $rc -ne 0; then
571 grep -q -E "EXPORT_SYMBOL.*($1)" \
572 "$LINUX_OBJ/$file" 2>/dev/null
574 if test $rc -eq 0; then
579 if test $export -eq 0; then
593 dnl # SPL_CHECK_SYMBOL_HEADER
594 dnl # check if a symbol prototype is defined in listed headers.
596 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
597 AC_MSG_CHECKING([whether symbol $1 exists in header])
600 grep -q "$2" "$LINUX/$file" 2>/dev/null
602 if test $rc -eq 0; then
607 if test $header -eq 0; then
617 dnl # SPL_CHECK_HEADER
618 dnl # check whether header exists and define HAVE_$2_HEADER
620 AC_DEFUN([SPL_CHECK_HEADER],
621 [AC_MSG_CHECKING([whether header $1 exists])
622 SPL_LINUX_TRY_COMPILE([
627 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
637 dnl # Use the atomic implemenation based on global spinlocks. This
638 dnl # should only be needed by 32-bit kernels which do not provide
639 dnl # the atomic64_* API. It may be optionally enabled as a fallback
640 dnl # if problems are observed with the direct mapping to the native
641 dnl # Linux atomic operations. You may not disable atomic spinlocks
642 dnl # if you kernel does not an atomic64_* API.
644 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
645 AC_ARG_ENABLE([atomic-spinlocks],
646 [AS_HELP_STRING([--enable-atomic-spinlocks],
647 [Atomic types use spinlocks @<:@default=check@:>@])],
649 [enable_atomic_spinlocks=check])
651 SPL_LINUX_TRY_COMPILE([
652 #include <asm/atomic.h>
654 atomic64_t *ptr __attribute__ ((unused));
657 AC_DEFINE(HAVE_ATOMIC64_T, 1,
658 [kernel defines atomic64_t])
663 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
664 AS_IF([test "x$have_atomic64_t" = xyes], [
665 enable_atomic_spinlocks=no
667 enable_atomic_spinlocks=yes
671 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
672 AC_DEFINE([ATOMIC_SPINLOCK], [1],
673 [Atomic types use spinlocks])
675 AS_IF([test "x$have_atomic64_t" = xno], [
677 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
681 AC_MSG_CHECKING([whether atomic types use spinlocks])
682 AC_MSG_RESULT([$enable_atomic_spinlocks])
684 AC_MSG_CHECKING([whether kernel defines atomic64_t])
685 AC_MSG_RESULT([$have_atomic64_t])
689 dnl # 2.6.24 API change,
690 dnl # check if atomic64_cmpxchg is defined
692 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
693 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
694 SPL_LINUX_TRY_COMPILE([
695 #include <asm/atomic.h>
696 #include <asm/system.h>
698 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
701 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
702 [kernel defines atomic64_cmpxchg])
709 dnl # 2.6.24 API change,
710 dnl # check if atomic64_xchg is defined
712 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
713 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
714 SPL_LINUX_TRY_COMPILE([
715 #include <asm/atomic.h>
717 atomic64_xchg((atomic64_t *)NULL, 0);
720 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
721 [kernel defines atomic64_xchg])
728 dnl # 2.6.24 API change,
729 dnl # check if uintptr_t typedef is defined
731 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
732 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
733 SPL_LINUX_TRY_COMPILE([
734 #include <linux/types.h>
736 uintptr_t *ptr __attribute__ ((unused));
739 AC_DEFINE(HAVE_UINTPTR_T, 1,
740 [kernel defines uintptr_t])
747 dnl # 2.6.20 API change,
748 dnl # INIT_WORK use 2 args and not store data inside
750 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
751 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
752 SPL_LINUX_TRY_COMPILE([
753 #include <linux/workqueue.h>
755 struct work_struct work __attribute__ ((unused));
756 INIT_WORK(&work, NULL, NULL);
759 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
760 [INIT_WORK wants 3 args])
767 dnl # 2.6.21 API change,
768 dnl # 'register_sysctl_table' use only one argument instead of two
770 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
771 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
772 SPL_LINUX_TRY_COMPILE([
773 #include <linux/sysctl.h>
775 (void) register_sysctl_table(NULL, 0);
778 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
779 [register_sysctl_table() wants 2 args])
786 dnl # 2.6.23 API change
787 dnl # Old set_shrinker API replaced with register_shrinker
789 AC_DEFUN([SPL_AC_SET_SHRINKER], [
790 AC_MSG_CHECKING([whether set_shrinker() available])
791 SPL_LINUX_TRY_COMPILE([
792 #include <linux/mm.h>
794 return set_shrinker(DEFAULT_SEEKS, NULL);
797 AC_DEFINE(HAVE_SET_SHRINKER, 1,
798 [set_shrinker() available])
805 dnl # 2.6.35 API change,
806 dnl # Add context to shrinker callback
808 AC_DEFUN([SPL_AC_3ARGS_SHRINKER_CALLBACK],
809 [AC_MSG_CHECKING([whether shrinker callback wants 3 args])
810 tmp_flags="$EXTRA_KCFLAGS"
811 EXTRA_KCFLAGS="-Werror"
812 SPL_LINUX_TRY_COMPILE([
813 #include <linux/mm.h>
815 int shrinker_cb(struct shrinker *, int, unsigned int);
817 struct shrinker cache_shrinker = {
818 .shrink = shrinker_cb,
819 .seeks = DEFAULT_SEEKS,
821 register_shrinker(&cache_shrinker);
824 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
825 [shrinker callback wants 3 args])
829 EXTRA_KCFLAGS="$tmp_flags"
833 dnl # 2.6.25 API change,
834 dnl # struct path entry added to struct nameidata
836 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
837 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
838 SPL_LINUX_TRY_COMPILE([
839 #include <linux/namei.h>
841 struct nameidata nd __attribute__ ((unused));
844 nd.path.dentry = NULL;
847 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
848 [struct path used in struct nameidata])
855 dnl # Custom SPL patch may export this system it is not required
857 AC_DEFUN([SPL_AC_TASK_CURR], [
858 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
859 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
864 dnl # 2.6.19 API change,
865 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
867 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
868 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
869 SPL_LINUX_TRY_COMPILE([
870 #include <linux/sysctl.h>
872 #ifndef CTL_UNNUMBERED
873 #error CTL_UNNUMBERED undefined
877 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
878 [unnumbered sysctl support exists])
885 dnl # 2.6.33 API change,
886 dnl # Removed .ctl_name from struct ctl_table.
888 AC_DEFUN([SPL_AC_CTL_NAME], [
889 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
890 SPL_LINUX_TRY_COMPILE([
891 #include <linux/sysctl.h>
893 struct ctl_table ctl __attribute__ ((unused));
897 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
904 dnl # 2.6.16 API change.
905 dnl # Check if 'fls64()' is available
907 AC_DEFUN([SPL_AC_FLS64],
908 [AC_MSG_CHECKING([whether fls64() is available])
909 SPL_LINUX_TRY_COMPILE([
910 #include <linux/bitops.h>
915 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
922 dnl # 2.6.18 API change, check whether device_create() is available.
923 dnl # Device_create() was introduced in 2.6.18 and depricated
924 dnl # class_device_create() which was fully removed in 2.6.26.
926 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
927 SPL_CHECK_SYMBOL_EXPORT(
929 [drivers/base/core.c],
930 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
931 [device_create() is available])],
936 dnl # 2.6.27 API change,
937 dnl # device_create() uses 5 args, new 'drvdata' argument.
939 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
940 AC_MSG_CHECKING([whether device_create() wants 5 args])
941 tmp_flags="$EXTRA_KCFLAGS"
942 EXTRA_KCFLAGS="-Werror"
943 SPL_LINUX_TRY_COMPILE([
944 #include <linux/device.h>
946 device_create(NULL, NULL, 0, NULL, "%d", 1);
949 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
950 [device_create wants 5 args])
954 EXTRA_KCFLAGS="$tmp_flags"
958 dnl # 2.6.13 API change, check whether class_device_create() is available.
959 dnl # Class_device_create() was introduced in 2.6.13 and depricated
960 dnl # class_simple_device_add() which was fully removed in 2.6.13.
962 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
963 SPL_CHECK_SYMBOL_EXPORT(
964 [class_device_create],
965 [drivers/base/class.c],
966 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
967 [class_device_create() is available])],
972 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
974 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
975 SPL_CHECK_SYMBOL_EXPORT(
976 [set_normalized_timespec],
978 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
979 [set_normalized_timespec() is available as export])],
984 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
985 dnl # previously it was available in time.h as an inline.
987 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
988 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
989 SPL_LINUX_TRY_COMPILE([
990 #include <linux/time.h>
991 void set_normalized_timespec(struct timespec *ts,
992 time_t sec, long nsec) { }
999 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
1000 [set_normalized_timespec() is available as inline])
1005 dnl # 2.6.18 API change,
1006 dnl # timespec_sub() inline function available in linux/time.h
1008 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
1009 AC_MSG_CHECKING([whether timespec_sub() is available])
1010 SPL_LINUX_TRY_COMPILE([
1011 #include <linux/time.h>
1013 struct timespec a = { 0 };
1014 struct timespec b = { 0 };
1015 struct timespec c __attribute__ ((unused));
1016 c = timespec_sub(a, b);
1019 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1026 dnl # 2.6.19 API change,
1027 dnl # check if init_utsname() is available in linux/utsname.h
1029 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
1030 AC_MSG_CHECKING([whether init_utsname() is available])
1031 SPL_LINUX_TRY_COMPILE([
1032 #include <linux/utsname.h>
1034 struct new_utsname *a __attribute__ ((unused));
1038 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1045 dnl # 2.6.26 API change,
1046 dnl # definition of struct fdtable relocated to linux/fdtable.h
1048 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
1049 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
1053 dnl # 2.6.14 API change,
1054 dnl # check whether 'files_fdtable()' exists
1056 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
1057 AC_MSG_CHECKING([whether files_fdtable() is available])
1058 SPL_LINUX_TRY_COMPILE([
1059 #include <linux/sched.h>
1060 #include <linux/file.h>
1061 #ifdef HAVE_FDTABLE_HEADER
1062 #include <linux/fdtable.h>
1065 struct files_struct *files = current->files;
1066 struct fdtable *fdt __attribute__ ((unused));
1067 fdt = files_fdtable(files);
1070 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
1077 dnl # 2.6.18 API change,
1078 dnl # added linux/uaccess.h
1080 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1081 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1085 dnl # 2.6.12 API change,
1086 dnl # check whether 'kmalloc_node()' is available.
1088 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1089 AC_MSG_CHECKING([whether kmalloc_node() is available])
1090 SPL_LINUX_TRY_COMPILE([
1091 #include <linux/slab.h>
1093 void *a __attribute__ ((unused));
1094 a = kmalloc_node(1, GFP_KERNEL, 0);
1097 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1104 dnl # 2.6.9 API change,
1105 dnl # check whether 'monotonic_clock()' is available it may
1106 dnl # be available for some archs but not others.
1108 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
1109 SPL_CHECK_SYMBOL_EXPORT(
1112 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1113 [monotonic_clock() is available])],
1118 dnl # 2.6.16 API change,
1119 dnl # check whether 'struct inode' has i_mutex
1121 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1122 AC_MSG_CHECKING([whether struct inode has i_mutex])
1123 SPL_LINUX_TRY_COMPILE([
1124 #include <linux/fs.h>
1125 #include <linux/mutex.h>
1128 mutex_init(&i.i_mutex);
1131 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1138 dnl # 2.6.29 API change,
1139 dnl # Adaptive mutexs introduced.
1141 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1142 AC_MSG_CHECKING([whether struct mutex has owner])
1143 SPL_LINUX_TRY_COMPILE([
1144 #include <linux/mutex.h>
1146 struct mutex mtx __attribute__ ((unused));
1150 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1157 dnl # 2.6.39 API change,
1158 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
1159 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
1160 dnl # was defined. As of 2.6.39 this was changed to a task_struct
1161 dnl # pointer which frankly makes a lot more sense.
1163 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
1164 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
1165 tmp_flags="$EXTRA_KCFLAGS"
1166 EXTRA_KCFLAGS="-Werror"
1167 SPL_LINUX_TRY_COMPILE([
1168 #include <linux/mutex.h>
1170 struct mutex mtx __attribute__ ((unused));
1171 mtx.owner = current;
1174 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
1175 [struct mutex owner is a task_struct])
1179 EXTRA_KCFLAGS="$tmp_flags"
1183 dnl # 2.6.18 API change,
1184 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1185 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1186 dnl # if the mutex validator is disabled or otherwise unavailable.
1188 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1189 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1190 SPL_LINUX_TRY_COMPILE([
1191 #include <linux/mutex.h>
1195 mutex_lock_nested(&mutex, 0);
1198 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1199 [mutex_lock_nested() is available])
1206 dnl # 2.6.27 API change,
1207 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1209 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1210 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1211 SPL_LINUX_TRY_COMPILE([
1212 #include <linux/smp.h>
1214 on_each_cpu(NULL, NULL, 0);
1217 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1218 [on_each_cpu wants 3 args])
1225 dnl # 2.6.18 API change,
1226 dnl # kallsyms_lookup_name no longer exported
1228 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
1229 SPL_CHECK_SYMBOL_EXPORT(
1230 [kallsyms_lookup_name],
1232 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1233 [kallsyms_lookup_name() is available])],
1238 dnl # Proposed API change,
1239 dnl # This symbol is not available in stock kernels. You may build a
1240 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1241 dnl # these symbols for use. If your already rolling a custom kernel for
1242 dnl # your environment this is recommended.
1244 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
1245 SPL_CHECK_SYMBOL_EXPORT(
1248 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1249 [get_vmalloc_info() is available])],
1254 dnl # 2.6.17 API change
1255 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1256 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1257 dnl # were exported in 2.6.17 for use by modules which was consistent with
1258 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1259 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1260 dnl # were dropped entirely leaving modules no way to directly iterate over
1261 dnl # the zone list. Because we need access to the zone helpers we check
1262 dnl # if the kernel contains the old or new implementation. Then we check
1263 dnl # to see if the symbols we need for each version are available. If they
1264 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1266 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1267 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1268 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1270 if test $rc -eq 0; then
1271 AC_MSG_RESULT([yes])
1272 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1279 dnl # Proposed API change,
1280 dnl # This symbol is not available in stock kernels. You may build a
1281 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1282 dnl # these symbols for use. If your already rolling a custom kernel for
1283 dnl # your environment this is recommended.
1285 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
1286 SPL_CHECK_SYMBOL_EXPORT(
1287 [first_online_pgdat],
1289 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1290 [first_online_pgdat() is available])],
1295 dnl # Proposed API change,
1296 dnl # This symbol is not available in stock kernels. You may build a
1297 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1298 dnl # these symbols for use. If your already rolling a custom kernel for
1299 dnl # your environment this is recommended.
1301 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
1302 SPL_CHECK_SYMBOL_EXPORT(
1303 [next_online_pgdat],
1305 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1306 [next_online_pgdat() is available])],
1311 dnl # Proposed API change,
1312 dnl # This symbol is not available in stock kernels. You may build a
1313 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1314 dnl # these symbols for use. If your already rolling a custom kernel for
1315 dnl # your environment this is recommended.
1317 AC_DEFUN([SPL_AC_NEXT_ZONE], [
1318 SPL_CHECK_SYMBOL_EXPORT(
1321 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1322 [next_zone() is available])],
1327 dnl # 2.6.17 API change,
1328 dnl # See SPL_AC_PGDAT_HELPERS for details.
1330 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1331 SPL_CHECK_SYMBOL_EXPORT(
1334 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1335 [pgdat_list is available])],
1340 dnl # 2.6.18 API change,
1341 dnl # First introduced global_page_state() support as an inline.
1343 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1344 AC_MSG_CHECKING([whether global_page_state() is available])
1345 SPL_LINUX_TRY_COMPILE([
1346 #include <linux/mm.h>
1348 unsigned long state __attribute__ ((unused));
1349 state = global_page_state(0);
1352 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1353 [global_page_state() is available])
1360 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1361 dnl # Public global zone stats now include a free 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_FREE_PAGES was available from 2.6.21 to current kernels, which
1367 dnl # is 2.6.30 as of when this was written.
1369 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1370 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1371 SPL_LINUX_TRY_COMPILE([
1372 #include <linux/mm.h>
1374 enum zone_stat_item zsi __attribute__ ((unused));
1375 zsi = NR_FREE_PAGES;
1378 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1379 [Page state NR_FREE_PAGES is available])
1386 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1387 dnl # Public global zone stats now include an inactive page count. However
1388 dnl # the enumerated names of the counters have changed since this API
1389 dnl # was introduced. We need to deduce the corrent name to use. This
1390 dnl # replaces the priviate get_zone_counts() interface.
1392 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1393 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1394 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1396 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1397 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1398 SPL_LINUX_TRY_COMPILE([
1399 #include <linux/mm.h>
1401 enum zone_stat_item zsi __attribute__ ((unused));
1405 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1406 [Page state NR_INACTIVE is available])
1411 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1412 SPL_LINUX_TRY_COMPILE([
1413 #include <linux/mm.h>
1415 enum zone_stat_item zsi __attribute__ ((unused));
1416 zsi = NR_INACTIVE_ANON;
1419 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1420 [Page state NR_INACTIVE_ANON is available])
1425 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1426 SPL_LINUX_TRY_COMPILE([
1427 #include <linux/mm.h>
1429 enum zone_stat_item zsi __attribute__ ((unused));
1430 zsi = NR_INACTIVE_FILE;
1433 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1434 [Page state NR_INACTIVE_FILE is available])
1441 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1442 dnl # Public global zone stats now include an active page count. However
1443 dnl # the enumerated names of the counters have changed since this API
1444 dnl # was introduced. We need to deduce the corrent name to use. This
1445 dnl # replaces the priviate get_zone_counts() interface.
1447 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1448 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1449 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1451 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1452 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1453 SPL_LINUX_TRY_COMPILE([
1454 #include <linux/mm.h>
1456 enum zone_stat_item zsi __attribute__ ((unused));
1460 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1461 [Page state NR_ACTIVE is available])
1466 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1467 SPL_LINUX_TRY_COMPILE([
1468 #include <linux/mm.h>
1470 enum zone_stat_item zsi __attribute__ ((unused));
1471 zsi = NR_ACTIVE_ANON;
1474 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1475 [Page state NR_ACTIVE_ANON is available])
1480 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1481 SPL_LINUX_TRY_COMPILE([
1482 #include <linux/mm.h>
1484 enum zone_stat_item zsi __attribute__ ((unused));
1485 zsi = NR_ACTIVE_FILE;
1488 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1489 [Page state NR_ACTIVE_FILE is available])
1496 dnl # Proposed API change for legacy kernels.
1497 dnl # This symbol is not available in older kernels. For kernels post
1498 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1499 dnl # page state information. This symbol is only used in legacy kernels
1500 dnl # any only as a last resort.
1502 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1503 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1504 SPL_LINUX_TRY_COMPILE([
1506 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1507 #error "global_page_state needs NR_FREE_PAGES"
1510 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1511 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1512 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1513 #error "global_page_state needs NR_ACTIVE*"
1516 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1517 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1518 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1519 #error "global_page_state needs NR_INACTIVE*"
1525 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1526 [get_zone_counts() is needed])
1528 SPL_CHECK_SYMBOL_EXPORT(
1531 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1532 [get_zone_counts() is available])],
1538 dnl # 2.6.27 API change,
1539 dnl # The user_path_dir() replaces __user_walk()
1541 AC_DEFUN([SPL_AC_USER_PATH_DIR], [
1542 SPL_CHECK_SYMBOL_EXPORT(
1545 [AC_DEFINE(HAVE_USER_PATH_DIR, 1,
1546 [user_path_dir() is available])],
1551 dnl # Symbol available in RHEL kernels not in stock kernels.
1553 AC_DEFUN([SPL_AC_SET_FS_PWD], [
1554 SPL_CHECK_SYMBOL_EXPORT(
1557 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1558 [set_fs_pwd() is available])],
1563 dnl # 2.6.25 API change,
1564 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1566 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1567 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1568 SPL_LINUX_TRY_COMPILE([
1569 #include <linux/sched.h>
1570 #include <linux/fs_struct.h>
1572 set_fs_pwd(NULL, NULL);
1575 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1576 [set_fs_pwd() wants 2 args])
1583 dnl # SLES API change, never adopted in mainline,
1584 dnl # Third 'struct vfsmount *' argument removed.
1586 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1587 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1588 SPL_LINUX_TRY_COMPILE([
1589 #include <linux/fs.h>
1591 vfs_unlink(NULL, NULL);
1594 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1595 [vfs_unlink() wants 2 args])
1602 dnl # SLES API change, never adopted in mainline,
1603 dnl # Third and sixth 'struct vfsmount *' argument removed.
1605 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1606 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1607 SPL_LINUX_TRY_COMPILE([
1608 #include <linux/fs.h>
1610 vfs_rename(NULL, NULL, NULL, NULL);
1613 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1614 [vfs_rename() wants 4 args])
1621 dnl # 2.6.36 API change,
1622 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1623 dnl # a spinlock_t to improve the fastpath performance.
1625 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1626 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1627 tmp_flags="$EXTRA_KCFLAGS"
1628 EXTRA_KCFLAGS="-Werror"
1629 SPL_LINUX_TRY_COMPILE([
1630 #include <linux/sched.h>
1631 #include <linux/fs_struct.h>
1633 struct fs_struct fs;
1634 spin_lock_init(&fs.lock);
1637 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1638 [struct fs_struct uses spinlock_t])
1642 EXTRA_KCFLAGS="$tmp_flags"
1646 dnl # 2.6.29 API change,
1647 dnl # check whether 'struct cred' exists
1649 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1650 AC_MSG_CHECKING([whether struct cred exists])
1651 SPL_LINUX_TRY_COMPILE([
1652 #include <linux/cred.h>
1654 struct cred *cr __attribute__ ((unused));
1658 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1665 dnl # Custom SPL patch may export this symbol.
1667 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1668 SPL_CHECK_SYMBOL_EXPORT(
1671 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1672 [groups_search() is available])],
1677 dnl # 2.6.x API change,
1678 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1680 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1681 SPL_CHECK_SYMBOL_EXPORT(
1682 [__put_task_struct],
1684 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1685 [__put_task_struct() is available])],
1690 dnl # 2.6.32 API change,
1691 dnl # Unused 'struct file *' removed from prototype.
1693 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1694 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1695 SPL_LINUX_TRY_COMPILE([
1696 #include <linux/sysctl.h>
1698 proc_dostring(NULL, 0, NULL, NULL, NULL);
1701 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1702 [proc_handler() wants 5 args])
1709 dnl # 2.6.x API change,
1710 dnl # kvasprintf() function added.
1712 AC_DEFUN([SPL_AC_KVASPRINTF], [
1713 SPL_CHECK_SYMBOL_EXPORT(
1716 [AC_DEFINE(HAVE_KVASPRINTF, 1,
1717 [kvasprintf() is available])],
1722 dnl # 2.6.29 API change,
1723 dnl # vfs_fsync() funcation added, prior to this use file_fsync().
1725 AC_DEFUN([SPL_AC_VFS_FSYNC], [
1726 SPL_CHECK_SYMBOL_EXPORT(
1729 [AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])],
1734 dnl # 2.6.35 API change,
1735 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
1737 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
1738 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
1739 SPL_LINUX_TRY_COMPILE([
1740 #include <linux/fs.h>
1745 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
1752 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
1753 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
1754 dnl # condition. The fixed version is exported as a symbol. The race
1755 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
1756 dnl # call that version while holding sem->wait_lock.
1758 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED], [
1759 SPL_CHECK_SYMBOL_EXPORT(
1761 [lib/rwsem-spinlock.c],
1762 [AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
1763 [rwsem_is_locked() acquires sem->wait_lock])],
1768 dnl # 2.6.37 API compat,
1769 dnl # The function invalidate_inodes() is no longer exported by the kernel.
1770 dnl # The prototype however is still available which means it is safe
1771 dnl # to acquire the symbol's address using spl_kallsyms_lookup_name().
1773 AC_DEFUN([SPL_AC_KERNEL_INVALIDATE_INODES], [
1774 SPL_CHECK_SYMBOL_EXPORT(
1775 [invalidate_inodes],
1777 [AC_DEFINE(HAVE_INVALIDATE_INODES, 1,
1778 [invalidate_inodes() is available])],
1783 dnl # 2.6.39 API compat,
1784 dnl # The function invalidate_inodes() now take 2 arguments. The second
1785 dnl # 'kill_dirty' argument describes how invalidate_inodes() should
1786 dnl # handle dirty inodes. Only when set will dirty inodes be discarded,
1787 dnl # otherwise they will be handled as busy.
1789 dnl # Unfortunately, we don't have access to the invalidate_inodes()
1790 dnl # prototype so it's not easy to check how many arguments it takes.
1791 dnl # However, this change was done for the benefit of invalidate_device()
1792 dnl # which also added an argument. The invalidate_device() symbol does
1793 dnl # exist in the development headers so if it takes two arguments we
1794 dnl # can fairly safely infer that invalidate_inodes() takes two arguments
1795 dnl # as well. See commit 93b270f76e7ef3b81001576860c2701931cdc78b.
1797 AC_DEFUN([SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES],
1798 [AC_MSG_CHECKING([whether invalidate_inodes() wants 2 args])
1799 SPL_LINUX_TRY_COMPILE([
1800 #include <linux/fs.h>
1802 return __invalidate_device(NULL, 0);
1805 AC_DEFINE(HAVE_2ARGS_INVALIDATE_INODES, 1,
1806 [invalidate_inodes() wants 2 args])
1813 dnl # 2.6.xx API compat,
1814 dnl # There currently exists no exposed API to partially shrink the dcache.
1815 dnl # The expected mechanism to shrink the cache is a registered shrinker
1816 dnl # which is called during memory pressure.
1818 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY], [
1819 SPL_CHECK_SYMBOL_EXPORT(
1820 [shrink_dcache_memory],
1822 [AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
1823 [shrink_dcache_memory() is available])],
1828 dnl # 2.6.xx API compat,
1829 dnl # There currently exists no exposed API to partially shrink the icache.
1830 dnl # The expected mechanism to shrink the cache is a registered shrinker
1831 dnl # which is called during memory pressure.
1833 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY], [
1834 SPL_CHECK_SYMBOL_EXPORT(
1835 [shrink_icache_memory],
1837 [AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
1838 [shrink_icache_memory() is available])],
1843 dnl # 2.6.39 API compat,
1844 dnl # The path_lookup() function has been renamed to kern_path_parent()
1845 dnl # and the flags argument has been removed. The only behavior now
1846 dnl # offered is that of LOOKUP_PARENT. The spl already always passed
1847 dnl # this flag so dropping the flag does not impact us.
1849 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_HEADER], [
1850 SPL_CHECK_SYMBOL_HEADER(
1852 [int kern_path_parent(const char \*, struct nameidata \*)],
1853 [include/linux/namei.h],
1854 [AC_DEFINE(HAVE_KERN_PATH_PARENT_HEADER, 1,
1855 [kern_path_parent() is available])],
1860 dnl # 3.1 API compat,
1861 dnl # The kern_path_parent() symbol is no longer exported by the kernel.
1862 dnl # However, it remains the prefered interface and since we still have
1863 dnl # access to the prototype we dynamically lookup the required address.
1865 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_SYMBOL], [
1866 SPL_CHECK_SYMBOL_EXPORT(
1869 [AC_DEFINE(HAVE_KERN_PATH_PARENT_SYMBOL, 1,
1870 [kern_path_parent() is available])],
1875 dnl # 2.6.39 API compat,
1876 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
1877 dnl # This was done to avoid always having to allocate the maximum size
1878 dnl # workspace (268K). The caller can now specific the windowBits and
1879 dnl # memLevel compression parameters to get a smaller workspace.
1881 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
1882 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
1883 SPL_LINUX_TRY_COMPILE([
1884 #include <linux/zlib.h>
1886 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
1889 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
1890 [zlib_deflate_workspacesize() wants 2 args])
1897 dnl # 2.6.39 API change,
1898 dnl # Shrinker adjust to use common shrink_control structure.
1900 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
1901 AC_MSG_CHECKING([whether struct shrink_control exists])
1902 SPL_LINUX_TRY_COMPILE([
1903 #include <linux/mm.h>
1905 struct shrink_control sc __attribute__ ((unused));
1908 sc.gfp_mask = GFP_KERNEL;
1911 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
1912 [struct shrink_control exists])