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)
22 SPL_AC_DEBUG_KMEM_TRACKING
24 SPL_AC_ATOMIC_SPINLOCK
25 SPL_AC_SHRINKER_CALLBACK
27 SPL_AC_CONFIG_TRIM_UNUSED_KSYMS
29 SPL_AC_SET_FS_PWD_WITH_CONST
30 SPL_AC_2ARGS_VFS_UNLINK
31 SPL_AC_4ARGS_VFS_RENAME
32 SPL_AC_2ARGS_VFS_FSYNC
33 SPL_AC_INODE_TRUNCATE_RANGE
34 SPL_AC_FS_STRUCT_SPINLOCK
36 SPL_AC_KERNEL_FALLOCATE
37 SPL_AC_CONFIG_ZLIB_INFLATE
38 SPL_AC_CONFIG_ZLIB_DEFLATE
39 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
40 SPL_AC_SHRINK_CONTROL_STRUCT
41 SPL_AC_RWSEM_SPINLOCK_IS_RAW
43 SPL_AC_RWSEM_ATOMIC_LONG_COUNT
44 SPL_AC_SCHED_RT_HEADER
45 SPL_AC_SCHED_SIGNAL_HEADER
46 SPL_AC_4ARGS_VFS_GETATTR
47 SPL_AC_3ARGS_VFS_GETATTR
48 SPL_AC_2ARGS_VFS_GETATTR
50 SPL_AC_KMEM_CACHE_ALLOCFLAGS
55 SPL_AC_WAIT_QUEUE_ENTRY_T
56 SPL_AC_WAIT_QUEUE_HEAD_ENTRY
59 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
60 modpost=$LINUX/scripts/Makefile.modpost
61 AC_MSG_CHECKING([kernel file name for module symbols])
62 if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
63 if grep -q Modules.symvers $modpost; then
64 LINUX_SYMBOLS=Modules.symvers
66 LINUX_SYMBOLS=Module.symvers
69 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
71 *** Please make sure the kernel devel package for your distribution
72 *** is installed. If you are building with a custom kernel, make sure the
73 *** kernel is configured, built, and the '--with-linux=PATH' configure
74 *** option refers to the location of the kernel source.])
79 AC_MSG_RESULT($LINUX_SYMBOLS)
80 AC_SUBST(LINUX_SYMBOLS)
83 AC_DEFUN([SPL_AC_KERNEL], [
85 AS_HELP_STRING([--with-linux=PATH],
86 [Path to kernel source]),
87 [kernelsrc="$withval"])
89 AC_ARG_WITH([linux-obj],
90 AS_HELP_STRING([--with-linux-obj=PATH],
91 [Path to kernel build objects]),
92 [kernelbuild="$withval"])
94 AC_MSG_CHECKING([kernel source directory])
95 if test -z "$kernelsrc"; then
96 if test -e "/lib/modules/$(uname -r)/source"; then
97 headersdir="/lib/modules/$(uname -r)/source"
98 sourcelink=$(readlink -f "$headersdir")
99 elif test -e "/lib/modules/$(uname -r)/build"; then
100 headersdir="/lib/modules/$(uname -r)/build"
101 sourcelink=$(readlink -f "$headersdir")
103 sourcelink=$(ls -1d /usr/src/kernels/* \
105 2>/dev/null | grep -v obj | tail -1)
108 if test -n "$sourcelink" && test -e ${sourcelink}; then
109 kernelsrc=`readlink -f ${sourcelink}`
111 kernelsrc="[Not found]"
114 if test "$kernelsrc" = "NONE"; then
119 AC_MSG_RESULT([$kernelsrc])
120 if test ! -d "$kernelsrc"; then
122 *** Please make sure the kernel devel package for your distribution
123 *** is installed and then try again. If that fails, you can specify the
124 *** location of the kernel source with the '--with-linux=PATH' option.])
127 AC_MSG_CHECKING([kernel build directory])
128 if test -z "$kernelbuild"; then
129 if test -e "/lib/modules/$(uname -r)/build"; then
130 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
131 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
132 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
133 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
134 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
135 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
136 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
138 kernelbuild=${kernelsrc}
141 AC_MSG_RESULT([$kernelbuild])
143 AC_MSG_CHECKING([kernel source version])
144 utsrelease1=$kernelbuild/include/linux/version.h
145 utsrelease2=$kernelbuild/include/linux/utsrelease.h
146 utsrelease3=$kernelbuild/include/generated/utsrelease.h
147 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
148 utsrelease=linux/version.h
149 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
150 utsrelease=linux/utsrelease.h
151 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
152 utsrelease=generated/utsrelease.h
155 if test "$utsrelease"; then
156 kernsrcver=`(echo "#include <$utsrelease>";
157 echo "kernsrcver=UTS_RELEASE") |
158 cpp -I $kernelbuild/include |
159 grep "^kernsrcver=" | cut -d \" -f 2`
161 if test -z "$kernsrcver"; then
162 AC_MSG_RESULT([Not found])
163 AC_MSG_ERROR([*** Cannot determine kernel version.])
166 AC_MSG_RESULT([Not found])
167 if test "x$enable_linux_builtin" != xyes; then
168 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
171 *** Cannot find UTS_RELEASE definition.
172 *** Please run 'make prepare' inside the kernel source tree.])
176 AC_MSG_RESULT([$kernsrcver])
179 LINUX_OBJ=${kernelbuild}
180 LINUX_VERSION=${kernsrcver}
184 AC_SUBST(LINUX_VERSION)
186 SPL_AC_MODULE_SYMVERS
190 dnl # Default SPL user configuration
192 AC_DEFUN([SPL_AC_CONFIG_USER], [])
195 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
196 dnl # are missing, it is non-fatal, but you will not be able to build
197 dnl # RPM packages and will be warned if you try too.
199 dnl # By default, the generic spec file will be used because it requires
200 dnl # minimal dependencies. Distribution specific spec files can be
201 dnl # placed under the 'rpm/<distribution>' directory and enabled using
202 dnl # the --with-spec=<distribution> configure option.
204 AC_DEFUN([SPL_AC_RPM], [
208 AC_MSG_CHECKING([whether $RPM is available])
209 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
210 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
212 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
215 AC_MSG_RESULT([$HAVE_RPM])
218 AC_MSG_CHECKING([whether $RPMBUILD is available])
219 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
220 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
222 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
225 AC_MSG_RESULT([$HAVE_RPMBUILD])
228 RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"'
230 RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
233 SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
238 RPM_SPEC_DIR="rpm/generic"
240 AS_HELP_STRING([--with-spec=SPEC],
241 [Spec files 'generic|redhat']),
242 [RPM_SPEC_DIR="rpm/$withval"])
244 AC_MSG_CHECKING([whether spec files are available])
245 AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
249 AC_SUBST(RPM_VERSION)
251 AC_SUBST(HAVE_RPMBUILD)
253 AC_SUBST(RPMBUILD_VERSION)
255 AC_SUBST(RPM_SPEC_DIR)
256 AC_SUBST(RPM_DEFINE_UTIL)
257 AC_SUBST(RPM_DEFINE_KMOD)
258 AC_SUBST(RPM_DEFINE_DKMS)
259 AC_SUBST(RPM_DEFINE_COMMON)
260 AC_SUBST(SRPM_DEFINE_UTIL)
261 AC_SUBST(SRPM_DEFINE_KMOD)
262 AC_SUBST(SRPM_DEFINE_DKMS)
263 AC_SUBST(SRPM_DEFINE_COMMON)
267 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
268 dnl # tools are missing it is non-fatal but you will not be able to build
269 dnl # DEB packages and will be warned if you try too.
271 AC_DEFUN([SPL_AC_DPKG], [
273 DPKGBUILD=dpkg-buildpackage
275 AC_MSG_CHECKING([whether $DPKG is available])
276 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
277 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
279 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
282 AC_MSG_RESULT([$HAVE_DPKG])
285 AC_MSG_CHECKING([whether $DPKGBUILD is available])
286 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
287 DPKGBUILD_VERSION=$(echo $tmp | \
288 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
290 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
293 AC_MSG_RESULT([$HAVE_DPKGBUILD])
298 AC_SUBST(DPKG_VERSION)
300 AC_SUBST(HAVE_DPKGBUILD)
302 AC_SUBST(DPKGBUILD_VERSION)
306 dnl # Until native packaging for various different packing systems
307 dnl # can be added the least we can do is attempt to use alien to
308 dnl # convert the RPM packages to the needed package type. This is
309 dnl # a hack but so far it has worked reasonable well.
311 AC_DEFUN([SPL_AC_ALIEN], [
314 AC_MSG_CHECKING([whether $ALIEN is available])
315 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
316 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
318 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
321 AC_MSG_RESULT([$HAVE_ALIEN])
326 AC_SUBST(ALIEN_VERSION)
330 dnl # Using the VENDOR tag from config.guess set the default
331 dnl # package type for 'make pkg': (rpm | deb | tgz)
333 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
334 AC_MSG_CHECKING([linux distribution])
335 if test -f /etc/toss-release ; then
337 elif test -f /etc/fedora-release ; then
339 elif test -f /etc/redhat-release ; then
341 elif test -f /etc/gentoo-release ; then
343 elif test -f /etc/arch-release ; then
345 elif test -f /etc/SuSE-release ; then
347 elif test -f /etc/slackware-version ; then
349 elif test -f /etc/lunar.release ; then
351 elif test -f /etc/lsb-release ; then
353 elif test -f /etc/debian_version ; then
358 AC_MSG_RESULT([$VENDOR])
361 AC_MSG_CHECKING([default package type])
363 toss) DEFAULT_PACKAGE=rpm ;;
364 redhat) DEFAULT_PACKAGE=rpm ;;
365 fedora) DEFAULT_PACKAGE=rpm ;;
366 gentoo) DEFAULT_PACKAGE=tgz ;;
367 arch) DEFAULT_PACKAGE=tgz ;;
368 sles) DEFAULT_PACKAGE=rpm ;;
369 slackware) DEFAULT_PACKAGE=tgz ;;
370 lunar) DEFAULT_PACKAGE=tgz ;;
371 ubuntu) DEFAULT_PACKAGE=deb ;;
372 debian) DEFAULT_PACKAGE=deb ;;
373 *) DEFAULT_PACKAGE=rpm ;;
376 AC_MSG_RESULT([$DEFAULT_PACKAGE])
377 AC_SUBST(DEFAULT_PACKAGE)
381 dnl # Default SPL user configuration
383 AC_DEFUN([SPL_AC_PACKAGE], [
384 SPL_AC_DEFAULT_PACKAGE
390 AC_DEFUN([SPL_AC_LICENSE], [
391 AC_MSG_CHECKING([spl author])
392 AC_MSG_RESULT([$SPL_META_AUTHOR])
394 AC_MSG_CHECKING([spl license])
395 AC_MSG_RESULT([$SPL_META_LICENSE])
398 AC_DEFUN([SPL_AC_CONFIG], [
400 AC_ARG_WITH([config],
401 AS_HELP_STRING([--with-config=CONFIG],
402 [Config file 'kernel|user|all|srpm']),
403 [SPL_CONFIG="$withval"])
404 AC_ARG_ENABLE([linux-builtin],
405 [AC_HELP_STRING([--enable-linux-builtin],
406 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
408 [enable_linux_builtin=no])
410 AC_MSG_CHECKING([spl config])
411 AC_MSG_RESULT([$SPL_CONFIG]);
414 case "$SPL_CONFIG" in
415 kernel) SPL_AC_CONFIG_KERNEL ;;
416 user) SPL_AC_CONFIG_USER ;;
417 all) SPL_AC_CONFIG_KERNEL
418 SPL_AC_CONFIG_USER ;;
421 AC_MSG_RESULT([Error!])
422 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
423 user kernel|user|all|srpm]) ;;
426 AM_CONDITIONAL([CONFIG_USER],
427 [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
428 AM_CONDITIONAL([CONFIG_KERNEL],
429 [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
430 [test "x$enable_linux_builtin" != xyes ])
434 dnl # Enable if the SPL should be compiled with internal debugging enabled.
435 dnl # By default this support is disabled.
437 AC_DEFUN([SPL_AC_DEBUG], [
438 AC_MSG_CHECKING([whether debugging is enabled])
439 AC_ARG_ENABLE([debug],
440 [AS_HELP_STRING([--enable-debug],
441 [Enable generic debug support @<:@default=no@:>@])],
445 AS_IF([test "x$enable_debug" = xyes],
447 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
448 DEBUG_CFLAGS="-DDEBUG -Werror"
449 DEBUG_SPL="_with_debug"
451 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
452 DEBUG_CFLAGS="-DNDEBUG"
453 DEBUG_SPL="_without_debug"
456 AC_SUBST(DEBUG_CFLAGS)
458 AC_MSG_RESULT([$enable_debug])
462 dnl # Enabled by default it provides a minimal level of memory tracking.
463 dnl # A total count of bytes allocated is kept for each alloc and free.
464 dnl # Then at module unload time a report to the console will be printed
465 dnl # if memory was leaked.
467 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
468 AC_ARG_ENABLE([debug-kmem],
469 [AS_HELP_STRING([--enable-debug-kmem],
470 [Enable basic kmem accounting @<:@default=no@:>@])],
472 [enable_debug_kmem=no])
474 AS_IF([test "x$enable_debug_kmem" = xyes],
476 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
477 DEBUG_KMEM="_with_debug_kmem"
478 AC_DEFINE([DEBUG_KMEM], [1],
479 [Define to 1 to enable basic kmem accounting])
481 DEBUG_KMEM="_without_debug_kmem"
485 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
486 AC_MSG_RESULT([$enable_debug_kmem])
490 dnl # Disabled by default it provides detailed memory tracking. This
491 dnl # feature also requires --enable-debug-kmem to be set. When enabled
492 dnl # not only will total bytes be tracked but also the location of every
493 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
494 dnl # addresses and where they were allocated will be dumped to the console.
495 dnl # Enabling this feature has a significant impact on performance but it
496 dnl # makes finding memory leaks pretty straight forward.
498 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
499 AC_ARG_ENABLE([debug-kmem-tracking],
500 [AS_HELP_STRING([--enable-debug-kmem-tracking],
501 [Enable detailed kmem tracking @<:@default=no@:>@])],
503 [enable_debug_kmem_tracking=no])
505 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
507 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
508 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
509 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
510 [Define to 1 to enable detailed kmem tracking])
512 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
515 AC_SUBST(DEBUG_KMEM_TRACKING)
516 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
517 AC_MSG_RESULT([$enable_debug_kmem_tracking])
521 dnl # SPL_LINUX_CONFTEST
523 AC_DEFUN([SPL_LINUX_CONFTEST], [
524 cat confdefs.h - <<_ACEOF >conftest.c
530 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
532 m4_define([SPL_LANG_PROGRAM], [
537 dnl Do *not* indent the following line: there may be CPP directives.
538 dnl Don't move the `;' right after for the same reason.
546 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
548 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
549 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
550 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
551 echo "obj-m := conftest.o" >build/Makefile
553 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
555 [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])],
557 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
563 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
565 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
566 [SPL_LINUX_COMPILE_IFELSE(
567 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
569 [test -s build/conftest.o],
574 dnl # SPL_CHECK_SYMBOL_EXPORT
575 dnl # check symbol exported or not
577 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
578 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
579 $LINUX_OBJ/Module*.symvers 2>/dev/null
581 if test $rc -ne 0; then
584 grep -q -E "EXPORT_SYMBOL.*($1)" \
585 "$LINUX_OBJ/$file" 2>/dev/null
587 if test $rc -eq 0; then
592 if test $export -eq 0; then :
603 dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
604 dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
605 dnl # is called if not compiling for builtin
607 AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
608 SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
609 if test $rc -ne 0; then :
612 if test "x$enable_linux_builtin" != xyes; then
613 SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
615 if test $rc -ne 0; then :
624 dnl # SPL_CHECK_SYMBOL_HEADER
625 dnl # check if a symbol prototype is defined in listed headers.
627 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
628 AC_MSG_CHECKING([whether symbol $1 exists in header])
631 grep -q "$2" "$LINUX/$file" 2>/dev/null
633 if test $rc -eq 0; then
638 if test $header -eq 0; then
648 dnl # SPL_CHECK_HEADER
649 dnl # check whether header exists and define HAVE_$2_HEADER
651 AC_DEFUN([SPL_CHECK_HEADER],
652 [AC_MSG_CHECKING([whether header $1 exists])
653 SPL_LINUX_TRY_COMPILE([
658 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
668 dnl # Basic toolchain sanity check. Verify that kernel modules can
669 dnl # be built and which symbols can be used.
671 AC_DEFUN([SPL_AC_TEST_MODULE],
672 [AC_MSG_CHECKING([whether modules can be built])
673 SPL_LINUX_TRY_COMPILE([],[],[
677 if test "x$enable_linux_builtin" != xyes; then
678 AC_MSG_ERROR([*** Unable to build an empty module.])
681 *** Unable to build an empty module.
682 *** Please run 'make scripts' inside the kernel source tree.])
686 AS_IF([test "x$cross_compiling" != xyes], [
689 #include "$LINUX/include/linux/license.h"
691 return !license_is_gpl_compatible(
692 "$SPL_META_LICENSE");
695 AC_DEFINE([SPL_IS_GPL_COMPATIBLE], [1],
696 [Define to 1 if GPL-only symbols can be used])
703 dnl # Use the atomic implemenation based on global spinlocks. This
704 dnl # should only be needed by 32-bit kernels which do not provide
705 dnl # the atomic64_* API. It may be optionally enabled as a fallback
706 dnl # if problems are observed with the direct mapping to the native
707 dnl # Linux atomic operations. You may not disable atomic spinlocks
708 dnl # if you kernel does not an atomic64_* API.
710 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
711 AC_ARG_ENABLE([atomic-spinlocks],
712 [AS_HELP_STRING([--enable-atomic-spinlocks],
713 [Atomic types use spinlocks @<:@default=check@:>@])],
715 [enable_atomic_spinlocks=check])
717 SPL_LINUX_TRY_COMPILE([
718 #include <linux/fs.h>
720 atomic64_t *ptr __attribute__ ((unused));
723 AC_DEFINE(HAVE_ATOMIC64_T, 1,
724 [kernel defines atomic64_t])
729 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
730 AS_IF([test "x$have_atomic64_t" = xyes], [
731 enable_atomic_spinlocks=no
733 enable_atomic_spinlocks=yes
737 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
738 AC_DEFINE([ATOMIC_SPINLOCK], [1],
739 [Atomic types use spinlocks])
741 AS_IF([test "x$have_atomic64_t" = xno], [
743 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
747 AC_MSG_CHECKING([whether atomic types use spinlocks])
748 AC_MSG_RESULT([$enable_atomic_spinlocks])
750 AC_MSG_CHECKING([whether kernel defines atomic64_t])
751 AC_MSG_RESULT([$have_atomic64_t])
754 AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[
755 tmp_flags="$EXTRA_KCFLAGS"
756 EXTRA_KCFLAGS="-Werror"
758 dnl # 2.6.23 to 2.6.34 API change
759 dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask)
761 AC_MSG_CHECKING([whether old 2-argument shrinker exists])
762 SPL_LINUX_TRY_COMPILE([
763 #include <linux/mm.h>
765 int shrinker_cb(int nr_to_scan, gfp_t gfp_mask);
767 struct shrinker cache_shrinker = {
768 .shrink = shrinker_cb,
769 .seeks = DEFAULT_SEEKS,
771 register_shrinker(&cache_shrinker);
774 AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1,
775 [old shrinker callback wants 2 args])
779 dnl # 2.6.35 - 2.6.39 API change
780 dnl # ->shrink(struct shrinker *,
781 dnl # int nr_to_scan, gfp_t gfp_mask)
783 AC_MSG_CHECKING([whether old 3-argument shrinker exists])
784 SPL_LINUX_TRY_COMPILE([
785 #include <linux/mm.h>
787 int shrinker_cb(struct shrinker *, int nr_to_scan,
790 struct shrinker cache_shrinker = {
791 .shrink = shrinker_cb,
792 .seeks = DEFAULT_SEEKS,
794 register_shrinker(&cache_shrinker);
797 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
798 [old shrinker callback wants 3 args])
802 dnl # 3.0 - 3.11 API change
803 dnl # ->shrink(struct shrinker *,
804 dnl # struct shrink_control *sc)
807 [whether new 2-argument shrinker exists])
808 SPL_LINUX_TRY_COMPILE([
809 #include <linux/mm.h>
811 int shrinker_cb(struct shrinker *,
812 struct shrink_control *sc);
814 struct shrinker cache_shrinker = {
815 .shrink = shrinker_cb,
816 .seeks = DEFAULT_SEEKS,
818 register_shrinker(&cache_shrinker);
821 AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1,
822 [new shrinker callback wants 2 args])
826 dnl # 3.12 API change,
827 dnl # ->shrink() is logically split in to
828 dnl # ->count_objects() and ->scan_objects()
831 [whether ->count_objects callback exists])
832 SPL_LINUX_TRY_COMPILE([
833 #include <linux/mm.h>
835 unsigned long shrinker_cb(
837 struct shrink_control *sc);
839 struct shrinker cache_shrinker = {
840 .count_objects = shrinker_cb,
841 .scan_objects = shrinker_cb,
842 .seeks = DEFAULT_SEEKS,
844 register_shrinker(&cache_shrinker);
847 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
848 1, [->count_objects exists])
855 EXTRA_KCFLAGS="$tmp_flags"
859 dnl # 2.6.33 API change,
860 dnl # Removed .ctl_name from struct ctl_table.
862 AC_DEFUN([SPL_AC_CTL_NAME], [
863 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
864 SPL_LINUX_TRY_COMPILE([
865 #include <linux/sysctl.h>
867 struct ctl_table ctl __attribute__ ((unused));
871 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
878 dnl # 3.10 API change,
879 dnl # PDE is replaced by PDE_DATA
881 AC_DEFUN([SPL_AC_PDE_DATA], [
882 AC_MSG_CHECKING([whether PDE_DATA() is available])
883 SPL_LINUX_TRY_COMPILE_SYMBOL([
884 #include <linux/proc_fs.h>
889 AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
897 dnl # set_fs_pwd takes const struct path *
899 AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
900 tmp_flags="$EXTRA_KCFLAGS"
901 EXTRA_KCFLAGS="-Werror"
902 [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
903 SPL_LINUX_TRY_COMPILE([
904 #include <linux/spinlock.h>
905 #include <linux/fs_struct.h>
906 #include <linux/path.h>
907 void (*const set_fs_pwd_func)
908 (struct fs_struct *, const struct path *)
914 AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
915 [set_fs_pwd() needs const path *])
917 SPL_LINUX_TRY_COMPILE([
918 #include <linux/spinlock.h>
919 #include <linux/fs_struct.h>
920 #include <linux/path.h>
921 void (*const set_fs_pwd_func)
922 (struct fs_struct *, struct path *)
929 AC_MSG_ERROR(unknown)
932 EXTRA_KCFLAGS="$tmp_flags"
936 dnl # 3.13 API change
937 dnl # vfs_unlink() updated to take a third delegated_inode argument.
939 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
940 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
941 SPL_LINUX_TRY_COMPILE([
942 #include <linux/fs.h>
944 vfs_unlink((struct inode *) NULL, (struct dentry *) NULL);
947 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
948 [vfs_unlink() wants 2 args])
952 dnl # Linux 3.13 API change
953 dnl # Added delegated inode
955 AC_MSG_CHECKING([whether vfs_unlink() wants 3 args])
956 SPL_LINUX_TRY_COMPILE([
957 #include <linux/fs.h>
959 vfs_unlink((struct inode *) NULL,
960 (struct dentry *) NULL,
961 (struct inode **) NULL);
964 AC_DEFINE(HAVE_3ARGS_VFS_UNLINK, 1,
965 [vfs_unlink() wants 3 args])
974 dnl # 3.13 and 3.15 API changes
975 dnl # Added delegated inode and flags argument.
977 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
978 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
979 SPL_LINUX_TRY_COMPILE([
980 #include <linux/fs.h>
982 vfs_rename((struct inode *) NULL, (struct dentry *) NULL,
983 (struct inode *) NULL, (struct dentry *) NULL);
986 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
987 [vfs_rename() wants 4 args])
991 dnl # Linux 3.13 API change
992 dnl # Added delegated inode
994 AC_MSG_CHECKING([whether vfs_rename() wants 5 args])
995 SPL_LINUX_TRY_COMPILE([
996 #include <linux/fs.h>
998 vfs_rename((struct inode *) NULL,
999 (struct dentry *) NULL,
1000 (struct inode *) NULL,
1001 (struct dentry *) NULL,
1002 (struct inode **) NULL);
1005 AC_DEFINE(HAVE_5ARGS_VFS_RENAME, 1,
1006 [vfs_rename() wants 5 args])
1010 dnl # Linux 3.15 API change
1013 AC_MSG_CHECKING([whether vfs_rename() wants 6 args])
1014 SPL_LINUX_TRY_COMPILE([
1015 #include <linux/fs.h>
1017 vfs_rename((struct inode *) NULL,
1018 (struct dentry *) NULL,
1019 (struct inode *) NULL,
1020 (struct dentry *) NULL,
1021 (struct inode **) NULL,
1025 AC_DEFINE(HAVE_6ARGS_VFS_RENAME, 1,
1026 [vfs_rename() wants 6 args])
1035 dnl # 2.6.36 API change,
1036 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1037 dnl # a spinlock_t to improve the fastpath performance.
1039 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1040 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1041 tmp_flags="$EXTRA_KCFLAGS"
1042 EXTRA_KCFLAGS="-Werror"
1043 SPL_LINUX_TRY_COMPILE([
1044 #include <linux/sched.h>
1045 #include <linux/fs_struct.h>
1047 static struct fs_struct fs;
1048 spin_lock_init(&fs.lock);
1051 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1052 [struct fs_struct uses spinlock_t])
1056 EXTRA_KCFLAGS="$tmp_flags"
1060 dnl # User namespaces, use kuid_t in place of uid_t
1061 dnl # where available. Not strictly a user namespaces thing
1062 dnl # but it should prevent surprises
1064 AC_DEFUN([SPL_AC_KUIDGID_T], [
1065 AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
1066 SPL_LINUX_TRY_COMPILE([
1067 #include <linux/uidgid.h>
1069 kuid_t userid = KUIDT_INIT(0);
1070 kgid_t groupid = KGIDT_INIT(0);
1072 SPL_LINUX_TRY_COMPILE([
1073 #include <linux/uidgid.h>
1078 AC_MSG_RESULT(yes; optional)
1080 AC_MSG_RESULT(yes; mandatory)
1081 AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
1089 dnl # 2.6.35 API change,
1090 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
1092 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
1093 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
1094 SPL_LINUX_TRY_COMPILE([
1095 #include <linux/fs.h>
1100 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
1107 dnl # 3.5 API change,
1108 dnl # inode_operations.truncate_range removed
1110 AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
1111 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
1112 SPL_LINUX_TRY_COMPILE([
1113 #include <linux/fs.h>
1115 struct inode_operations ops;
1116 ops.truncate_range = NULL;
1119 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
1120 [truncate_range() inode operation is available])
1127 dnl # Linux 2.6.38 - 3.x API
1129 AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
1130 AC_MSG_CHECKING([whether fops->fallocate() exists])
1131 SPL_LINUX_TRY_COMPILE([
1132 #include <linux/fs.h>
1134 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1135 struct file_operations fops __attribute__ ((unused)) = {
1136 .fallocate = fallocate,
1140 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1147 dnl # Linux 2.6.x - 2.6.37 API
1149 AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
1150 AC_MSG_CHECKING([whether iops->fallocate() exists])
1151 SPL_LINUX_TRY_COMPILE([
1152 #include <linux/fs.h>
1154 long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
1155 struct inode_operations fops __attribute__ ((unused)) = {
1156 .fallocate = fallocate,
1160 AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
1167 dnl # PaX Linux 2.6.38 - 3.x API
1169 AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
1170 AC_MSG_CHECKING([whether fops->fallocate() exists])
1171 SPL_LINUX_TRY_COMPILE([
1172 #include <linux/fs.h>
1174 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1175 struct file_operations_no_const fops __attribute__ ((unused)) = {
1176 .fallocate = fallocate,
1180 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1187 dnl # The fallocate callback was moved from the inode_operations
1188 dnl # structure to the file_operations structure.
1190 AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
1191 SPL_AC_KERNEL_FILE_FALLOCATE
1192 SPL_AC_KERNEL_INODE_FALLOCATE
1193 SPL_AC_PAX_KERNEL_FILE_FALLOCATE
1197 dnl # zlib inflate compat,
1198 dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
1200 AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
1201 AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
1202 SPL_LINUX_TRY_COMPILE([
1203 #if !defined(CONFIG_ZLIB_INFLATE) && \
1204 !defined(CONFIG_ZLIB_INFLATE_MODULE)
1205 #error CONFIG_ZLIB_INFLATE not defined
1208 AC_MSG_RESULT([yes])
1212 *** This kernel does not include the required zlib inflate support.
1213 *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
1218 dnl # zlib deflate compat,
1219 dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
1221 AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
1222 AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
1223 SPL_LINUX_TRY_COMPILE([
1224 #if !defined(CONFIG_ZLIB_DEFLATE) && \
1225 !defined(CONFIG_ZLIB_DEFLATE_MODULE)
1226 #error CONFIG_ZLIB_DEFLATE not defined
1229 AC_MSG_RESULT([yes])
1233 *** This kernel does not include the required zlib deflate support.
1234 *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
1239 dnl # config trim unused symbols,
1240 dnl # Verify the kernel has CONFIG_TRIM_UNUSED_KSYMS DISABLED.
1242 AC_DEFUN([SPL_AC_CONFIG_TRIM_UNUSED_KSYMS], [
1243 AC_MSG_CHECKING([whether CONFIG_TRIM_UNUSED_KSYM is disabled])
1244 SPL_LINUX_TRY_COMPILE([
1245 #if defined(CONFIG_TRIM_UNUSED_KSYMS)
1246 #error CONFIG_TRIM_UNUSED_KSYMS not defined
1249 AC_MSG_RESULT([yes])
1253 *** This kernel has unused symbols trimming enabled, please disable.
1254 *** Rebuild the kernel with CONFIG_TRIM_UNUSED_KSYMS=n set.])
1259 dnl # 2.6.39 API compat,
1260 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
1261 dnl # This was done to avoid always having to allocate the maximum size
1262 dnl # workspace (268K). The caller can now specific the windowBits and
1263 dnl # memLevel compression parameters to get a smaller workspace.
1265 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
1266 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
1267 SPL_LINUX_TRY_COMPILE([
1268 #include <linux/zlib.h>
1270 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
1273 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
1274 [zlib_deflate_workspacesize() wants 2 args])
1281 dnl # 2.6.39 API change,
1282 dnl # Shrinker adjust to use common shrink_control structure.
1284 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
1285 AC_MSG_CHECKING([whether struct shrink_control exists])
1286 SPL_LINUX_TRY_COMPILE([
1287 #include <linux/mm.h>
1289 struct shrink_control sc __attribute__ ((unused));
1292 sc.gfp_mask = GFP_KERNEL;
1295 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
1296 [struct shrink_control exists])
1303 dnl # 3.1 API Change
1305 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
1306 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
1308 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
1309 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
1310 tmp_flags="$EXTRA_KCFLAGS"
1311 EXTRA_KCFLAGS="-Werror"
1312 SPL_LINUX_TRY_COMPILE([
1313 #include <linux/rwsem.h>
1315 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
1316 raw_spinlock_t dummy_lock __attribute__ ((unused)) =
1317 __RAW_SPIN_LOCK_INITIALIZER(dummy_lock);
1318 dummy_semaphore.wait_lock = dummy_lock;
1321 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
1322 [struct rw_semaphore member wait_lock is raw_spinlock_t])
1326 EXTRA_KCFLAGS="$tmp_flags"
1330 dnl # 3.16 API Change
1332 dnl # rwsem-spinlock "->activity" changed to "->count"
1334 AC_DEFUN([SPL_AC_RWSEM_ACTIVITY], [
1335 AC_MSG_CHECKING([whether struct rw_semaphore has member activity])
1336 tmp_flags="$EXTRA_KCFLAGS"
1337 EXTRA_KCFLAGS="-Werror"
1338 SPL_LINUX_TRY_COMPILE([
1339 #include <linux/rwsem.h>
1341 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
1342 dummy_semaphore.activity = 0;
1345 AC_DEFINE(HAVE_RWSEM_ACTIVITY, 1,
1346 [struct rw_semaphore has member activity])
1350 EXTRA_KCFLAGS="$tmp_flags"
1354 dnl # 4.8 API Change
1356 dnl # rwsem "->count" changed to atomic_long_t type
1358 AC_DEFUN([SPL_AC_RWSEM_ATOMIC_LONG_COUNT], [
1360 [whether struct rw_semaphore has atomic_long_t member count])
1361 tmp_flags="$EXTRA_KCFLAGS"
1362 EXTRA_KCFLAGS="-Werror"
1363 SPL_LINUX_TRY_COMPILE([
1364 #include <linux/rwsem.h>
1366 DECLARE_RWSEM(dummy_semaphore);
1367 (void) atomic_long_read(&dummy_semaphore.count);
1370 AC_DEFINE(HAVE_RWSEM_ATOMIC_LONG_COUNT, 1,
1371 [struct rw_semaphore has atomic_long_t member count])
1375 EXTRA_KCFLAGS="$tmp_flags"
1379 dnl # 3.9 API change,
1380 dnl # Moved things from linux/sched.h to linux/sched/rt.h
1382 AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
1383 [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
1384 SPL_LINUX_TRY_COMPILE([
1385 #include <linux/sched.h>
1386 #include <linux/sched/rt.h>
1390 AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
1398 dnl # 4.11 API change,
1399 dnl # Moved things from linux/sched.h to linux/sched/signal.h
1401 AC_DEFUN([SPL_AC_SCHED_SIGNAL_HEADER],
1402 [AC_MSG_CHECKING([whether header linux/sched/signal.h exists])
1403 SPL_LINUX_TRY_COMPILE([
1404 #include <linux/sched.h>
1405 #include <linux/sched/signal.h>
1409 AC_DEFINE(HAVE_SCHED_SIGNAL_HEADER, 1, [linux/sched/signal.h exists])
1417 dnl # 4.11 API, a528d35e@torvalds/linux
1418 dnl # vfs_getattr(const struct path *p, struct kstat *s, u32 m, unsigned int f)
1420 AC_DEFUN([SPL_AC_4ARGS_VFS_GETATTR], [
1421 AC_MSG_CHECKING([whether vfs_getattr() wants 4 args])
1422 SPL_LINUX_TRY_COMPILE([
1423 #include <linux/fs.h>
1425 vfs_getattr((const struct path *)NULL,
1426 (struct kstat *)NULL,
1431 AC_DEFINE(HAVE_4ARGS_VFS_GETATTR, 1,
1432 [vfs_getattr wants 4 args])
1440 dnl # vfs_getattr(struct path *p, struct kstat *s)
1442 AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
1443 AC_MSG_CHECKING([whether vfs_getattr() wants 2 args])
1444 SPL_LINUX_TRY_COMPILE([
1445 #include <linux/fs.h>
1447 vfs_getattr((struct path *) NULL,
1448 (struct kstat *)NULL);
1451 AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
1452 [vfs_getattr wants 2 args])
1460 dnl # vfs_getattr(struct vfsmount *v, struct dentry *d, struct kstat *k)
1462 AC_DEFUN([SPL_AC_3ARGS_VFS_GETATTR], [
1463 AC_MSG_CHECKING([whether vfs_getattr() wants 3 args])
1464 SPL_LINUX_TRY_COMPILE([
1465 #include <linux/fs.h>
1467 vfs_getattr((struct vfsmount *)NULL,
1468 (struct dentry *)NULL,
1469 (struct kstat *)NULL);
1472 AC_DEFINE(HAVE_3ARGS_VFS_GETATTR, 1,
1473 [vfs_getattr wants 3 args])
1480 dnl # 2.6.36 API compatibility.
1481 dnl # Added usleep_range timer.
1482 dnl # usleep_range is a finer precision implementation of msleep
1483 dnl # designed to be a drop-in replacement for udelay where a precise
1484 dnl # sleep / busy-wait is unnecessary.
1486 AC_DEFUN([SPL_AC_USLEEP_RANGE], [
1487 AC_MSG_CHECKING([whether usleep_range() is available])
1488 SPL_LINUX_TRY_COMPILE([
1489 #include <linux/delay.h>
1494 AC_DEFINE(HAVE_USLEEP_RANGE, 1,
1495 [usleep_range is available])
1502 dnl # 2.6.35 API change,
1503 dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are
1504 dnl # private allocation flags which are applied when allocating a new slab
1505 dnl # in kmem_getpages(). Unfortunately there is no public API for setting
1506 dnl # non-default flags.
1508 AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [
1509 AC_MSG_CHECKING([whether struct kmem_cache has allocflags])
1510 SPL_LINUX_TRY_COMPILE([
1511 #include <linux/slab.h>
1513 struct kmem_cache cachep __attribute__ ((unused));
1514 cachep.allocflags = GFP_KERNEL;
1517 AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1,
1518 [struct kmem_cache has allocflags])
1522 AC_MSG_CHECKING([whether struct kmem_cache has gfpflags])
1523 SPL_LINUX_TRY_COMPILE([
1524 #include <linux/slab.h>
1526 struct kmem_cache cachep __attribute__ ((unused));
1527 cachep.gfpflags = GFP_KERNEL;
1530 AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1,
1531 [struct kmem_cache has gfpflags])
1539 dnl # 3.17 API change,
1540 dnl # wait_on_bit() no longer requires an action argument. The former
1541 dnl # "wait_on_bit" interface required an 'action' function to be provided
1542 dnl # which does the actual waiting. There were over 20 such functions in the
1543 dnl # kernel, many of them identical, though most cases can be satisfied by one
1544 dnl # of just two functions: one which uses io_schedule() and one which just
1545 dnl # uses schedule(). This API change was made to consolidate all of those
1546 dnl # redundant wait functions.
1548 AC_DEFUN([SPL_AC_WAIT_ON_BIT], [
1549 AC_MSG_CHECKING([whether wait_on_bit() takes an action])
1550 SPL_LINUX_TRY_COMPILE([
1551 #include <linux/wait.h>
1553 int (*action)(void *) = NULL;
1554 wait_on_bit(NULL, 0, action, 0);
1557 AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes])
1564 dnl # 4.7 API change
1565 dnl # i_mutex is changed to i_rwsem. Instead of directly using
1566 dnl # i_mutex/i_rwsem, we should use inode_lock() and inode_lock_shared()
1567 dnl # We test inode_lock_shared because inode_lock is introduced earlier.
1569 AC_DEFUN([SPL_AC_INODE_LOCK], [
1570 AC_MSG_CHECKING([whether inode_lock_shared() exists])
1571 tmp_flags="$EXTRA_KCFLAGS"
1572 EXTRA_KCFLAGS="-Werror"
1573 SPL_LINUX_TRY_COMPILE([
1574 #include <linux/fs.h>
1576 struct inode *inode = NULL;
1577 inode_lock_shared(inode);
1580 AC_DEFINE(HAVE_INODE_LOCK_SHARED, 1, [yes])
1584 EXTRA_KCFLAGS="$tmp_flags"
1588 dnl # Check whether mutex has owner with task_struct type.
1590 dnl # Note that before Linux 3.0, mutex owner is of type thread_info.
1592 dnl # Note that in Linux 3.18, the condition for owner is changed from
1593 dnl # defined(CONFIG_DEBUG_MUTEXES) || defined(CONFIG_SMP) to
1594 dnl # defined(CONFIG_DEBUG_MUTEXES) || defined(CONFIG_MUTEX_SPIN_ON_OWNER)
1596 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1597 AC_MSG_CHECKING([whether mutex has owner])
1598 tmp_flags="$EXTRA_KCFLAGS"
1599 EXTRA_KCFLAGS="-Werror"
1600 SPL_LINUX_TRY_COMPILE([
1601 #include <linux/mutex.h>
1602 #include <linux/spinlock.h>
1605 struct task_struct *t __attribute__ ((unused));
1609 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [yes])
1613 EXTRA_KCFLAGS="$tmp_flags"
1617 dnl # 4.9 API change
1618 dnl # group_info changed from 2d array via >blocks to 1d array via ->gid
1620 AC_DEFUN([SPL_AC_GROUP_INFO_GID], [
1621 AC_MSG_CHECKING([whether group_info->gid exists])
1622 tmp_flags="$EXTRA_KCFLAGS"
1623 EXTRA_KCFLAGS="-Werror"
1624 SPL_LINUX_TRY_COMPILE([
1625 #include <linux/cred.h>
1627 struct group_info *gi = groups_alloc(1);
1628 gi->gid[0] = KGIDT_INIT(0);
1631 AC_DEFINE(HAVE_GROUP_INFO_GID, 1, [group_info->gid exists])
1635 EXTRA_KCFLAGS="$tmp_flags"
1639 dnl # 4.13 API change
1640 dnl # Renamed struct wait_queue -> struct wait_queue_entry.
1642 AC_DEFUN([SPL_AC_WAIT_QUEUE_ENTRY_T], [
1643 AC_MSG_CHECKING([whether wait_queue_entry_t exists])
1644 SPL_LINUX_TRY_COMPILE([
1645 #include <linux/wait.h>
1647 wait_queue_entry_t *entry __attribute__ ((unused));
1650 AC_DEFINE(HAVE_WAIT_QUEUE_ENTRY_T, 1,
1651 [wait_queue_entry_t exists])
1658 dnl # 4.13 API change
1659 dnl # Renamed wait_queue_head::task_list -> wait_queue_head::head
1660 dnl # Renamed wait_queue_entry::task_list -> wait_queue_entry::entry
1662 AC_DEFUN([SPL_AC_WAIT_QUEUE_HEAD_ENTRY], [
1663 AC_MSG_CHECKING([whether wq_head->head and wq_entry->entry exist])
1664 SPL_LINUX_TRY_COMPILE([
1665 #include <linux/wait.h>
1667 #ifdef HAVE_WAIT_QUEUE_ENTRY_T
1668 typedef wait_queue_head_t spl_wait_queue_head_t;
1669 typedef wait_queue_entry_t spl_wait_queue_entry_t;
1671 typedef wait_queue_head_t spl_wait_queue_head_t;
1672 typedef wait_queue_t spl_wait_queue_entry_t;
1675 spl_wait_queue_head_t wq_head;
1676 spl_wait_queue_entry_t wq_entry;
1677 struct list_head *head __attribute__ ((unused));
1678 struct list_head *entry __attribute__ ((unused));
1680 head = &wq_head.head;
1681 entry = &wq_entry.entry;
1684 AC_DEFINE(HAVE_WAIT_QUEUE_HEAD_ENTRY, 1,
1685 [wq_head->head and wq_entry->entry exist])