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_SHRINKER_CALLBACK
30 SPL_AC_MUTEX_OWNER_TASK_STRUCT
31 SPL_AC_KALLSYMS_LOOKUP_NAME
34 SPL_AC_SET_FS_PWD_WITH_CONST
35 SPL_AC_2ARGS_VFS_UNLINK
36 SPL_AC_4ARGS_VFS_RENAME
38 SPL_AC_2ARGS_VFS_FSYNC
39 SPL_AC_INODE_TRUNCATE_RANGE
40 SPL_AC_FS_STRUCT_SPINLOCK
44 SPL_AC_PUT_TASK_STRUCT
45 SPL_AC_5ARGS_PROC_HANDLER
47 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
48 SPL_AC_KERNEL_FALLOCATE
49 SPL_AC_SHRINK_DCACHE_MEMORY
50 SPL_AC_SHRINK_ICACHE_MEMORY
52 SPL_AC_CONFIG_KALLSYMS
53 SPL_AC_CONFIG_ZLIB_INFLATE
54 SPL_AC_CONFIG_ZLIB_DEFLATE
55 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
56 SPL_AC_SHRINK_CONTROL_STRUCT
57 SPL_AC_RWSEM_SPINLOCK_IS_RAW
58 SPL_AC_SCHED_RT_HEADER
59 SPL_AC_2ARGS_VFS_GETATTR
61 SPL_AC_KMEM_CACHE_ALLOCFLAGS
65 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
66 modpost=$LINUX/scripts/Makefile.modpost
67 AC_MSG_CHECKING([kernel file name for module symbols])
68 if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
69 if grep -q Modules.symvers $modpost; then
70 LINUX_SYMBOLS=Modules.symvers
72 LINUX_SYMBOLS=Module.symvers
75 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
77 *** Please make sure the kernel devel package for your distribution
78 *** is installed. If you are building with a custom kernel, make sure the
79 *** kernel is configured, built, and the '--with-linux=PATH' configure
80 *** option refers to the location of the kernel source.])
85 AC_MSG_RESULT($LINUX_SYMBOLS)
86 AC_SUBST(LINUX_SYMBOLS)
89 AC_DEFUN([SPL_AC_KERNEL], [
91 AS_HELP_STRING([--with-linux=PATH],
92 [Path to kernel source]),
93 [kernelsrc="$withval"])
95 AC_ARG_WITH([linux-obj],
96 AS_HELP_STRING([--with-linux-obj=PATH],
97 [Path to kernel build objects]),
98 [kernelbuild="$withval"])
100 AC_MSG_CHECKING([kernel source directory])
101 if test -z "$kernelsrc"; then
102 if test -e "/lib/modules/$(uname -r)/source"; then
103 headersdir="/lib/modules/$(uname -r)/source"
104 sourcelink=$(readlink -f "$headersdir")
105 elif test -e "/lib/modules/$(uname -r)/build"; then
106 headersdir="/lib/modules/$(uname -r)/build"
107 sourcelink=$(readlink -f "$headersdir")
109 sourcelink=$(ls -1d /usr/src/kernels/* \
111 2>/dev/null | grep -v obj | tail -1)
114 if test -n "$sourcelink" && test -e ${sourcelink}; then
115 kernelsrc=`readlink -f ${sourcelink}`
117 kernelsrc="[Not found]"
120 if test "$kernelsrc" = "NONE"; then
125 AC_MSG_RESULT([$kernelsrc])
126 if test ! -d "$kernelsrc"; then
128 *** Please make sure the kernel devel package for your distribution
129 *** is installed and then try again. If that fails, you can specify the
130 *** location of the kernel source with the '--with-linux=PATH' option.])
133 AC_MSG_CHECKING([kernel build directory])
134 if test -z "$kernelbuild"; then
135 if test -e "/lib/modules/$(uname -r)/build"; then
136 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
137 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
138 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
139 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
140 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
141 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
142 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
144 kernelbuild=${kernelsrc}
147 AC_MSG_RESULT([$kernelbuild])
149 AC_MSG_CHECKING([kernel source version])
150 utsrelease1=$kernelbuild/include/linux/version.h
151 utsrelease2=$kernelbuild/include/linux/utsrelease.h
152 utsrelease3=$kernelbuild/include/generated/utsrelease.h
153 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
154 utsrelease=linux/version.h
155 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
156 utsrelease=linux/utsrelease.h
157 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
158 utsrelease=generated/utsrelease.h
161 if test "$utsrelease"; then
162 kernsrcver=`(echo "#include <$utsrelease>";
163 echo "kernsrcver=UTS_RELEASE") |
164 cpp -I $kernelbuild/include |
165 grep "^kernsrcver=" | cut -d \" -f 2`
167 if test -z "$kernsrcver"; then
168 AC_MSG_RESULT([Not found])
169 AC_MSG_ERROR([*** Cannot determine kernel version.])
172 AC_MSG_RESULT([Not found])
173 if test "x$enable_linux_builtin" != xyes; then
174 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
177 *** Cannot find UTS_RELEASE definition.
178 *** Please run 'make prepare' inside the kernel source tree.])
182 AC_MSG_RESULT([$kernsrcver])
185 LINUX_OBJ=${kernelbuild}
186 LINUX_VERSION=${kernsrcver}
190 AC_SUBST(LINUX_VERSION)
192 SPL_AC_MODULE_SYMVERS
196 dnl # Default SPL user configuration
198 AC_DEFUN([SPL_AC_CONFIG_USER], [])
201 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
202 dnl # are missing, it is non-fatal, but you will not be able to build
203 dnl # RPM packages and will be warned if you try too.
205 dnl # By default, the generic spec file will be used because it requires
206 dnl # minimal dependencies. Distribution specific spec files can be
207 dnl # placed under the 'rpm/<distribution>' directory and enabled using
208 dnl # the --with-spec=<distribution> configure option.
210 AC_DEFUN([SPL_AC_RPM], [
214 AC_MSG_CHECKING([whether $RPM is available])
215 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
216 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
218 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
221 AC_MSG_RESULT([$HAVE_RPM])
224 AC_MSG_CHECKING([whether $RPMBUILD is available])
225 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
226 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
228 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
231 AC_MSG_RESULT([$HAVE_RPMBUILD])
234 RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_LOG) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"'
236 RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
239 SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
244 RPM_SPEC_DIR="rpm/generic"
246 AS_HELP_STRING([--with-spec=SPEC],
247 [Spec files 'generic|fedora']),
248 [RPM_SPEC_DIR="rpm/$withval"])
250 AC_MSG_CHECKING([whether spec files are available])
251 AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
255 AC_SUBST(RPM_VERSION)
257 AC_SUBST(HAVE_RPMBUILD)
259 AC_SUBST(RPMBUILD_VERSION)
261 AC_SUBST(RPM_SPEC_DIR)
262 AC_SUBST(RPM_DEFINE_UTIL)
263 AC_SUBST(RPM_DEFINE_KMOD)
264 AC_SUBST(RPM_DEFINE_DKMS)
265 AC_SUBST(RPM_DEFINE_COMMON)
266 AC_SUBST(SRPM_DEFINE_UTIL)
267 AC_SUBST(SRPM_DEFINE_KMOD)
268 AC_SUBST(SRPM_DEFINE_DKMS)
269 AC_SUBST(SRPM_DEFINE_COMMON)
273 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
274 dnl # tools are missing it is non-fatal but you will not be able to build
275 dnl # DEB packages and will be warned if you try too.
277 AC_DEFUN([SPL_AC_DPKG], [
279 DPKGBUILD=dpkg-buildpackage
281 AC_MSG_CHECKING([whether $DPKG is available])
282 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
283 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
285 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
288 AC_MSG_RESULT([$HAVE_DPKG])
291 AC_MSG_CHECKING([whether $DPKGBUILD is available])
292 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
293 DPKGBUILD_VERSION=$(echo $tmp | \
294 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
296 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
299 AC_MSG_RESULT([$HAVE_DPKGBUILD])
304 AC_SUBST(DPKG_VERSION)
306 AC_SUBST(HAVE_DPKGBUILD)
308 AC_SUBST(DPKGBUILD_VERSION)
312 dnl # Until native packaging for various different packing systems
313 dnl # can be added the least we can do is attempt to use alien to
314 dnl # convert the RPM packages to the needed package type. This is
315 dnl # a hack but so far it has worked reasonable well.
317 AC_DEFUN([SPL_AC_ALIEN], [
320 AC_MSG_CHECKING([whether $ALIEN is available])
321 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
322 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
324 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
327 AC_MSG_RESULT([$HAVE_ALIEN])
332 AC_SUBST(ALIEN_VERSION)
336 dnl # Using the VENDOR tag from config.guess set the default
337 dnl # package type for 'make pkg': (rpm | deb | tgz)
339 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
340 AC_MSG_CHECKING([linux distribution])
341 if test -f /etc/toss-release ; then
343 elif test -f /etc/fedora-release ; then
345 elif test -f /etc/redhat-release ; then
347 elif test -f /etc/gentoo-release ; then
349 elif test -f /etc/arch-release ; then
351 elif test -f /etc/SuSE-release ; then
353 elif test -f /etc/slackware-version ; then
355 elif test -f /etc/lunar.release ; then
357 elif test -f /etc/lsb-release ; then
359 elif test -f /etc/debian_version ; then
364 AC_MSG_RESULT([$VENDOR])
367 AC_MSG_CHECKING([default package type])
369 toss) DEFAULT_PACKAGE=rpm ;;
370 redhat) DEFAULT_PACKAGE=rpm ;;
371 fedora) DEFAULT_PACKAGE=rpm ;;
372 gentoo) DEFAULT_PACKAGE=tgz ;;
373 arch) DEFAULT_PACKAGE=tgz ;;
374 sles) DEFAULT_PACKAGE=rpm ;;
375 slackware) DEFAULT_PACKAGE=tgz ;;
376 lunar) DEFAULT_PACKAGE=tgz ;;
377 ubuntu) DEFAULT_PACKAGE=deb ;;
378 debian) DEFAULT_PACKAGE=deb ;;
379 *) DEFAULT_PACKAGE=rpm ;;
382 AC_MSG_RESULT([$DEFAULT_PACKAGE])
383 AC_SUBST(DEFAULT_PACKAGE)
387 dnl # Default SPL user configuration
389 AC_DEFUN([SPL_AC_PACKAGE], [
390 SPL_AC_DEFAULT_PACKAGE
396 AC_DEFUN([SPL_AC_LICENSE], [
397 AC_MSG_CHECKING([spl author])
398 AC_MSG_RESULT([$SPL_META_AUTHOR])
400 AC_MSG_CHECKING([spl license])
401 AC_MSG_RESULT([$SPL_META_LICENSE])
404 AC_DEFUN([SPL_AC_CONFIG], [
406 AC_ARG_WITH([config],
407 AS_HELP_STRING([--with-config=CONFIG],
408 [Config file 'kernel|user|all|srpm']),
409 [SPL_CONFIG="$withval"])
410 AC_ARG_ENABLE([linux-builtin],
411 [AC_HELP_STRING([--enable-linux-builtin],
412 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
414 [enable_linux_builtin=no])
416 AC_MSG_CHECKING([spl config])
417 AC_MSG_RESULT([$SPL_CONFIG]);
420 case "$SPL_CONFIG" in
421 kernel) SPL_AC_CONFIG_KERNEL ;;
422 user) SPL_AC_CONFIG_USER ;;
423 all) SPL_AC_CONFIG_KERNEL
424 SPL_AC_CONFIG_USER ;;
427 AC_MSG_RESULT([Error!])
428 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
429 user kernel|user|all|srpm]) ;;
432 AM_CONDITIONAL([CONFIG_USER],
433 [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
434 AM_CONDITIONAL([CONFIG_KERNEL],
435 [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
436 [test "x$enable_linux_builtin" != xyes ])
440 dnl # Enable if the SPL should be compiled with internal debugging enabled.
441 dnl # By default this support is disabled.
443 AC_DEFUN([SPL_AC_DEBUG], [
444 AC_MSG_CHECKING([whether debugging is enabled])
445 AC_ARG_ENABLE([debug],
446 [AS_HELP_STRING([--enable-debug],
447 [Enable generic debug support @<:@default=no@:>@])],
451 AS_IF([test "x$enable_debug" = xyes],
453 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
454 DEBUG_CFLAGS="-DDEBUG -Werror"
455 DEBUG_SPL="_with_debug"
457 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
458 DEBUG_CFLAGS="-DNDEBUG"
459 DEBUG_SPL="_without_debug"
462 AC_SUBST(DEBUG_CFLAGS)
464 AC_MSG_RESULT([$enable_debug])
468 dnl # Enabled by default it provides a basic debug log infrastructure.
469 dnl # Each subsystem registers itself with a name and logs messages
470 dnl # using predefined types. If the debug mask it set to allow the
471 dnl # message type it will be written to the internal log. The log
472 dnl # can be dumped to a file by echoing 1 to the 'dump' proc entry,
473 dnl # after dumping the log it must be decoded using the spl utility.
475 dnl # echo 1 >/proc/sys/kernel/spl/debug/dump
476 dnl # spl /tmp/spl-log.xxx.yyy /tmp/spl-log.xxx.yyy.txt
478 AC_DEFUN([SPL_AC_DEBUG_LOG], [
479 AC_ARG_ENABLE([debug-log],
480 [AS_HELP_STRING([--enable-debug-log],
481 [Enable basic debug logging @<:@default=yes@:>@])],
483 [enable_debug_log=yes])
485 AS_IF([test "x$enable_debug_log" = xyes],
487 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG"
488 DEBUG_LOG="_with_debug_log"
489 AC_DEFINE([DEBUG_LOG], [1],
490 [Define to 1 to enable basic debug logging])
492 DEBUG_LOG="_without_debug_log"
496 AC_MSG_CHECKING([whether basic debug logging is enabled])
497 AC_MSG_RESULT([$enable_debug_log])
501 dnl # Enabled by default it provides a minimal level of memory tracking.
502 dnl # A total count of bytes allocated is kept for each alloc and free.
503 dnl # Then at module unload time a report to the console will be printed
504 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
505 dnl # and provide an easy way to inspect the kmem based slab.
507 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
508 AC_ARG_ENABLE([debug-kmem],
509 [AS_HELP_STRING([--enable-debug-kmem],
510 [Enable basic kmem accounting @<:@default=yes@:>@])],
512 [enable_debug_kmem=yes])
514 AS_IF([test "x$enable_debug_kmem" = xyes],
516 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
517 DEBUG_KMEM="_with_debug_kmem"
518 AC_DEFINE([DEBUG_KMEM], [1],
519 [Define to 1 to enable basic kmem accounting])
521 DEBUG_KMEM="_without_debug_kmem"
525 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
526 AC_MSG_RESULT([$enable_debug_kmem])
530 dnl # Disabled by default it provides detailed memory tracking. This
531 dnl # feature also requires --enable-debug-kmem to be set. When enabled
532 dnl # not only will total bytes be tracked but also the location of every
533 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
534 dnl # addresses and where they were allocated will be dumped to the console.
535 dnl # Enabling this feature has a significant impact on performance but it
536 dnl # makes finding memory leaks pretty straight forward.
538 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
539 AC_ARG_ENABLE([debug-kmem-tracking],
540 [AS_HELP_STRING([--enable-debug-kmem-tracking],
541 [Enable detailed kmem tracking @<:@default=no@:>@])],
543 [enable_debug_kmem_tracking=no])
545 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
547 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
548 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
549 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
550 [Define to 1 to enable detailed kmem tracking])
552 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
555 AC_SUBST(DEBUG_KMEM_TRACKING)
556 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
557 AC_MSG_RESULT([$enable_debug_kmem_tracking])
561 dnl # SPL_LINUX_CONFTEST
563 AC_DEFUN([SPL_LINUX_CONFTEST], [
564 cat confdefs.h - <<_ACEOF >conftest.c
570 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
572 m4_define([SPL_LANG_PROGRAM], [
577 dnl Do *not* indent the following line: there may be CPP directives.
578 dnl Don't move the `;' right after for the same reason.
586 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
588 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
589 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
590 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
591 echo "obj-m := conftest.o" >build/Makefile
593 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
595 [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])],
597 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
603 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
605 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
606 [SPL_LINUX_COMPILE_IFELSE(
607 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
609 [test -s build/conftest.o],
614 dnl # SPL_CHECK_SYMBOL_EXPORT
615 dnl # check symbol exported or not
617 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
618 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
619 $LINUX_OBJ/Module*.symvers 2>/dev/null
621 if test $rc -ne 0; then
624 grep -q -E "EXPORT_SYMBOL.*($1)" \
625 "$LINUX_OBJ/$file" 2>/dev/null
627 if test $rc -eq 0; then
632 if test $export -eq 0; then :
643 dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
644 dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
645 dnl # is called if not compiling for builtin
647 AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
648 SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
649 if test $rc -ne 0; then :
652 if test "x$enable_linux_builtin" != xyes; then
653 SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
655 if test $rc -ne 0; then :
664 dnl # SPL_CHECK_SYMBOL_HEADER
665 dnl # check if a symbol prototype is defined in listed headers.
667 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
668 AC_MSG_CHECKING([whether symbol $1 exists in header])
671 grep -q "$2" "$LINUX/$file" 2>/dev/null
673 if test $rc -eq 0; then
678 if test $header -eq 0; then
688 dnl # SPL_CHECK_HEADER
689 dnl # check whether header exists and define HAVE_$2_HEADER
691 AC_DEFUN([SPL_CHECK_HEADER],
692 [AC_MSG_CHECKING([whether header $1 exists])
693 SPL_LINUX_TRY_COMPILE([
698 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
708 dnl # Basic toolchain sanity check. Verify that kernel modules can
709 dnl # be built and which symbols can be used.
711 AC_DEFUN([SPL_AC_TEST_MODULE],
712 [AC_MSG_CHECKING([whether modules can be built])
713 SPL_LINUX_TRY_COMPILE([],[],[
717 if test "x$enable_linux_builtin" != xyes; then
718 AC_MSG_ERROR([*** Unable to build an empty module.])
721 *** Unable to build an empty module.
722 *** Please run 'make scripts' inside the kernel source tree.])
728 #include "$LINUX/include/linux/license.h"
730 return !license_is_gpl_compatible("$SPL_META_LICENSE");
733 AC_DEFINE([SPL_IS_GPL_COMPATIBLE], [1],
734 [Define to 1 if GPL-only symbols can be used])
740 dnl # Use the atomic implemenation based on global spinlocks. This
741 dnl # should only be needed by 32-bit kernels which do not provide
742 dnl # the atomic64_* API. It may be optionally enabled as a fallback
743 dnl # if problems are observed with the direct mapping to the native
744 dnl # Linux atomic operations. You may not disable atomic spinlocks
745 dnl # if you kernel does not an atomic64_* API.
747 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
748 AC_ARG_ENABLE([atomic-spinlocks],
749 [AS_HELP_STRING([--enable-atomic-spinlocks],
750 [Atomic types use spinlocks @<:@default=check@:>@])],
752 [enable_atomic_spinlocks=check])
754 SPL_LINUX_TRY_COMPILE([
755 #include <linux/fs.h>
757 atomic64_t *ptr __attribute__ ((unused));
760 AC_DEFINE(HAVE_ATOMIC64_T, 1,
761 [kernel defines atomic64_t])
766 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
767 AS_IF([test "x$have_atomic64_t" = xyes], [
768 enable_atomic_spinlocks=no
770 enable_atomic_spinlocks=yes
774 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
775 AC_DEFINE([ATOMIC_SPINLOCK], [1],
776 [Atomic types use spinlocks])
778 AS_IF([test "x$have_atomic64_t" = xno], [
780 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
784 AC_MSG_CHECKING([whether atomic types use spinlocks])
785 AC_MSG_RESULT([$enable_atomic_spinlocks])
787 AC_MSG_CHECKING([whether kernel defines atomic64_t])
788 AC_MSG_RESULT([$have_atomic64_t])
791 AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[
792 tmp_flags="$EXTRA_KCFLAGS"
793 EXTRA_KCFLAGS="-Werror"
795 dnl # 2.6.23 to 2.6.34 API change
796 dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask)
798 AC_MSG_CHECKING([whether old 2-argument shrinker exists])
799 SPL_LINUX_TRY_COMPILE([
800 #include <linux/mm.h>
802 int shrinker_cb(int nr_to_scan, gfp_t gfp_mask);
804 struct shrinker cache_shrinker = {
805 .shrink = shrinker_cb,
806 .seeks = DEFAULT_SEEKS,
808 register_shrinker(&cache_shrinker);
811 AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1,
812 [old shrinker callback wants 2 args])
816 dnl # 2.6.35 - 2.6.39 API change
817 dnl # ->shrink(struct shrinker *,
818 dnl # int nr_to_scan, gfp_t gfp_mask)
820 AC_MSG_CHECKING([whether old 3-argument shrinker exists])
821 SPL_LINUX_TRY_COMPILE([
822 #include <linux/mm.h>
824 int shrinker_cb(struct shrinker *, int nr_to_scan,
827 struct shrinker cache_shrinker = {
828 .shrink = shrinker_cb,
829 .seeks = DEFAULT_SEEKS,
831 register_shrinker(&cache_shrinker);
834 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
835 [old shrinker callback wants 3 args])
839 dnl # 3.0 - 3.11 API change
840 dnl # ->shrink(struct shrinker *,
841 dnl # struct shrink_control *sc)
844 [whether new 2-argument shrinker exists])
845 SPL_LINUX_TRY_COMPILE([
846 #include <linux/mm.h>
848 int shrinker_cb(struct shrinker *,
849 struct shrink_control *sc);
851 struct shrinker cache_shrinker = {
852 .shrink = shrinker_cb,
853 .seeks = DEFAULT_SEEKS,
855 register_shrinker(&cache_shrinker);
858 AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1,
859 [new shrinker callback wants 2 args])
863 dnl # 3.12 API change,
864 dnl # ->shrink() is logically split in to
865 dnl # ->count_objects() and ->scan_objects()
868 [whether ->count_objects callback exists])
869 SPL_LINUX_TRY_COMPILE([
870 #include <linux/mm.h>
872 unsigned long shrinker_cb(
874 struct shrink_control *sc);
876 struct shrinker cache_shrinker = {
877 .count_objects = shrinker_cb,
878 .scan_objects = shrinker_cb,
879 .seeks = DEFAULT_SEEKS,
881 register_shrinker(&cache_shrinker);
884 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
885 1, [->count_objects exists])
892 EXTRA_KCFLAGS="$tmp_flags"
896 dnl # 2.6.33 API change,
897 dnl # Removed .ctl_name from struct ctl_table.
899 AC_DEFUN([SPL_AC_CTL_NAME], [
900 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
901 SPL_LINUX_TRY_COMPILE([
902 #include <linux/sysctl.h>
904 struct ctl_table ctl __attribute__ ((unused));
908 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
915 dnl # 2.6.29 API change,
916 dnl # Adaptive mutexs were introduced which track the mutex owner. The
917 dnl # mutex wrappers leverage this functionality to avoid tracking the
918 dnl # owner multipe times.
920 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
921 AC_MSG_CHECKING([whether struct mutex has owner])
922 SPL_LINUX_TRY_COMPILE([
923 #include <linux/mutex.h>
925 struct mutex mtx __attribute__ ((unused));
929 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
936 dnl # 2.6.39 API change,
937 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
938 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
939 dnl # was defined. As of 2.6.39 this was changed to a task_struct
940 dnl # pointer which frankly makes a lot more sense.
942 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
943 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
944 tmp_flags="$EXTRA_KCFLAGS"
945 EXTRA_KCFLAGS="-Werror"
946 SPL_LINUX_TRY_COMPILE([
947 #include <linux/mutex.h>
948 #include <linux/sched.h>
950 struct mutex mtx __attribute__ ((unused));
954 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
955 [struct mutex owner is a task_struct])
959 EXTRA_KCFLAGS="$tmp_flags"
963 dnl # 2.6.18 API change,
964 dnl # kallsyms_lookup_name no longer exported
966 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME],
967 [AC_MSG_CHECKING([whether kallsyms_lookup_name() is available])
968 SPL_LINUX_TRY_COMPILE_SYMBOL([
969 #include <linux/kallsyms.h>
971 kallsyms_lookup_name(NULL);
972 ], [kallsyms_lookup_name], [], [
974 AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
975 [kallsyms_lookup_name() is available])
982 dnl # 3.10 API change,
983 dnl # PDE is replaced by PDE_DATA
985 AC_DEFUN([SPL_AC_PDE_DATA], [
986 AC_MSG_CHECKING([whether PDE_DATA() is available])
987 SPL_LINUX_TRY_COMPILE_SYMBOL([
988 #include <linux/proc_fs.h>
993 AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
1000 dnl # 2.6.27 API change,
1001 dnl # The user_path_dir() replaces __user_walk()
1003 AC_DEFUN([SPL_AC_USER_PATH_DIR],
1004 [AC_MSG_CHECKING([whether user_path_dir() is available])
1005 SPL_LINUX_TRY_COMPILE_SYMBOL([
1006 #include <linux/fcntl.h>
1007 #include <linux/namei.h>
1009 user_path_dir(NULL, NULL);
1010 ], [user_path_at], [], [
1012 AC_DEFINE(HAVE_USER_PATH_DIR, 1, [user_path_dir() is available])
1019 dnl # Symbol available in RHEL kernels not in stock kernels.
1021 AC_DEFUN([SPL_AC_SET_FS_PWD],
1022 [AC_MSG_CHECKING([whether set_fs_pwd() is available])
1023 SPL_LINUX_TRY_COMPILE_SYMBOL([
1024 #include <linux/spinlock.h>
1025 #include <linux/fs_struct.h>
1028 ], [set_fs_pwd], [], [
1030 AC_DEFINE(HAVE_SET_FS_PWD, 1, [set_fs_pwd() is available])
1037 dnl # 3.9 API change
1038 dnl # set_fs_pwd takes const struct path *
1040 AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
1041 tmp_flags="$EXTRA_KCFLAGS"
1042 EXTRA_KCFLAGS="-Werror"
1043 [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
1044 SPL_LINUX_TRY_COMPILE([
1045 #include <linux/spinlock.h>
1046 #include <linux/fs_struct.h>
1047 #include <linux/path.h>
1048 void (*const set_fs_pwd_func)
1049 (struct fs_struct *, const struct path *)
1055 AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
1056 [set_fs_pwd() needs const path *])
1058 SPL_LINUX_TRY_COMPILE([
1059 #include <linux/spinlock.h>
1060 #include <linux/fs_struct.h>
1061 #include <linux/path.h>
1062 void (*const set_fs_pwd_func)
1063 (struct fs_struct *, struct path *)
1070 AC_MSG_ERROR(unknown)
1073 EXTRA_KCFLAGS="$tmp_flags"
1076 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1077 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1078 SPL_LINUX_TRY_COMPILE([
1079 #include <linux/fs.h>
1081 vfs_unlink((struct inode *) NULL, (struct dentry *) NULL);
1084 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1085 [vfs_unlink() wants 2 args])
1089 dnl # Linux 3.13 API change
1090 dnl # Added delegated inode
1092 AC_MSG_CHECKING([whether vfs_unlink() wants 3 args])
1093 SPL_LINUX_TRY_COMPILE([
1094 #include <linux/fs.h>
1096 vfs_unlink((struct inode *) NULL,
1097 (struct dentry *) NULL,
1098 (struct inode **) NULL);
1101 AC_DEFINE(HAVE_3ARGS_VFS_UNLINK, 1,
1102 [vfs_unlink() wants 3 args])
1110 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1111 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1112 SPL_LINUX_TRY_COMPILE([
1113 #include <linux/fs.h>
1115 vfs_rename((struct inode *) NULL, (struct dentry *) NULL,
1116 (struct inode *) NULL, (struct dentry *) NULL);
1119 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1120 [vfs_rename() wants 4 args])
1124 dnl # Linux 3.13 API change
1125 dnl # Added delegated inode
1127 AC_MSG_CHECKING([whether vfs_rename() wants 5 args])
1128 SPL_LINUX_TRY_COMPILE([
1129 #include <linux/fs.h>
1131 vfs_rename((struct inode *) NULL,
1132 (struct dentry *) NULL,
1133 (struct inode *) NULL,
1134 (struct dentry *) NULL,
1135 (struct inode **) NULL);
1138 AC_DEFINE(HAVE_5ARGS_VFS_RENAME, 1,
1139 [vfs_rename() wants 5 args])
1143 dnl # Linux 3.15 API change
1146 AC_MSG_CHECKING([whether vfs_rename() wants 6 args])
1147 SPL_LINUX_TRY_COMPILE([
1148 #include <linux/fs.h>
1150 vfs_rename((struct inode *) NULL,
1151 (struct dentry *) NULL,
1152 (struct inode *) NULL,
1153 (struct dentry *) NULL,
1154 (struct inode **) NULL,
1158 AC_DEFINE(HAVE_6ARGS_VFS_RENAME, 1,
1159 [vfs_rename() wants 6 args])
1168 dnl # 2.6.36 API change,
1169 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1170 dnl # a spinlock_t to improve the fastpath performance.
1172 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1173 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1174 tmp_flags="$EXTRA_KCFLAGS"
1175 EXTRA_KCFLAGS="-Werror"
1176 SPL_LINUX_TRY_COMPILE([
1177 #include <linux/sched.h>
1178 #include <linux/fs_struct.h>
1180 struct fs_struct fs;
1181 spin_lock_init(&fs.lock);
1184 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1185 [struct fs_struct uses spinlock_t])
1189 EXTRA_KCFLAGS="$tmp_flags"
1193 dnl # 2.6.29 API change,
1194 dnl # check whether 'struct cred' exists
1196 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1197 AC_MSG_CHECKING([whether struct cred exists])
1198 SPL_LINUX_TRY_COMPILE([
1199 #include <linux/cred.h>
1201 struct cred *cr __attribute__ ((unused));
1205 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1213 dnl # User namespaces, use kuid_t in place of uid_t
1214 dnl # where available. Not strictly a user namespaces thing
1215 dnl # but it should prevent surprises
1217 AC_DEFUN([SPL_AC_KUIDGID_T], [
1218 AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
1219 SPL_LINUX_TRY_COMPILE([
1220 #include <linux/uidgid.h>
1222 kuid_t userid = KUIDT_INIT(0);
1223 kgid_t groupid = KGIDT_INIT(0);
1225 SPL_LINUX_TRY_COMPILE([
1226 #include <linux/uidgid.h>
1231 AC_MSG_RESULT(yes; optional)
1233 AC_MSG_RESULT(yes; mandatory)
1234 AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
1242 dnl # Custom SPL patch may export this symbol.
1244 AC_DEFUN([SPL_AC_GROUPS_SEARCH],
1245 [AC_MSG_CHECKING([whether groups_search() is available])
1246 SPL_LINUX_TRY_COMPILE_SYMBOL([
1247 #include <linux/cred.h>
1248 #ifdef HAVE_KUIDGID_T
1249 #include <linux/uidgid.h>
1252 #ifdef HAVE_KUIDGID_T
1253 groups_search(NULL, KGIDT_INIT(0));
1255 groups_search(NULL, 0);
1257 ], [groups_search], [], [
1259 AC_DEFINE(HAVE_GROUPS_SEARCH, 1, [groups_search() is available])
1266 dnl # 2.6.x API change,
1267 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1269 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT],
1270 [AC_MSG_CHECKING([whether __put_task_struct() is available])
1271 SPL_LINUX_TRY_COMPILE_SYMBOL([
1272 #include <linux/sched.h>
1274 __put_task_struct(NULL);
1275 ], [__put_task_struct], [], [
1277 AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1278 [__put_task_struct() is available])
1285 dnl # 2.6.32 API change,
1286 dnl # Unused 'struct file *' removed from prototype.
1288 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1289 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1290 SPL_LINUX_TRY_COMPILE([
1291 #include <linux/sysctl.h>
1293 proc_dostring(NULL, 0, NULL, NULL, NULL);
1296 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1297 [proc_handler() wants 5 args])
1304 dnl # 2.6.x API change,
1305 dnl # kvasprintf() function added.
1307 AC_DEFUN([SPL_AC_KVASPRINTF],
1308 [AC_MSG_CHECKING([whether kvasprintf() is available])
1309 SPL_LINUX_TRY_COMPILE_SYMBOL([
1310 #include <linux/kernel.h>
1312 kvasprintf(0, NULL, *((va_list*)NULL));
1313 ], [kvasprintf], [], [
1315 AC_DEFINE(HAVE_KVASPRINTF, 1, [kvasprintf() is available])
1322 dnl # 2.6.29 API change,
1323 dnl # vfs_fsync() funcation added, prior to this use file_fsync().
1325 AC_DEFUN([SPL_AC_VFS_FSYNC],
1326 [AC_MSG_CHECKING([whether vfs_fsync() is available])
1327 SPL_LINUX_TRY_COMPILE_SYMBOL([
1328 #include <linux/fs.h>
1331 ], [vfs_fsync], [fs/sync.c], [
1333 AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])
1340 dnl # 2.6.35 API change,
1341 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
1343 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
1344 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
1345 SPL_LINUX_TRY_COMPILE([
1346 #include <linux/fs.h>
1351 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
1358 dnl # 3.5 API change,
1359 dnl # inode_operations.truncate_range removed
1361 AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
1362 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
1363 SPL_LINUX_TRY_COMPILE([
1364 #include <linux/fs.h>
1366 struct inode_operations ops;
1367 ops.truncate_range = NULL;
1370 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
1371 [truncate_range() inode operation is available])
1378 dnl # Linux 2.6.38 - 3.x API
1380 AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
1381 AC_MSG_CHECKING([whether fops->fallocate() exists])
1382 SPL_LINUX_TRY_COMPILE([
1383 #include <linux/fs.h>
1385 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1386 struct file_operations fops __attribute__ ((unused)) = {
1387 .fallocate = fallocate,
1391 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1398 dnl # Linux 2.6.x - 2.6.37 API
1400 AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
1401 AC_MSG_CHECKING([whether iops->fallocate() exists])
1402 SPL_LINUX_TRY_COMPILE([
1403 #include <linux/fs.h>
1405 long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
1406 struct inode_operations fops __attribute__ ((unused)) = {
1407 .fallocate = fallocate,
1411 AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
1418 dnl # PaX Linux 2.6.38 - 3.x API
1420 AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
1421 AC_MSG_CHECKING([whether fops->fallocate() exists])
1422 SPL_LINUX_TRY_COMPILE([
1423 #include <linux/fs.h>
1425 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1426 struct file_operations_no_const fops __attribute__ ((unused)) = {
1427 .fallocate = fallocate,
1431 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1438 dnl # The fallocate callback was moved from the inode_operations
1439 dnl # structure to the file_operations structure.
1441 AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
1442 SPL_AC_KERNEL_FILE_FALLOCATE
1443 SPL_AC_KERNEL_INODE_FALLOCATE
1444 SPL_AC_PAX_KERNEL_FILE_FALLOCATE
1448 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
1449 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
1450 dnl # condition. The fixed version is exported as a symbol. The race
1451 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
1452 dnl # call that version while holding sem->wait_lock.
1454 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED],
1455 [AC_MSG_CHECKING([whether rwsem_is_locked() acquires sem->wait_lock])
1456 SPL_LINUX_TRY_COMPILE_SYMBOL([
1457 #include <linux/rwsem.h>
1458 int rwsem_is_locked(struct rw_semaphore *sem) { return 0; }
1459 ], [], [rwsem_is_locked], [lib/rwsem-spinlock.c], [
1461 AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
1462 [rwsem_is_locked() acquires sem->wait_lock])
1469 dnl # 2.6.xx API compat,
1470 dnl # There currently exists no exposed API to partially shrink the dcache.
1471 dnl # The expected mechanism to shrink the cache is a registered shrinker
1472 dnl # which is called during memory pressure.
1474 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY],
1475 [AC_MSG_CHECKING([whether shrink_dcache_memory() is available])
1476 SPL_LINUX_TRY_COMPILE_SYMBOL([
1477 #include <linux/dcache.h>
1479 shrink_dcache_memory(0, 0);
1480 ], [shrink_dcache_memory], [fs/dcache.c], [
1482 AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
1483 [shrink_dcache_memory() is available])
1490 dnl # 2.6.xx API compat,
1491 dnl # There currently exists no exposed API to partially shrink the icache.
1492 dnl # The expected mechanism to shrink the cache is a registered shrinker
1493 dnl # which is called during memory pressure.
1495 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY],
1496 [AC_MSG_CHECKING([whether shrink_icache_memory() is available])
1497 SPL_LINUX_TRY_COMPILE_SYMBOL([
1498 #include <linux/dcache.h>
1500 shrink_icache_memory(0, 0);
1501 ], [shrink_icache_memory], [fs/inode.c], [
1503 AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
1504 [shrink_icache_memory() is available])
1511 dnl # 2.6.28 API change
1512 dnl # The kern_path() function has been introduced. We adopt it as the new way
1513 dnl # of looking up paths. When it is not available, we emulate it using the
1514 dnl # older interfaces.
1516 AC_DEFUN([SPL_AC_KERN_PATH],
1517 [AC_MSG_CHECKING([whether kern_path() is available])
1518 SPL_LINUX_TRY_COMPILE_SYMBOL([
1519 #include <linux/namei.h>
1521 int r = kern_path(NULL, 0, NULL);
1522 ], [kern_path], [fs/namei.c], [
1524 AC_DEFINE(HAVE_KERN_PATH, 1,
1525 [kern_path() is available])
1528 AC_MSG_CHECKING([whether path_lookup() is available])
1529 SPL_LINUX_TRY_COMPILE_SYMBOL([
1530 #include <linux/namei.h>
1532 int r = path_lookup(NULL, 0, NULL);
1533 ], [path_lookup], [fs/namei.c], [
1535 AC_DEFINE(HAVE_KERN_PATH, 1,
1536 [kern_path() is available])
1540 *** Neither kern_path() nor path_lookup() is available.
1541 *** Please file an issue:
1542 *** https://github.com/zfsonlinux/spl/issues/new])
1549 dnl # /proc/kallsyms support,
1550 dnl # Verify the kernel has CONFIG_KALLSYMS support enabled.
1552 AC_DEFUN([SPL_AC_CONFIG_KALLSYMS], [
1553 AC_MSG_CHECKING([whether CONFIG_KALLSYMS is defined])
1554 SPL_LINUX_TRY_COMPILE([
1555 #if !defined(CONFIG_KALLSYMS)
1556 #error CONFIG_KALLSYMS not defined
1559 AC_MSG_RESULT([yes])
1563 *** This kernel does not include the required kallsyms support.
1564 *** Rebuild the kernel with CONFIG_KALLSYMS=y set.])
1569 dnl # zlib inflate compat,
1570 dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
1572 AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
1573 AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
1574 SPL_LINUX_TRY_COMPILE([
1575 #if !defined(CONFIG_ZLIB_INFLATE) && \
1576 !defined(CONFIG_ZLIB_INFLATE_MODULE)
1577 #error CONFIG_ZLIB_INFLATE not defined
1580 AC_MSG_RESULT([yes])
1584 *** This kernel does not include the required zlib inflate support.
1585 *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
1590 dnl # zlib deflate compat,
1591 dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
1593 AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
1594 AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
1595 SPL_LINUX_TRY_COMPILE([
1596 #if !defined(CONFIG_ZLIB_DEFLATE) && \
1597 !defined(CONFIG_ZLIB_DEFLATE_MODULE)
1598 #error CONFIG_ZLIB_DEFLATE not defined
1601 AC_MSG_RESULT([yes])
1605 *** This kernel does not include the required zlib deflate support.
1606 *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
1611 dnl # 2.6.39 API compat,
1612 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
1613 dnl # This was done to avoid always having to allocate the maximum size
1614 dnl # workspace (268K). The caller can now specific the windowBits and
1615 dnl # memLevel compression parameters to get a smaller workspace.
1617 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
1618 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
1619 SPL_LINUX_TRY_COMPILE([
1620 #include <linux/zlib.h>
1622 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
1625 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
1626 [zlib_deflate_workspacesize() wants 2 args])
1633 dnl # 2.6.39 API change,
1634 dnl # Shrinker adjust to use common shrink_control structure.
1636 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
1637 AC_MSG_CHECKING([whether struct shrink_control exists])
1638 SPL_LINUX_TRY_COMPILE([
1639 #include <linux/mm.h>
1641 struct shrink_control sc __attribute__ ((unused));
1644 sc.gfp_mask = GFP_KERNEL;
1647 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
1648 [struct shrink_control exists])
1655 dnl # 3.1 API Change
1657 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
1658 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
1660 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
1661 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
1662 tmp_flags="$EXTRA_KCFLAGS"
1663 EXTRA_KCFLAGS="-Werror"
1664 SPL_LINUX_TRY_COMPILE([
1665 #include <linux/rwsem.h>
1667 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
1668 raw_spinlock_t dummy_lock __attribute__ ((unused));
1669 dummy_semaphore.wait_lock = dummy_lock;
1672 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
1673 [struct rw_semaphore member wait_lock is raw_spinlock_t])
1677 EXTRA_KCFLAGS="$tmp_flags"
1681 dnl # 3.9 API change,
1682 dnl # Moved things from linux/sched.h to linux/sched/rt.h
1684 AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
1685 [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
1686 SPL_LINUX_TRY_COMPILE([
1687 #include <linux/sched.h>
1688 #include <linux/sched/rt.h>
1692 AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
1700 dnl # 3.9 API change,
1701 dnl # vfs_getattr() uses 2 args
1702 dnl # It takes struct path * instead of struct vfsmount * and struct dentry *
1704 AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
1705 AC_MSG_CHECKING([whether vfs_getattr() wants])
1706 SPL_LINUX_TRY_COMPILE([
1707 #include <linux/fs.h>
1709 vfs_getattr((struct path *) NULL,
1710 (struct kstat *)NULL);
1712 AC_MSG_RESULT(2 args)
1713 AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
1714 [vfs_getattr wants 2 args])
1716 SPL_LINUX_TRY_COMPILE([
1717 #include <linux/fs.h>
1719 vfs_getattr((struct vfsmount *)NULL,
1720 (struct dentry *)NULL,
1721 (struct kstat *)NULL);
1723 AC_MSG_RESULT(3 args)
1725 AC_MSG_ERROR(unknown)
1731 dnl # 2.6.36 API compatibility.
1732 dnl # Added usleep_range timer.
1733 dnl # usleep_range is a finer precision implementation of msleep
1734 dnl # designed to be a drop-in replacement for udelay where a precise
1735 dnl # sleep / busy-wait is unnecessary.
1737 AC_DEFUN([SPL_AC_USLEEP_RANGE], [
1738 AC_MSG_CHECKING([whether usleep_range() is available])
1739 SPL_LINUX_TRY_COMPILE([
1740 #include <linux/delay.h>
1745 AC_DEFINE(HAVE_USLEEP_RANGE, 1,
1746 [usleep_range is available])
1753 dnl # 2.6.35 API change,
1754 dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are
1755 dnl # private allocation flags which are applied when allocating a new slab
1756 dnl # in kmem_getpages(). Unfortunately there is no public API for setting
1757 dnl # non-default flags.
1759 AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [
1760 AC_MSG_CHECKING([whether struct kmem_cache has allocflags])
1761 SPL_LINUX_TRY_COMPILE([
1762 #include <linux/slab.h>
1764 struct kmem_cache cachep __attribute__ ((unused));
1765 cachep.allocflags = GFP_KERNEL;
1768 AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1,
1769 [struct kmem_cache has allocflags])
1773 AC_MSG_CHECKING([whether struct kmem_cache has gfpflags])
1774 SPL_LINUX_TRY_COMPILE([
1775 #include <linux/slab.h>
1777 struct kmem_cache cachep __attribute__ ((unused));
1778 cachep.gfpflags = GFP_KERNEL;
1781 AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1,
1782 [struct kmem_cache has gfpflags])
1790 dnl # 3.17 API change,
1791 dnl # wait_on_bit() no longer requires an action argument. The former
1792 dnl # "wait_on_bit" interface required an 'action' function to be provided
1793 dnl # which does the actual waiting. There were over 20 such functions in the
1794 dnl # kernel, many of them identical, though most cases can be satisfied by one
1795 dnl # of just two functions: one which uses io_schedule() and one which just
1796 dnl # uses schedule(). This API change was made to consolidate all of those
1797 dnl # redundant wait functions.
1799 AC_DEFUN([SPL_AC_WAIT_ON_BIT], [
1800 AC_MSG_CHECKING([whether wait_on_bit() takes an action])
1801 SPL_LINUX_TRY_COMPILE([
1802 #include <linux/wait.h>
1804 int (*action)(void *) = NULL;
1805 wait_on_bit(NULL, 0, action, 0);
1808 AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes])