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], [
12 if test "${LINUX_OBJ}" != "${LINUX}"; then
13 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
15 AC_SUBST(KERNELMAKE_PARAMS)
17 KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes"
18 AC_SUBST(KERNELCPPFLAGS)
23 SPL_AC_DEBUG_KMEM_TRACKING
25 SPL_AC_ATOMIC_SPINLOCK
26 SPL_AC_TYPE_ATOMIC64_CMPXCHG
27 SPL_AC_TYPE_ATOMIC64_XCHG
29 SPL_AC_2ARGS_REGISTER_SYSCTL
30 SPL_AC_SHRINKER_CALLBACK
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
46 SPL_AC_MONOTONIC_CLOCK
49 SPL_AC_MUTEX_OWNER_TASK_STRUCT
50 SPL_AC_MUTEX_LOCK_NESTED
51 SPL_AC_3ARGS_ON_EACH_CPU
52 SPL_AC_KALLSYMS_LOOKUP_NAME
53 SPL_AC_GET_VMALLOC_INFO
55 SPL_AC_FIRST_ONLINE_PGDAT
56 SPL_AC_NEXT_ONLINE_PGDAT
59 SPL_AC_GLOBAL_PAGE_STATE
60 SPL_AC_ZONE_STAT_ITEM_FREE
61 SPL_AC_ZONE_STAT_ITEM_INACTIVE
62 SPL_AC_ZONE_STAT_ITEM_ACTIVE
63 SPL_AC_GET_ZONE_COUNTS
66 SPL_AC_SET_FS_PWD_WITH_CONST
67 SPL_AC_2ARGS_VFS_UNLINK
68 SPL_AC_4ARGS_VFS_RENAME
70 SPL_AC_2ARGS_VFS_FSYNC
71 SPL_AC_INODE_TRUNCATE_RANGE
72 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_FALLOCATE
81 SPL_AC_SHRINK_DCACHE_MEMORY
82 SPL_AC_SHRINK_ICACHE_MEMORY
84 SPL_AC_CONFIG_KALLSYMS
85 SPL_AC_CONFIG_ZLIB_INFLATE
86 SPL_AC_CONFIG_ZLIB_DEFLATE
87 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
88 SPL_AC_SHRINK_CONTROL_STRUCT
89 SPL_AC_RWSEM_SPINLOCK_IS_RAW
90 SPL_AC_SCHED_RT_HEADER
91 SPL_AC_2ARGS_VFS_GETATTR
93 SPL_AC_KMEM_CACHE_ALLOCFLAGS
97 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
98 modpost=$LINUX/scripts/Makefile.modpost
99 AC_MSG_CHECKING([kernel file name for module symbols])
100 if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
101 if grep -q Modules.symvers $modpost; then
102 LINUX_SYMBOLS=Modules.symvers
104 LINUX_SYMBOLS=Module.symvers
107 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
109 *** Please make sure the kernel devel package for your distribution
110 *** is installed. If you are building with a custom kernel, make sure the
111 *** kernel is configured, built, and the '--with-linux=PATH' configure
112 *** option refers to the location of the kernel source.])
117 AC_MSG_RESULT($LINUX_SYMBOLS)
118 AC_SUBST(LINUX_SYMBOLS)
121 AC_DEFUN([SPL_AC_KERNEL], [
123 AS_HELP_STRING([--with-linux=PATH],
124 [Path to kernel source]),
125 [kernelsrc="$withval"])
127 AC_ARG_WITH([linux-obj],
128 AS_HELP_STRING([--with-linux-obj=PATH],
129 [Path to kernel build objects]),
130 [kernelbuild="$withval"])
132 AC_MSG_CHECKING([kernel source directory])
133 if test -z "$kernelsrc"; then
134 if test -e "/lib/modules/$(uname -r)/source"; then
135 headersdir="/lib/modules/$(uname -r)/source"
136 sourcelink=$(readlink -f "$headersdir")
137 elif test -e "/lib/modules/$(uname -r)/build"; then
138 headersdir="/lib/modules/$(uname -r)/build"
139 sourcelink=$(readlink -f "$headersdir")
141 sourcelink=$(ls -1d /usr/src/kernels/* \
143 2>/dev/null | grep -v obj | tail -1)
146 if test -n "$sourcelink" && test -e ${sourcelink}; then
147 kernelsrc=`readlink -f ${sourcelink}`
149 kernelsrc="[Not found]"
152 if test "$kernelsrc" = "NONE"; then
157 AC_MSG_RESULT([$kernelsrc])
158 if test ! -d "$kernelsrc"; then
160 *** Please make sure the kernel devel package for your distribution
161 *** is installed and then try again. If that fails, you can specify the
162 *** location of the kernel source with the '--with-linux=PATH' option.])
165 AC_MSG_CHECKING([kernel build directory])
166 if test -z "$kernelbuild"; then
167 if test -e "/lib/modules/$(uname -r)/build"; then
168 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
169 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
170 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
171 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
172 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
173 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
174 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
176 kernelbuild=${kernelsrc}
179 AC_MSG_RESULT([$kernelbuild])
181 AC_MSG_CHECKING([kernel source version])
182 utsrelease1=$kernelbuild/include/linux/version.h
183 utsrelease2=$kernelbuild/include/linux/utsrelease.h
184 utsrelease3=$kernelbuild/include/generated/utsrelease.h
185 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
186 utsrelease=linux/version.h
187 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
188 utsrelease=linux/utsrelease.h
189 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
190 utsrelease=generated/utsrelease.h
193 if test "$utsrelease"; then
194 kernsrcver=`(echo "#include <$utsrelease>";
195 echo "kernsrcver=UTS_RELEASE") |
196 cpp -I $kernelbuild/include |
197 grep "^kernsrcver=" | cut -d \" -f 2`
199 if test -z "$kernsrcver"; then
200 AC_MSG_RESULT([Not found])
201 AC_MSG_ERROR([*** Cannot determine kernel version.])
204 AC_MSG_RESULT([Not found])
205 if test "x$enable_linux_builtin" != xyes; then
206 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
209 *** Cannot find UTS_RELEASE definition.
210 *** Please run 'make prepare' inside the kernel source tree.])
214 AC_MSG_RESULT([$kernsrcver])
217 LINUX_OBJ=${kernelbuild}
218 LINUX_VERSION=${kernsrcver}
222 AC_SUBST(LINUX_VERSION)
224 SPL_AC_MODULE_SYMVERS
228 dnl # Default SPL user configuration
230 AC_DEFUN([SPL_AC_CONFIG_USER], [])
233 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
234 dnl # are missing, it is non-fatal, but you will not be able to build
235 dnl # RPM packages and will be warned if you try too.
237 dnl # By default, the generic spec file will be used because it requires
238 dnl # minimal dependencies. Distribution specific spec files can be
239 dnl # placed under the 'rpm/<distribution>' directory and enabled using
240 dnl # the --with-spec=<distribution> configure option.
242 AC_DEFUN([SPL_AC_RPM], [
246 AC_MSG_CHECKING([whether $RPM is available])
247 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
248 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
250 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
253 AC_MSG_RESULT([$HAVE_RPM])
256 AC_MSG_CHECKING([whether $RPMBUILD is available])
257 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
258 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
260 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
263 AC_MSG_RESULT([$HAVE_RPMBUILD])
266 RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_LOG) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"'
268 RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
271 SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
276 RPM_SPEC_DIR="rpm/generic"
278 AS_HELP_STRING([--with-spec=SPEC],
279 [Spec files 'generic|fedora']),
280 [RPM_SPEC_DIR="rpm/$withval"])
282 AC_MSG_CHECKING([whether spec files are available])
283 AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
287 AC_SUBST(RPM_VERSION)
289 AC_SUBST(HAVE_RPMBUILD)
291 AC_SUBST(RPMBUILD_VERSION)
293 AC_SUBST(RPM_SPEC_DIR)
294 AC_SUBST(RPM_DEFINE_UTIL)
295 AC_SUBST(RPM_DEFINE_KMOD)
296 AC_SUBST(RPM_DEFINE_DKMS)
297 AC_SUBST(RPM_DEFINE_COMMON)
298 AC_SUBST(SRPM_DEFINE_UTIL)
299 AC_SUBST(SRPM_DEFINE_KMOD)
300 AC_SUBST(SRPM_DEFINE_DKMS)
301 AC_SUBST(SRPM_DEFINE_COMMON)
305 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
306 dnl # tools are missing it is non-fatal but you will not be able to build
307 dnl # DEB packages and will be warned if you try too.
309 AC_DEFUN([SPL_AC_DPKG], [
311 DPKGBUILD=dpkg-buildpackage
313 AC_MSG_CHECKING([whether $DPKG is available])
314 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
315 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
317 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
320 AC_MSG_RESULT([$HAVE_DPKG])
323 AC_MSG_CHECKING([whether $DPKGBUILD is available])
324 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
325 DPKGBUILD_VERSION=$(echo $tmp | \
326 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
328 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
331 AC_MSG_RESULT([$HAVE_DPKGBUILD])
336 AC_SUBST(DPKG_VERSION)
338 AC_SUBST(HAVE_DPKGBUILD)
340 AC_SUBST(DPKGBUILD_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/toss-release ; then
375 elif test -f /etc/fedora-release ; then
377 elif test -f /etc/redhat-release ; then
379 elif test -f /etc/gentoo-release ; then
381 elif test -f /etc/arch-release ; then
383 elif test -f /etc/SuSE-release ; then
385 elif test -f /etc/slackware-version ; then
387 elif test -f /etc/lunar.release ; then
389 elif test -f /etc/lsb-release ; then
391 elif test -f /etc/debian_version ; then
396 AC_MSG_RESULT([$VENDOR])
399 AC_MSG_CHECKING([default package type])
401 toss) DEFAULT_PACKAGE=rpm ;;
402 redhat) DEFAULT_PACKAGE=rpm ;;
403 fedora) DEFAULT_PACKAGE=rpm ;;
404 gentoo) DEFAULT_PACKAGE=tgz ;;
405 arch) DEFAULT_PACKAGE=tgz ;;
406 sles) DEFAULT_PACKAGE=rpm ;;
407 slackware) DEFAULT_PACKAGE=tgz ;;
408 lunar) DEFAULT_PACKAGE=tgz ;;
409 ubuntu) DEFAULT_PACKAGE=deb ;;
410 debian) DEFAULT_PACKAGE=deb ;;
411 *) DEFAULT_PACKAGE=rpm ;;
414 AC_MSG_RESULT([$DEFAULT_PACKAGE])
415 AC_SUBST(DEFAULT_PACKAGE)
419 dnl # Default SPL user configuration
421 AC_DEFUN([SPL_AC_PACKAGE], [
422 SPL_AC_DEFAULT_PACKAGE
428 AC_DEFUN([SPL_AC_LICENSE], [
429 AC_MSG_CHECKING([spl author])
430 AC_MSG_RESULT([$SPL_META_AUTHOR])
432 AC_MSG_CHECKING([spl license])
433 AC_MSG_RESULT([$SPL_META_LICENSE])
436 AC_DEFUN([SPL_AC_CONFIG], [
438 AC_ARG_WITH([config],
439 AS_HELP_STRING([--with-config=CONFIG],
440 [Config file 'kernel|user|all|srpm']),
441 [SPL_CONFIG="$withval"])
442 AC_ARG_ENABLE([linux-builtin],
443 [AC_HELP_STRING([--enable-linux-builtin],
444 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
446 [enable_linux_builtin=no])
448 AC_MSG_CHECKING([spl config])
449 AC_MSG_RESULT([$SPL_CONFIG]);
452 case "$SPL_CONFIG" in
453 kernel) SPL_AC_CONFIG_KERNEL ;;
454 user) SPL_AC_CONFIG_USER ;;
455 all) SPL_AC_CONFIG_KERNEL
456 SPL_AC_CONFIG_USER ;;
459 AC_MSG_RESULT([Error!])
460 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
461 user kernel|user|all|srpm]) ;;
464 AM_CONDITIONAL([CONFIG_USER],
465 [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
466 AM_CONDITIONAL([CONFIG_KERNEL],
467 [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
468 [test "x$enable_linux_builtin" != xyes ])
472 dnl # Enable if the SPL should be compiled with internal debugging enabled.
473 dnl # By default this support is disabled.
475 AC_DEFUN([SPL_AC_DEBUG], [
476 AC_MSG_CHECKING([whether debugging is enabled])
477 AC_ARG_ENABLE([debug],
478 [AS_HELP_STRING([--enable-debug],
479 [Enable generic debug support @<:@default=no@:>@])],
483 AS_IF([test "x$enable_debug" = xyes],
485 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
486 DEBUG_CFLAGS="-DDEBUG -Werror"
487 DEBUG_SPL="_with_debug"
489 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
490 DEBUG_CFLAGS="-DNDEBUG"
491 DEBUG_SPL="_without_debug"
494 AC_SUBST(DEBUG_CFLAGS)
496 AC_MSG_RESULT([$enable_debug])
500 dnl # Enabled by default it provides a basic debug log infrastructure.
501 dnl # Each subsystem registers itself with a name and logs messages
502 dnl # using predefined types. If the debug mask it set to allow the
503 dnl # message type it will be written to the internal log. The log
504 dnl # can be dumped to a file by echoing 1 to the 'dump' proc entry,
505 dnl # after dumping the log it must be decoded using the spl utility.
507 dnl # echo 1 >/proc/sys/kernel/spl/debug/dump
508 dnl # spl /tmp/spl-log.xxx.yyy /tmp/spl-log.xxx.yyy.txt
510 AC_DEFUN([SPL_AC_DEBUG_LOG], [
511 AC_ARG_ENABLE([debug-log],
512 [AS_HELP_STRING([--enable-debug-log],
513 [Enable basic debug logging @<:@default=yes@:>@])],
515 [enable_debug_log=yes])
517 AS_IF([test "x$enable_debug_log" = xyes],
519 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG"
520 DEBUG_LOG="_with_debug_log"
521 AC_DEFINE([DEBUG_LOG], [1],
522 [Define to 1 to enable basic debug logging])
524 DEBUG_LOG="_without_debug_log"
528 AC_MSG_CHECKING([whether basic debug logging is enabled])
529 AC_MSG_RESULT([$enable_debug_log])
533 dnl # Enabled by default it provides a minimal level of memory tracking.
534 dnl # A total count of bytes allocated is kept for each alloc and free.
535 dnl # Then at module unload time a report to the console will be printed
536 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
537 dnl # and provide an easy way to inspect the kmem based slab.
539 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
540 AC_ARG_ENABLE([debug-kmem],
541 [AS_HELP_STRING([--enable-debug-kmem],
542 [Enable basic kmem accounting @<:@default=yes@:>@])],
544 [enable_debug_kmem=yes])
546 AS_IF([test "x$enable_debug_kmem" = xyes],
548 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
549 DEBUG_KMEM="_with_debug_kmem"
550 AC_DEFINE([DEBUG_KMEM], [1],
551 [Define to 1 to enable basic kmem accounting])
553 DEBUG_KMEM="_without_debug_kmem"
557 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
558 AC_MSG_RESULT([$enable_debug_kmem])
562 dnl # Disabled by default it provides detailed memory tracking. This
563 dnl # feature also requires --enable-debug-kmem to be set. When enabled
564 dnl # not only will total bytes be tracked but also the location of every
565 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
566 dnl # addresses and where they were allocated will be dumped to the console.
567 dnl # Enabling this feature has a significant impact on performance but it
568 dnl # makes finding memory leaks pretty straight forward.
570 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
571 AC_ARG_ENABLE([debug-kmem-tracking],
572 [AS_HELP_STRING([--enable-debug-kmem-tracking],
573 [Enable detailed kmem tracking @<:@default=no@:>@])],
575 [enable_debug_kmem_tracking=no])
577 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
579 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
580 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
581 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
582 [Define to 1 to enable detailed kmem tracking])
584 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
587 AC_SUBST(DEBUG_KMEM_TRACKING)
588 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
589 AC_MSG_RESULT([$enable_debug_kmem_tracking])
593 dnl # SPL_LINUX_CONFTEST
595 AC_DEFUN([SPL_LINUX_CONFTEST], [
596 cat confdefs.h - <<_ACEOF >conftest.c
602 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
604 m4_define([SPL_LANG_PROGRAM], [
609 dnl Do *not* indent the following line: there may be CPP directives.
610 dnl Don't move the `;' right after for the same reason.
618 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
620 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
621 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
622 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
623 echo "obj-m := conftest.o" >build/Makefile
625 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
627 [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 $modpost_flag) >/dev/null && AC_TRY_COMMAND([$3])],
629 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
635 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
637 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
638 [SPL_LINUX_COMPILE_IFELSE(
639 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
641 [test -s build/conftest.o],
646 dnl # SPL_CHECK_SYMBOL_EXPORT
647 dnl # check symbol exported or not
649 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
650 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
651 $LINUX_OBJ/Module*.symvers 2>/dev/null
653 if test $rc -ne 0; then
656 grep -q -E "EXPORT_SYMBOL.*($1)" \
657 "$LINUX_OBJ/$file" 2>/dev/null
659 if test $rc -eq 0; then
664 if test $export -eq 0; then :
675 dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
676 dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
677 dnl # is called if not compiling for builtin
679 AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
680 SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
681 if test $rc -ne 0; then :
684 if test "x$enable_linux_builtin" != xyes; then
685 SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
687 if test $rc -ne 0; then :
696 dnl # SPL_CHECK_SYMBOL_HEADER
697 dnl # check if a symbol prototype is defined in listed headers.
699 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
700 AC_MSG_CHECKING([whether symbol $1 exists in header])
703 grep -q "$2" "$LINUX/$file" 2>/dev/null
705 if test $rc -eq 0; then
710 if test $header -eq 0; then
720 dnl # SPL_CHECK_HEADER
721 dnl # check whether header exists and define HAVE_$2_HEADER
723 AC_DEFUN([SPL_CHECK_HEADER],
724 [AC_MSG_CHECKING([whether header $1 exists])
725 SPL_LINUX_TRY_COMPILE([
730 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
740 dnl # Basic toolchain sanity check. Verify that kernel modules can
741 dnl # be built and which symbols can be used.
743 AC_DEFUN([SPL_AC_TEST_MODULE],
744 [AC_MSG_CHECKING([whether modules can be built])
745 SPL_LINUX_TRY_COMPILE([],[],[
749 if test "x$enable_linux_builtin" != xyes; then
750 AC_MSG_ERROR([*** Unable to build an empty module.])
753 *** Unable to build an empty module.
754 *** Please run 'make scripts' inside the kernel source tree.])
760 #include "$LINUX/include/linux/license.h"
762 return !license_is_gpl_compatible("$SPL_META_LICENSE");
765 AC_DEFINE([SPL_IS_GPL_COMPATIBLE], [1],
766 [Define to 1 if GPL-only symbols can be used])
772 dnl # Use the atomic implemenation based on global spinlocks. This
773 dnl # should only be needed by 32-bit kernels which do not provide
774 dnl # the atomic64_* API. It may be optionally enabled as a fallback
775 dnl # if problems are observed with the direct mapping to the native
776 dnl # Linux atomic operations. You may not disable atomic spinlocks
777 dnl # if you kernel does not an atomic64_* API.
779 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
780 AC_ARG_ENABLE([atomic-spinlocks],
781 [AS_HELP_STRING([--enable-atomic-spinlocks],
782 [Atomic types use spinlocks @<:@default=check@:>@])],
784 [enable_atomic_spinlocks=check])
786 SPL_LINUX_TRY_COMPILE([
787 #include <linux/fs.h>
789 atomic64_t *ptr __attribute__ ((unused));
792 AC_DEFINE(HAVE_ATOMIC64_T, 1,
793 [kernel defines atomic64_t])
798 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
799 AS_IF([test "x$have_atomic64_t" = xyes], [
800 enable_atomic_spinlocks=no
802 enable_atomic_spinlocks=yes
806 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
807 AC_DEFINE([ATOMIC_SPINLOCK], [1],
808 [Atomic types use spinlocks])
810 AS_IF([test "x$have_atomic64_t" = xno], [
812 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
816 AC_MSG_CHECKING([whether atomic types use spinlocks])
817 AC_MSG_RESULT([$enable_atomic_spinlocks])
819 AC_MSG_CHECKING([whether kernel defines atomic64_t])
820 AC_MSG_RESULT([$have_atomic64_t])
824 dnl # 2.6.24 API change,
825 dnl # check if atomic64_cmpxchg is defined
827 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
828 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
829 SPL_LINUX_TRY_COMPILE([
830 #include <linux/fs.h>
832 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
835 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
836 [kernel defines atomic64_cmpxchg])
843 dnl # 2.6.24 API change,
844 dnl # check if atomic64_xchg is defined
846 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
847 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
848 SPL_LINUX_TRY_COMPILE([
849 #include <linux/fs.h>
851 atomic64_xchg((atomic64_t *)NULL, 0);
854 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
855 [kernel defines atomic64_xchg])
862 dnl # 2.6.24 API change,
863 dnl # check if uintptr_t typedef is defined
865 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
866 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
867 SPL_LINUX_TRY_COMPILE([
868 #include <linux/types.h>
870 uintptr_t *ptr __attribute__ ((unused));
873 AC_DEFINE(HAVE_UINTPTR_T, 1,
874 [kernel defines uintptr_t])
881 dnl # 2.6.21 API change,
882 dnl # 'register_sysctl_table' use only one argument instead of two
884 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
885 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
886 SPL_LINUX_TRY_COMPILE([
887 #include <linux/sysctl.h>
889 (void) register_sysctl_table(NULL, 0);
892 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
893 [register_sysctl_table() wants 2 args])
899 AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[
900 tmp_flags="$EXTRA_KCFLAGS"
901 EXTRA_KCFLAGS="-Werror"
903 dnl # 2.6.23 to 2.6.34 API change
904 dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask)
906 AC_MSG_CHECKING([whether old 2-argument shrinker exists])
907 SPL_LINUX_TRY_COMPILE([
908 #include <linux/mm.h>
910 int shrinker_cb(int nr_to_scan, gfp_t gfp_mask);
912 struct shrinker cache_shrinker = {
913 .shrink = shrinker_cb,
914 .seeks = DEFAULT_SEEKS,
916 register_shrinker(&cache_shrinker);
919 AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1,
920 [old shrinker callback wants 2 args])
924 dnl # 2.6.35 - 2.6.39 API change
925 dnl # ->shrink(struct shrinker *,
926 dnl # int nr_to_scan, gfp_t gfp_mask)
928 AC_MSG_CHECKING([whether old 3-argument shrinker exists])
929 SPL_LINUX_TRY_COMPILE([
930 #include <linux/mm.h>
932 int shrinker_cb(struct shrinker *, int nr_to_scan,
935 struct shrinker cache_shrinker = {
936 .shrink = shrinker_cb,
937 .seeks = DEFAULT_SEEKS,
939 register_shrinker(&cache_shrinker);
942 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
943 [old shrinker callback wants 3 args])
947 dnl # 3.0 - 3.11 API change
948 dnl # ->shrink(struct shrinker *,
949 dnl # struct shrink_control *sc)
952 [whether new 2-argument shrinker exists])
953 SPL_LINUX_TRY_COMPILE([
954 #include <linux/mm.h>
956 int shrinker_cb(struct shrinker *,
957 struct shrink_control *sc);
959 struct shrinker cache_shrinker = {
960 .shrink = shrinker_cb,
961 .seeks = DEFAULT_SEEKS,
963 register_shrinker(&cache_shrinker);
966 AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1,
967 [new shrinker callback wants 2 args])
971 dnl # 3.12 API change,
972 dnl # ->shrink() is logically split in to
973 dnl # ->count_objects() and ->scan_objects()
976 [whether ->count_objects callback exists])
977 SPL_LINUX_TRY_COMPILE([
978 #include <linux/mm.h>
980 unsigned long shrinker_cb(
982 struct shrink_control *sc);
984 struct shrinker cache_shrinker = {
985 .count_objects = shrinker_cb,
986 .scan_objects = shrinker_cb,
987 .seeks = DEFAULT_SEEKS,
989 register_shrinker(&cache_shrinker);
992 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
993 1, [->count_objects exists])
1000 EXTRA_KCFLAGS="$tmp_flags"
1004 dnl # Custom SPL patch may export this system it is not required
1006 AC_DEFUN([SPL_AC_TASK_CURR],
1007 [AC_MSG_CHECKING([whether task_curr() is available])
1008 SPL_LINUX_TRY_COMPILE_SYMBOL([
1009 #include <linux/sched.h>
1012 ], [task_curr], [kernel/sched.c], [
1014 AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() is available])
1021 dnl # 2.6.19 API change,
1022 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
1024 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
1025 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
1026 SPL_LINUX_TRY_COMPILE([
1027 #include <linux/sysctl.h>
1029 #ifndef CTL_UNNUMBERED
1030 #error CTL_UNNUMBERED undefined
1034 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
1035 [unnumbered sysctl support exists])
1042 dnl # 2.6.33 API change,
1043 dnl # Removed .ctl_name from struct ctl_table.
1045 AC_DEFUN([SPL_AC_CTL_NAME], [
1046 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
1047 SPL_LINUX_TRY_COMPILE([
1048 #include <linux/sysctl.h>
1050 struct ctl_table ctl __attribute__ ((unused));
1054 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
1061 dnl # 2.6.16 API change.
1062 dnl # Check if 'fls64()' is available
1064 AC_DEFUN([SPL_AC_FLS64],
1065 [AC_MSG_CHECKING([whether fls64() is available])
1066 SPL_LINUX_TRY_COMPILE([
1067 #include <linux/bitops.h>
1072 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
1079 dnl # 2.6.18 API change, check whether device_create() is available.
1080 dnl # Device_create() was introduced in 2.6.18 and depricated
1081 dnl # class_device_create() which was fully removed in 2.6.26.
1083 AC_DEFUN([SPL_AC_DEVICE_CREATE],
1084 [AC_MSG_CHECKING([whether device_create() is available])
1085 SPL_CHECK_SYMBOL_EXPORT([device_create], [drivers/base/core.c], [
1087 AC_DEFINE(HAVE_DEVICE_CREATE, 1,
1088 [device_create() is available])
1095 dnl # 2.6.27 API change,
1096 dnl # device_create() uses 5 args, new 'drvdata' argument.
1098 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
1099 AC_MSG_CHECKING([whether device_create() wants 5 args])
1100 tmp_flags="$EXTRA_KCFLAGS"
1101 EXTRA_KCFLAGS="-Werror"
1102 SPL_LINUX_TRY_COMPILE([
1103 #include <linux/device.h>
1105 device_create(NULL, NULL, 0, NULL, "%d", 1);
1108 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
1109 [device_create wants 5 args])
1113 EXTRA_KCFLAGS="$tmp_flags"
1117 dnl # 2.6.13 API change, check whether class_device_create() is available.
1118 dnl # Class_device_create() was introduced in 2.6.13 and depricated
1119 dnl # class_simple_device_add() which was fully removed in 2.6.13.
1121 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE],
1122 [AC_MSG_CHECKING([whether class_device_create() is available])
1123 SPL_LINUX_TRY_COMPILE_SYMBOL([
1124 #include <linux/device.h>
1126 class_device_create(NULL, NULL, 0, NULL, NULL);
1127 ], [class_device_create], [drivers/base/class.c], [
1129 AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
1130 [class_device_create() is available])
1137 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
1139 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT],
1140 [AC_MSG_CHECKING([whether set_normalized_timespec() is available as export])
1141 SPL_LINUX_TRY_COMPILE_SYMBOL([
1142 #include <linux/time.h>
1144 set_normalized_timespec(NULL, 0, 0);
1145 ], [set_normalized_timespec], [kernel/time.c], [
1147 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
1148 [set_normalized_timespec() is available as export])
1155 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
1156 dnl # previously it was available in time.h as an inline.
1158 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
1159 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
1160 SPL_LINUX_TRY_COMPILE([
1161 #include <linux/time.h>
1162 void set_normalized_timespec(struct timespec *ts,
1163 time_t sec, long nsec) { }
1170 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
1171 [set_normalized_timespec() is available as inline])
1176 dnl # 2.6.18 API change,
1177 dnl # timespec_sub() inline function available in linux/time.h
1179 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
1180 AC_MSG_CHECKING([whether timespec_sub() is available])
1181 SPL_LINUX_TRY_COMPILE([
1182 #include <linux/time.h>
1184 struct timespec a = { 0 };
1185 struct timespec b = { 0 };
1186 struct timespec c __attribute__ ((unused));
1187 c = timespec_sub(a, b);
1190 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1197 dnl # 2.6.19 API change,
1198 dnl # check if init_utsname() is available in linux/utsname.h
1200 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
1201 AC_MSG_CHECKING([whether init_utsname() is available])
1202 SPL_LINUX_TRY_COMPILE([
1203 #include <linux/utsname.h>
1205 struct new_utsname *a __attribute__ ((unused));
1209 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1216 dnl # 2.6.18 API change,
1217 dnl # added linux/uaccess.h
1219 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1220 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1224 dnl # 2.6.12 API change,
1225 dnl # check whether 'kmalloc_node()' is available.
1227 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1228 AC_MSG_CHECKING([whether kmalloc_node() is available])
1229 SPL_LINUX_TRY_COMPILE([
1230 #include <linux/slab.h>
1232 void *a __attribute__ ((unused));
1233 a = kmalloc_node(1, GFP_KERNEL, 0);
1236 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1243 dnl # 2.6.9 API change,
1244 dnl # check whether 'monotonic_clock()' is available it may
1245 dnl # be available for some archs but not others.
1247 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK],
1248 [AC_MSG_CHECKING([whether monotonic_clock() is available])
1249 SPL_LINUX_TRY_COMPILE_SYMBOL([
1250 #include <linux/timex.h>
1253 ], [monotonic_clock], [], [
1255 AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1256 [monotonic_clock() is available])
1263 dnl # 2.6.16 API change,
1264 dnl # check whether 'struct inode' has i_mutex
1266 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1267 AC_MSG_CHECKING([whether struct inode has i_mutex])
1268 SPL_LINUX_TRY_COMPILE([
1269 #include <linux/fs.h>
1270 #include <linux/mutex.h>
1273 mutex_init(&i.i_mutex);
1276 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1283 dnl # 2.6.29 API change,
1284 dnl # Adaptive mutexs introduced.
1286 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1287 AC_MSG_CHECKING([whether struct mutex has owner])
1288 SPL_LINUX_TRY_COMPILE([
1289 #include <linux/mutex.h>
1291 struct mutex mtx __attribute__ ((unused));
1295 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1302 dnl # 2.6.39 API change,
1303 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
1304 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
1305 dnl # was defined. As of 2.6.39 this was changed to a task_struct
1306 dnl # pointer which frankly makes a lot more sense.
1308 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
1309 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
1310 tmp_flags="$EXTRA_KCFLAGS"
1311 EXTRA_KCFLAGS="-Werror"
1312 SPL_LINUX_TRY_COMPILE([
1313 #include <linux/mutex.h>
1314 #include <linux/sched.h>
1316 struct mutex mtx __attribute__ ((unused));
1317 mtx.owner = current;
1320 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
1321 [struct mutex owner is a task_struct])
1325 EXTRA_KCFLAGS="$tmp_flags"
1329 dnl # 2.6.18 API change,
1330 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1331 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1332 dnl # if the mutex validator is disabled or otherwise unavailable.
1334 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1335 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1336 SPL_LINUX_TRY_COMPILE([
1337 #include <linux/mutex.h>
1341 mutex_lock_nested(&mutex, 0);
1344 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1345 [mutex_lock_nested() is available])
1352 dnl # 2.6.27 API change,
1353 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1355 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1356 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1357 SPL_LINUX_TRY_COMPILE([
1358 #include <linux/interrupt.h>
1359 #include <linux/smp.h>
1361 void on_each_cpu_func(void *data) { return; }
1363 on_each_cpu(on_each_cpu_func, NULL, 0);
1366 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1367 [on_each_cpu wants 3 args])
1374 dnl # 2.6.18 API change,
1375 dnl # kallsyms_lookup_name no longer exported
1377 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME],
1378 [AC_MSG_CHECKING([whether kallsyms_lookup_name() is available])
1379 SPL_LINUX_TRY_COMPILE_SYMBOL([
1380 #include <linux/kallsyms.h>
1382 kallsyms_lookup_name(NULL);
1383 ], [kallsyms_lookup_name], [], [
1385 AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1386 [kallsyms_lookup_name() is available])
1393 dnl # Proposed API change,
1394 dnl # This symbol is not available in stock kernels. You may build a
1395 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1396 dnl # these symbols for use. If your already rolling a custom kernel for
1397 dnl # your environment this is recommended.
1399 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO],
1400 [AC_MSG_CHECKING([whether get_vmalloc_info() is available])
1401 SPL_CHECK_SYMBOL_EXPORT([get_vmalloc_info], [], [
1403 AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1404 [get_vmalloc_info() is available])
1411 dnl # 3.10 API change,
1412 dnl # struct vmalloc_info is now declared in linux/vmalloc.h
1414 AC_DEFUN([SPL_AC_VMALLOC_INFO], [
1415 AC_MSG_CHECKING([whether struct vmalloc_info is declared])
1416 SPL_LINUX_TRY_COMPILE([
1417 #include <linux/vmalloc.h>
1418 struct vmalloc_info { void *a; };
1425 AC_DEFINE(HAVE_VMALLOC_INFO, 1, [yes])
1430 dnl # 3.10 API change,
1431 dnl # PDE is replaced by PDE_DATA
1433 AC_DEFUN([SPL_AC_PDE_DATA], [
1434 AC_MSG_CHECKING([whether PDE_DATA() is available])
1435 SPL_LINUX_TRY_COMPILE_SYMBOL([
1436 #include <linux/proc_fs.h>
1439 ], [PDE_DATA], [], [
1441 AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
1448 dnl # 2.6.17 API change
1449 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1450 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1451 dnl # were exported in 2.6.17 for use by modules which was consistent with
1452 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1453 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1454 dnl # were dropped entirely leaving modules no way to directly iterate over
1455 dnl # the zone list. Because we need access to the zone helpers we check
1456 dnl # if the kernel contains the old or new implementation. Then we check
1457 dnl # to see if the symbols we need for each version are available. If they
1458 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1460 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1461 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1462 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1464 if test $rc -eq 0; then
1465 AC_MSG_RESULT([yes])
1466 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1473 dnl # Proposed API change,
1474 dnl # This symbol is not available in stock kernels. You may build a
1475 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1476 dnl # these symbols for use. If your already rolling a custom kernel for
1477 dnl # your environment this is recommended.
1479 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT],
1480 [AC_MSG_CHECKING([whether first_online_pgdat() is available])
1481 SPL_LINUX_TRY_COMPILE_SYMBOL([
1482 #include <linux/mmzone.h>
1484 first_online_pgdat();
1485 ], [first_online_pgdat], [], [
1487 AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1488 [first_online_pgdat() is available])
1495 dnl # Proposed API change,
1496 dnl # This symbol is not available in stock kernels. You may build a
1497 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1498 dnl # these symbols for use. If your already rolling a custom kernel for
1499 dnl # your environment this is recommended.
1501 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT],
1502 [AC_MSG_CHECKING([whether next_online_pgdat() is available])
1503 SPL_LINUX_TRY_COMPILE_SYMBOL([
1504 #include <linux/mmzone.h>
1506 next_online_pgdat(NULL);
1507 ], [next_online_pgdat], [], [
1509 AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1510 [next_online_pgdat() is available])
1517 dnl # Proposed API change,
1518 dnl # This symbol is not available in stock kernels. You may build a
1519 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1520 dnl # these symbols for use. If your already rolling a custom kernel for
1521 dnl # your environment this is recommended.
1523 AC_DEFUN([SPL_AC_NEXT_ZONE],
1524 [AC_MSG_CHECKING([whether next_zone() is available])
1525 SPL_LINUX_TRY_COMPILE_SYMBOL([
1526 #include <linux/mmzone.h>
1529 ], [next_zone], [], [
1531 AC_DEFINE(HAVE_NEXT_ZONE, 1, [next_zone() is available])
1538 dnl # 2.6.17 API change,
1539 dnl # See SPL_AC_PGDAT_HELPERS for details.
1541 AC_DEFUN([SPL_AC_PGDAT_LIST],
1542 [AC_MSG_CHECKING([whether pgdat_list is available])
1543 SPL_LINUX_TRY_COMPILE_SYMBOL([
1544 #include <linux/topology.h>
1545 pg_data_t *tmp = pgdat_list;
1546 ], [], [pgdat_list], [], [
1548 AC_DEFINE(HAVE_PGDAT_LIST, 1, [pgdat_list is available])
1555 dnl # 2.6.18 API change,
1556 dnl # First introduced global_page_state() support as an inline.
1558 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1559 AC_MSG_CHECKING([whether global_page_state() is available])
1560 SPL_LINUX_TRY_COMPILE([
1561 #include <linux/mm.h>
1563 unsigned long state __attribute__ ((unused));
1564 state = global_page_state(0);
1567 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1568 [global_page_state() is available])
1575 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1576 dnl # Public global zone stats now include a free page count. However
1577 dnl # the enumerated names of the counters have changed since this API
1578 dnl # was introduced. We need to deduce the corrent name to use. This
1579 dnl # replaces the priviate get_zone_counts() interface.
1581 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1582 dnl # is 2.6.30 as of when this was written.
1584 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1585 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1586 SPL_LINUX_TRY_COMPILE([
1587 #include <linux/mm.h>
1589 enum zone_stat_item zsi __attribute__ ((unused));
1590 zsi = NR_FREE_PAGES;
1593 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1594 [Page state NR_FREE_PAGES is available])
1601 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1602 dnl # Public global zone stats now include an inactive page count. However
1603 dnl # the enumerated names of the counters have changed since this API
1604 dnl # was introduced. We need to deduce the corrent name to use. This
1605 dnl # replaces the priviate get_zone_counts() interface.
1607 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1608 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1609 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1611 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1612 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1613 SPL_LINUX_TRY_COMPILE([
1614 #include <linux/mm.h>
1616 enum zone_stat_item zsi __attribute__ ((unused));
1620 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1621 [Page state NR_INACTIVE is available])
1626 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1627 SPL_LINUX_TRY_COMPILE([
1628 #include <linux/mm.h>
1630 enum zone_stat_item zsi __attribute__ ((unused));
1631 zsi = NR_INACTIVE_ANON;
1634 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1635 [Page state NR_INACTIVE_ANON is available])
1640 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1641 SPL_LINUX_TRY_COMPILE([
1642 #include <linux/mm.h>
1644 enum zone_stat_item zsi __attribute__ ((unused));
1645 zsi = NR_INACTIVE_FILE;
1648 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1649 [Page state NR_INACTIVE_FILE is available])
1656 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1657 dnl # Public global zone stats now include an active page count. However
1658 dnl # the enumerated names of the counters have changed since this API
1659 dnl # was introduced. We need to deduce the corrent name to use. This
1660 dnl # replaces the priviate get_zone_counts() interface.
1662 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1663 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1664 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1666 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1667 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1668 SPL_LINUX_TRY_COMPILE([
1669 #include <linux/mm.h>
1671 enum zone_stat_item zsi __attribute__ ((unused));
1675 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1676 [Page state NR_ACTIVE is available])
1681 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1682 SPL_LINUX_TRY_COMPILE([
1683 #include <linux/mm.h>
1685 enum zone_stat_item zsi __attribute__ ((unused));
1686 zsi = NR_ACTIVE_ANON;
1689 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1690 [Page state NR_ACTIVE_ANON is available])
1695 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1696 SPL_LINUX_TRY_COMPILE([
1697 #include <linux/mm.h>
1699 enum zone_stat_item zsi __attribute__ ((unused));
1700 zsi = NR_ACTIVE_FILE;
1703 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1704 [Page state NR_ACTIVE_FILE is available])
1711 dnl # Proposed API change for legacy kernels.
1712 dnl # This symbol is not available in older kernels. For kernels post
1713 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1714 dnl # page state information. This symbol is only used in legacy kernels
1715 dnl # any only as a last resort.
1717 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1718 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1719 SPL_LINUX_TRY_COMPILE([
1721 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1722 #error "global_page_state needs NR_FREE_PAGES"
1725 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1726 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1727 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1728 #error "global_page_state needs NR_ACTIVE*"
1731 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1732 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1733 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1734 #error "global_page_state needs NR_INACTIVE*"
1740 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1741 [get_zone_counts() is needed])
1743 AC_MSG_CHECKING([whether get_zone_counts() is available])
1744 SPL_LINUX_TRY_COMPILE_SYMBOL([
1745 #include <linux/mmzone.h>
1747 get_zone_counts(NULL, NULL, NULL);
1748 ], [get_zone_counts], [], [
1750 AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1751 [get_zone_counts() is available])
1759 dnl # 2.6.27 API change,
1760 dnl # The user_path_dir() replaces __user_walk()
1762 AC_DEFUN([SPL_AC_USER_PATH_DIR],
1763 [AC_MSG_CHECKING([whether user_path_dir() is available])
1764 SPL_LINUX_TRY_COMPILE_SYMBOL([
1765 #include <linux/fcntl.h>
1766 #include <linux/namei.h>
1768 user_path_dir(NULL, NULL);
1769 ], [user_path_at], [], [
1771 AC_DEFINE(HAVE_USER_PATH_DIR, 1, [user_path_dir() is available])
1778 dnl # Symbol available in RHEL kernels not in stock kernels.
1780 AC_DEFUN([SPL_AC_SET_FS_PWD],
1781 [AC_MSG_CHECKING([whether set_fs_pwd() is available])
1782 SPL_LINUX_TRY_COMPILE_SYMBOL([
1783 #include <linux/spinlock.h>
1784 #include <linux/fs_struct.h>
1787 ], [set_fs_pwd], [], [
1789 AC_DEFINE(HAVE_SET_FS_PWD, 1, [set_fs_pwd() is available])
1796 dnl # 3.9 API change
1797 dnl # set_fs_pwd takes const struct path *
1799 AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
1800 tmp_flags="$EXTRA_KCFLAGS"
1801 EXTRA_KCFLAGS="-Werror"
1802 [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
1803 SPL_LINUX_TRY_COMPILE([
1804 #include <linux/spinlock.h>
1805 #include <linux/fs_struct.h>
1806 #include <linux/path.h>
1807 void (*const set_fs_pwd_func)
1808 (struct fs_struct *, const struct path *)
1814 AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
1815 [set_fs_pwd() needs const path *])
1817 SPL_LINUX_TRY_COMPILE([
1818 #include <linux/spinlock.h>
1819 #include <linux/fs_struct.h>
1820 #include <linux/path.h>
1821 void (*const set_fs_pwd_func)
1822 (struct fs_struct *, struct path *)
1829 AC_MSG_ERROR(unknown)
1832 EXTRA_KCFLAGS="$tmp_flags"
1835 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1836 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1837 SPL_LINUX_TRY_COMPILE([
1838 #include <linux/fs.h>
1840 vfs_unlink((struct inode *) NULL, (struct dentry *) NULL);
1843 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1844 [vfs_unlink() wants 2 args])
1848 dnl # Linux 3.13 API change
1849 dnl # Added delegated inode
1851 AC_MSG_CHECKING([whether vfs_unlink() wants 3 args])
1852 SPL_LINUX_TRY_COMPILE([
1853 #include <linux/fs.h>
1855 vfs_unlink((struct inode *) NULL,
1856 (struct dentry *) NULL,
1857 (struct inode **) NULL);
1860 AC_DEFINE(HAVE_3ARGS_VFS_UNLINK, 1,
1861 [vfs_unlink() wants 3 args])
1869 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1870 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1871 SPL_LINUX_TRY_COMPILE([
1872 #include <linux/fs.h>
1874 vfs_rename((struct inode *) NULL, (struct dentry *) NULL,
1875 (struct inode *) NULL, (struct dentry *) NULL);
1878 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1879 [vfs_rename() wants 4 args])
1883 dnl # Linux 3.13 API change
1884 dnl # Added delegated inode
1886 AC_MSG_CHECKING([whether vfs_rename() wants 5 args])
1887 SPL_LINUX_TRY_COMPILE([
1888 #include <linux/fs.h>
1890 vfs_rename((struct inode *) NULL,
1891 (struct dentry *) NULL,
1892 (struct inode *) NULL,
1893 (struct dentry *) NULL,
1894 (struct inode **) NULL);
1897 AC_DEFINE(HAVE_5ARGS_VFS_RENAME, 1,
1898 [vfs_rename() wants 5 args])
1902 dnl # Linux 3.15 API change
1905 AC_MSG_CHECKING([whether vfs_rename() wants 6 args])
1906 SPL_LINUX_TRY_COMPILE([
1907 #include <linux/fs.h>
1909 vfs_rename((struct inode *) NULL,
1910 (struct dentry *) NULL,
1911 (struct inode *) NULL,
1912 (struct dentry *) NULL,
1913 (struct inode **) NULL,
1917 AC_DEFINE(HAVE_6ARGS_VFS_RENAME, 1,
1918 [vfs_rename() wants 6 args])
1927 dnl # 2.6.36 API change,
1928 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1929 dnl # a spinlock_t to improve the fastpath performance.
1931 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1932 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1933 tmp_flags="$EXTRA_KCFLAGS"
1934 EXTRA_KCFLAGS="-Werror"
1935 SPL_LINUX_TRY_COMPILE([
1936 #include <linux/sched.h>
1937 #include <linux/fs_struct.h>
1939 struct fs_struct fs;
1940 spin_lock_init(&fs.lock);
1943 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1944 [struct fs_struct uses spinlock_t])
1948 EXTRA_KCFLAGS="$tmp_flags"
1952 dnl # 2.6.29 API change,
1953 dnl # check whether 'struct cred' exists
1955 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1956 AC_MSG_CHECKING([whether struct cred exists])
1957 SPL_LINUX_TRY_COMPILE([
1958 #include <linux/cred.h>
1960 struct cred *cr __attribute__ ((unused));
1964 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1972 dnl # User namespaces, use kuid_t in place of uid_t
1973 dnl # where available. Not strictly a user namespaces thing
1974 dnl # but it should prevent surprises
1976 AC_DEFUN([SPL_AC_KUIDGID_T], [
1977 AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
1978 SPL_LINUX_TRY_COMPILE([
1979 #include <linux/uidgid.h>
1981 kuid_t userid = KUIDT_INIT(0);
1982 kgid_t groupid = KGIDT_INIT(0);
1984 SPL_LINUX_TRY_COMPILE([
1985 #include <linux/uidgid.h>
1990 AC_MSG_RESULT(yes; optional)
1992 AC_MSG_RESULT(yes; mandatory)
1993 AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
2001 dnl # Custom SPL patch may export this symbol.
2003 AC_DEFUN([SPL_AC_GROUPS_SEARCH],
2004 [AC_MSG_CHECKING([whether groups_search() is available])
2005 SPL_LINUX_TRY_COMPILE_SYMBOL([
2006 #include <linux/cred.h>
2007 #ifdef HAVE_KUIDGID_T
2008 #include <linux/uidgid.h>
2011 #ifdef HAVE_KUIDGID_T
2012 groups_search(NULL, KGIDT_INIT(0));
2014 groups_search(NULL, 0);
2016 ], [groups_search], [], [
2018 AC_DEFINE(HAVE_GROUPS_SEARCH, 1, [groups_search() is available])
2025 dnl # 2.6.x API change,
2026 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
2028 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT],
2029 [AC_MSG_CHECKING([whether __put_task_struct() is available])
2030 SPL_LINUX_TRY_COMPILE_SYMBOL([
2031 #include <linux/sched.h>
2033 __put_task_struct(NULL);
2034 ], [__put_task_struct], [], [
2036 AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
2037 [__put_task_struct() is available])
2044 dnl # 2.6.32 API change,
2045 dnl # Unused 'struct file *' removed from prototype.
2047 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
2048 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
2049 SPL_LINUX_TRY_COMPILE([
2050 #include <linux/sysctl.h>
2052 proc_dostring(NULL, 0, NULL, NULL, NULL);
2055 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
2056 [proc_handler() wants 5 args])
2063 dnl # 2.6.x API change,
2064 dnl # kvasprintf() function added.
2066 AC_DEFUN([SPL_AC_KVASPRINTF],
2067 [AC_MSG_CHECKING([whether kvasprintf() is available])
2068 SPL_LINUX_TRY_COMPILE_SYMBOL([
2069 #include <linux/kernel.h>
2071 kvasprintf(0, NULL, *((va_list*)NULL));
2072 ], [kvasprintf], [], [
2074 AC_DEFINE(HAVE_KVASPRINTF, 1, [kvasprintf() is available])
2081 dnl # 2.6.29 API change,
2082 dnl # vfs_fsync() funcation added, prior to this use file_fsync().
2084 AC_DEFUN([SPL_AC_VFS_FSYNC],
2085 [AC_MSG_CHECKING([whether vfs_fsync() is available])
2086 SPL_LINUX_TRY_COMPILE_SYMBOL([
2087 #include <linux/fs.h>
2090 ], [vfs_fsync], [fs/sync.c], [
2092 AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])
2099 dnl # 2.6.35 API change,
2100 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
2102 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
2103 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
2104 SPL_LINUX_TRY_COMPILE([
2105 #include <linux/fs.h>
2110 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
2117 dnl # 3.5 API change,
2118 dnl # inode_operations.truncate_range removed
2120 AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
2121 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
2122 SPL_LINUX_TRY_COMPILE([
2123 #include <linux/fs.h>
2125 struct inode_operations ops;
2126 ops.truncate_range = NULL;
2129 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
2130 [truncate_range() inode operation is available])
2137 dnl # Linux 2.6.38 - 3.x API
2139 AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
2140 AC_MSG_CHECKING([whether fops->fallocate() exists])
2141 SPL_LINUX_TRY_COMPILE([
2142 #include <linux/fs.h>
2144 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
2145 struct file_operations fops __attribute__ ((unused)) = {
2146 .fallocate = fallocate,
2150 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
2157 dnl # Linux 2.6.x - 2.6.37 API
2159 AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
2160 AC_MSG_CHECKING([whether iops->fallocate() exists])
2161 SPL_LINUX_TRY_COMPILE([
2162 #include <linux/fs.h>
2164 long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
2165 struct inode_operations fops __attribute__ ((unused)) = {
2166 .fallocate = fallocate,
2170 AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
2177 dnl # PaX Linux 2.6.38 - 3.x API
2179 AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
2180 AC_MSG_CHECKING([whether fops->fallocate() exists])
2181 SPL_LINUX_TRY_COMPILE([
2182 #include <linux/fs.h>
2184 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
2185 struct file_operations_no_const fops __attribute__ ((unused)) = {
2186 .fallocate = fallocate,
2190 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
2197 dnl # The fallocate callback was moved from the inode_operations
2198 dnl # structure to the file_operations structure.
2200 AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
2201 SPL_AC_KERNEL_FILE_FALLOCATE
2202 SPL_AC_KERNEL_INODE_FALLOCATE
2203 SPL_AC_PAX_KERNEL_FILE_FALLOCATE
2207 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
2208 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
2209 dnl # condition. The fixed version is exported as a symbol. The race
2210 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
2211 dnl # call that version while holding sem->wait_lock.
2213 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED],
2214 [AC_MSG_CHECKING([whether rwsem_is_locked() acquires sem->wait_lock])
2215 SPL_LINUX_TRY_COMPILE_SYMBOL([
2216 #include <linux/rwsem.h>
2217 int rwsem_is_locked(struct rw_semaphore *sem) { return 0; }
2218 ], [], [rwsem_is_locked], [lib/rwsem-spinlock.c], [
2220 AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
2221 [rwsem_is_locked() acquires sem->wait_lock])
2228 dnl # 2.6.xx API compat,
2229 dnl # There currently exists no exposed API to partially shrink the dcache.
2230 dnl # The expected mechanism to shrink the cache is a registered shrinker
2231 dnl # which is called during memory pressure.
2233 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY],
2234 [AC_MSG_CHECKING([whether shrink_dcache_memory() is available])
2235 SPL_LINUX_TRY_COMPILE_SYMBOL([
2236 #include <linux/dcache.h>
2238 shrink_dcache_memory(0, 0);
2239 ], [shrink_dcache_memory], [fs/dcache.c], [
2241 AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
2242 [shrink_dcache_memory() is available])
2249 dnl # 2.6.xx API compat,
2250 dnl # There currently exists no exposed API to partially shrink the icache.
2251 dnl # The expected mechanism to shrink the cache is a registered shrinker
2252 dnl # which is called during memory pressure.
2254 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY],
2255 [AC_MSG_CHECKING([whether shrink_icache_memory() is available])
2256 SPL_LINUX_TRY_COMPILE_SYMBOL([
2257 #include <linux/dcache.h>
2259 shrink_icache_memory(0, 0);
2260 ], [shrink_icache_memory], [fs/inode.c], [
2262 AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
2263 [shrink_icache_memory() is available])
2270 dnl # 2.6.28 API change
2271 dnl # The kern_path() function has been introduced. We adopt it as the new way
2272 dnl # of looking up paths. When it is not available, we emulate it using the
2273 dnl # older interfaces.
2275 AC_DEFUN([SPL_AC_KERN_PATH],
2276 [AC_MSG_CHECKING([whether kern_path() is available])
2277 SPL_LINUX_TRY_COMPILE_SYMBOL([
2278 #include <linux/namei.h>
2280 int r = kern_path(NULL, 0, NULL);
2281 ], [kern_path], [fs/namei.c], [
2283 AC_DEFINE(HAVE_KERN_PATH, 1,
2284 [kern_path() is available])
2287 AC_MSG_CHECKING([whether path_lookup() is available])
2288 SPL_LINUX_TRY_COMPILE_SYMBOL([
2289 #include <linux/namei.h>
2291 int r = path_lookup(NULL, 0, NULL);
2292 ], [path_lookup], [fs/namei.c], [
2294 AC_DEFINE(HAVE_KERN_PATH, 1,
2295 [kern_path() is available])
2299 *** Neither kern_path() nor path_lookup() is available.
2300 *** Please file an issue:
2301 *** https://github.com/zfsonlinux/spl/issues/new])
2308 dnl # /proc/kallsyms support,
2309 dnl # Verify the kernel has CONFIG_KALLSYMS support enabled.
2311 AC_DEFUN([SPL_AC_CONFIG_KALLSYMS], [
2312 AC_MSG_CHECKING([whether CONFIG_KALLSYMS is defined])
2313 SPL_LINUX_TRY_COMPILE([
2314 #if !defined(CONFIG_KALLSYMS)
2315 #error CONFIG_KALLSYMS not defined
2318 AC_MSG_RESULT([yes])
2322 *** This kernel does not include the required kallsyms support.
2323 *** Rebuild the kernel with CONFIG_KALLSYMS=y set.])
2328 dnl # zlib inflate compat,
2329 dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
2331 AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
2332 AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
2333 SPL_LINUX_TRY_COMPILE([
2334 #if !defined(CONFIG_ZLIB_INFLATE) && \
2335 !defined(CONFIG_ZLIB_INFLATE_MODULE)
2336 #error CONFIG_ZLIB_INFLATE not defined
2339 AC_MSG_RESULT([yes])
2343 *** This kernel does not include the required zlib inflate support.
2344 *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
2349 dnl # zlib deflate compat,
2350 dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
2352 AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
2353 AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
2354 SPL_LINUX_TRY_COMPILE([
2355 #if !defined(CONFIG_ZLIB_DEFLATE) && \
2356 !defined(CONFIG_ZLIB_DEFLATE_MODULE)
2357 #error CONFIG_ZLIB_DEFLATE not defined
2360 AC_MSG_RESULT([yes])
2364 *** This kernel does not include the required zlib deflate support.
2365 *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
2370 dnl # 2.6.39 API compat,
2371 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
2372 dnl # This was done to avoid always having to allocate the maximum size
2373 dnl # workspace (268K). The caller can now specific the windowBits and
2374 dnl # memLevel compression parameters to get a smaller workspace.
2376 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
2377 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
2378 SPL_LINUX_TRY_COMPILE([
2379 #include <linux/zlib.h>
2381 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
2384 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
2385 [zlib_deflate_workspacesize() wants 2 args])
2392 dnl # 2.6.39 API change,
2393 dnl # Shrinker adjust to use common shrink_control structure.
2395 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
2396 AC_MSG_CHECKING([whether struct shrink_control exists])
2397 SPL_LINUX_TRY_COMPILE([
2398 #include <linux/mm.h>
2400 struct shrink_control sc __attribute__ ((unused));
2403 sc.gfp_mask = GFP_KERNEL;
2406 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
2407 [struct shrink_control exists])
2414 dnl # 3.1 API Change
2416 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
2417 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
2419 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
2420 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
2421 tmp_flags="$EXTRA_KCFLAGS"
2422 EXTRA_KCFLAGS="-Werror"
2423 SPL_LINUX_TRY_COMPILE([
2424 #include <linux/rwsem.h>
2426 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
2427 raw_spinlock_t dummy_lock __attribute__ ((unused));
2428 dummy_semaphore.wait_lock = dummy_lock;
2431 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
2432 [struct rw_semaphore member wait_lock is raw_spinlock_t])
2436 EXTRA_KCFLAGS="$tmp_flags"
2440 dnl # 3.9 API change,
2441 dnl # Moved things from linux/sched.h to linux/sched/rt.h
2443 AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
2444 [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
2445 SPL_LINUX_TRY_COMPILE([
2446 #include <linux/sched.h>
2447 #include <linux/sched/rt.h>
2451 AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
2459 dnl # 3.9 API change,
2460 dnl # vfs_getattr() uses 2 args
2461 dnl # It takes struct path * instead of struct vfsmount * and struct dentry *
2463 AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
2464 AC_MSG_CHECKING([whether vfs_getattr() wants])
2465 SPL_LINUX_TRY_COMPILE([
2466 #include <linux/fs.h>
2468 vfs_getattr((struct path *) NULL,
2469 (struct kstat *)NULL);
2471 AC_MSG_RESULT(2 args)
2472 AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
2473 [vfs_getattr wants 2 args])
2475 SPL_LINUX_TRY_COMPILE([
2476 #include <linux/fs.h>
2478 vfs_getattr((struct vfsmount *)NULL,
2479 (struct dentry *)NULL,
2480 (struct kstat *)NULL);
2482 AC_MSG_RESULT(3 args)
2484 AC_MSG_ERROR(unknown)
2490 dnl # 2.6.36 API compatibility.
2491 dnl # Added usleep_range timer.
2492 dnl # usleep_range is a finer precision implementation of msleep
2493 dnl # designed to be a drop-in replacement for udelay where a precise
2494 dnl # sleep / busy-wait is unnecessary.
2496 AC_DEFUN([SPL_AC_USLEEP_RANGE], [
2497 AC_MSG_CHECKING([whether usleep_range() is available])
2498 SPL_LINUX_TRY_COMPILE([
2499 #include <linux/delay.h>
2504 AC_DEFINE(HAVE_USLEEP_RANGE, 1,
2505 [usleep_range is available])
2512 dnl # 2.6.35 API change,
2513 dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are
2514 dnl # private allocation flags which are applied when allocating a new slab
2515 dnl # in kmem_getpages(). Unfortunately there is no public API for setting
2516 dnl # non-default flags.
2518 AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [
2519 AC_MSG_CHECKING([whether struct kmem_cache has allocflags])
2520 SPL_LINUX_TRY_COMPILE([
2521 #include <linux/slab.h>
2523 struct kmem_cache cachep __attribute__ ((unused));
2524 cachep.allocflags = GFP_KERNEL;
2527 AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1,
2528 [struct kmem_cache has allocflags])
2532 AC_MSG_CHECKING([whether struct kmem_cache has gfpflags])
2533 SPL_LINUX_TRY_COMPILE([
2534 #include <linux/slab.h>
2536 struct kmem_cache cachep __attribute__ ((unused));
2537 cachep.gfpflags = GFP_KERNEL;
2540 AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1,
2541 [struct kmem_cache has gfpflags])
2549 dnl # 3.17 API change,
2550 dnl # wait_on_bit() no longer requires an action argument. The former
2551 dnl # "wait_on_bit" interface required an 'action' function to be provided
2552 dnl # which does the actual waiting. There were over 20 such functions in the
2553 dnl # kernel, many of them identical, though most cases can be satisfied by one
2554 dnl # of just two functions: one which uses io_schedule() and one which just
2555 dnl # uses schedule(). This API change was made to consolidate all of those
2556 dnl # redundant wait functions.
2558 AC_DEFUN([SPL_AC_WAIT_ON_BIT], [
2559 AC_MSG_CHECKING([whether wait_on_bit() takes an action])
2560 SPL_LINUX_TRY_COMPILE([
2561 #include <linux/wait.h>
2563 int (*action)(void *) = NULL;
2564 wait_on_bit(NULL, 0, action, 0);
2567 AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes])