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_KMEM_CACHE_CREATE_USERCOPY
56 SPL_AC_WAIT_QUEUE_ENTRY_T
57 SPL_AC_WAIT_QUEUE_HEAD_ENTRY
60 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
61 modpost=$LINUX/scripts/Makefile.modpost
62 AC_MSG_CHECKING([kernel file name for module symbols])
63 if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
64 if grep -q Modules.symvers $modpost; then
65 LINUX_SYMBOLS=Modules.symvers
67 LINUX_SYMBOLS=Module.symvers
70 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
72 *** Please make sure the kernel devel package for your distribution
73 *** is installed. If you are building with a custom kernel, make sure the
74 *** kernel is configured, built, and the '--with-linux=PATH' configure
75 *** option refers to the location of the kernel source.])
80 AC_MSG_RESULT($LINUX_SYMBOLS)
81 AC_SUBST(LINUX_SYMBOLS)
84 AC_DEFUN([SPL_AC_KERNEL], [
86 AS_HELP_STRING([--with-linux=PATH],
87 [Path to kernel source]),
88 [kernelsrc="$withval"])
90 AC_ARG_WITH([linux-obj],
91 AS_HELP_STRING([--with-linux-obj=PATH],
92 [Path to kernel build objects]),
93 [kernelbuild="$withval"])
95 AC_MSG_CHECKING([kernel source directory])
96 if test -z "$kernelsrc"; then
97 if test -e "/lib/modules/$(uname -r)/source"; then
98 headersdir="/lib/modules/$(uname -r)/source"
99 sourcelink=$(readlink -f "$headersdir")
100 elif test -e "/lib/modules/$(uname -r)/build"; then
101 headersdir="/lib/modules/$(uname -r)/build"
102 sourcelink=$(readlink -f "$headersdir")
104 sourcelink=$(ls -1d /usr/src/kernels/* \
106 2>/dev/null | grep -v obj | tail -1)
109 if test -n "$sourcelink" && test -e ${sourcelink}; then
110 kernelsrc=`readlink -f ${sourcelink}`
112 kernelsrc="[Not found]"
115 if test "$kernelsrc" = "NONE"; then
121 AC_MSG_RESULT([$kernelsrc])
122 if test ! -d "$kernelsrc"; then
124 *** Please make sure the kernel devel package for your distribution
125 *** is installed and then try again. If that fails, you can specify the
126 *** location of the kernel source with the '--with-linux=PATH' option.])
129 AC_MSG_CHECKING([kernel build directory])
130 if test -z "$kernelbuild"; then
131 if test x$withlinux != xyes -a -e "/lib/modules/$(uname -r)/build"; then
132 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
133 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
134 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
135 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
136 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
137 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
138 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
140 kernelbuild=${kernelsrc}
143 AC_MSG_RESULT([$kernelbuild])
145 AC_MSG_CHECKING([kernel source version])
146 utsrelease1=$kernelbuild/include/linux/version.h
147 utsrelease2=$kernelbuild/include/linux/utsrelease.h
148 utsrelease3=$kernelbuild/include/generated/utsrelease.h
149 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
150 utsrelease=linux/version.h
151 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
152 utsrelease=linux/utsrelease.h
153 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
154 utsrelease=generated/utsrelease.h
157 if test "$utsrelease"; then
158 kernsrcver=`(echo "#include <$utsrelease>";
159 echo "kernsrcver=UTS_RELEASE") |
160 cpp -I $kernelbuild/include |
161 grep "^kernsrcver=" | cut -d \" -f 2`
163 if test -z "$kernsrcver"; then
164 AC_MSG_RESULT([Not found])
165 AC_MSG_ERROR([*** Cannot determine kernel version.])
168 AC_MSG_RESULT([Not found])
169 if test "x$enable_linux_builtin" != xyes; then
170 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
173 *** Cannot find UTS_RELEASE definition.
174 *** Please run 'make prepare' inside the kernel source tree.])
178 AC_MSG_RESULT([$kernsrcver])
181 LINUX_OBJ=${kernelbuild}
182 LINUX_VERSION=${kernsrcver}
186 AC_SUBST(LINUX_VERSION)
188 SPL_AC_MODULE_SYMVERS
192 dnl # Default SPL user configuration
194 AC_DEFUN([SPL_AC_CONFIG_USER], [])
197 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
198 dnl # are missing, it is non-fatal, but you will not be able to build
199 dnl # RPM packages and will be warned if you try too.
201 dnl # By default, the generic spec file will be used because it requires
202 dnl # minimal dependencies. Distribution specific spec files can be
203 dnl # placed under the 'rpm/<distribution>' directory and enabled using
204 dnl # the --with-spec=<distribution> configure option.
206 AC_DEFUN([SPL_AC_RPM], [
210 AC_MSG_CHECKING([whether $RPM is available])
211 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
212 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
214 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
217 AC_MSG_RESULT([$HAVE_RPM])
220 AC_MSG_CHECKING([whether $RPMBUILD is available])
221 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
222 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
224 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
227 AC_MSG_RESULT([$HAVE_RPMBUILD])
230 RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"'
232 RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
235 SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
240 RPM_SPEC_DIR="rpm/generic"
242 AS_HELP_STRING([--with-spec=SPEC],
243 [Spec files 'generic|redhat']),
244 [RPM_SPEC_DIR="rpm/$withval"])
246 AC_MSG_CHECKING([whether spec files are available])
247 AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
251 AC_SUBST(RPM_VERSION)
253 AC_SUBST(HAVE_RPMBUILD)
255 AC_SUBST(RPMBUILD_VERSION)
257 AC_SUBST(RPM_SPEC_DIR)
258 AC_SUBST(RPM_DEFINE_UTIL)
259 AC_SUBST(RPM_DEFINE_KMOD)
260 AC_SUBST(RPM_DEFINE_DKMS)
261 AC_SUBST(RPM_DEFINE_COMMON)
262 AC_SUBST(SRPM_DEFINE_UTIL)
263 AC_SUBST(SRPM_DEFINE_KMOD)
264 AC_SUBST(SRPM_DEFINE_DKMS)
265 AC_SUBST(SRPM_DEFINE_COMMON)
269 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
270 dnl # tools are missing it is non-fatal but you will not be able to build
271 dnl # DEB packages and will be warned if you try too.
273 AC_DEFUN([SPL_AC_DPKG], [
275 DPKGBUILD=dpkg-buildpackage
277 AC_MSG_CHECKING([whether $DPKG is available])
278 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
279 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
281 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
284 AC_MSG_RESULT([$HAVE_DPKG])
287 AC_MSG_CHECKING([whether $DPKGBUILD is available])
288 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
289 DPKGBUILD_VERSION=$(echo $tmp | \
290 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
292 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
295 AC_MSG_RESULT([$HAVE_DPKGBUILD])
300 AC_SUBST(DPKG_VERSION)
302 AC_SUBST(HAVE_DPKGBUILD)
304 AC_SUBST(DPKGBUILD_VERSION)
308 dnl # Until native packaging for various different packing systems
309 dnl # can be added the least we can do is attempt to use alien to
310 dnl # convert the RPM packages to the needed package type. This is
311 dnl # a hack but so far it has worked reasonable well.
313 AC_DEFUN([SPL_AC_ALIEN], [
316 AC_MSG_CHECKING([whether $ALIEN is available])
317 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
318 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
320 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
323 AC_MSG_RESULT([$HAVE_ALIEN])
328 AC_SUBST(ALIEN_VERSION)
332 dnl # Using the VENDOR tag from config.guess set the default
333 dnl # package type for 'make pkg': (rpm | deb | tgz)
335 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
336 AC_MSG_CHECKING([linux distribution])
337 if test -f /etc/toss-release ; then
339 elif test -f /etc/fedora-release ; then
341 elif test -f /etc/redhat-release ; then
343 elif test -f /etc/gentoo-release ; then
345 elif test -f /etc/arch-release ; then
347 elif test -f /etc/SuSE-release ; then
349 elif test -f /etc/slackware-version ; then
351 elif test -f /etc/lunar.release ; then
353 elif test -f /etc/lsb-release ; then
355 elif test -f /etc/debian_version ; then
360 AC_MSG_RESULT([$VENDOR])
363 AC_MSG_CHECKING([default package type])
365 toss) DEFAULT_PACKAGE=rpm ;;
366 redhat) DEFAULT_PACKAGE=rpm ;;
367 fedora) DEFAULT_PACKAGE=rpm ;;
368 gentoo) DEFAULT_PACKAGE=tgz ;;
369 arch) DEFAULT_PACKAGE=tgz ;;
370 sles) DEFAULT_PACKAGE=rpm ;;
371 slackware) DEFAULT_PACKAGE=tgz ;;
372 lunar) DEFAULT_PACKAGE=tgz ;;
373 ubuntu) DEFAULT_PACKAGE=deb ;;
374 debian) DEFAULT_PACKAGE=deb ;;
375 *) DEFAULT_PACKAGE=rpm ;;
378 AC_MSG_RESULT([$DEFAULT_PACKAGE])
379 AC_SUBST(DEFAULT_PACKAGE)
383 dnl # Default SPL user configuration
385 AC_DEFUN([SPL_AC_PACKAGE], [
386 SPL_AC_DEFAULT_PACKAGE
392 AC_DEFUN([SPL_AC_LICENSE], [
393 AC_MSG_CHECKING([spl author])
394 AC_MSG_RESULT([$SPL_META_AUTHOR])
396 AC_MSG_CHECKING([spl license])
397 AC_MSG_RESULT([$SPL_META_LICENSE])
400 AC_DEFUN([SPL_AC_CONFIG], [
402 AC_ARG_WITH([config],
403 AS_HELP_STRING([--with-config=CONFIG],
404 [Config file 'kernel|user|all|srpm']),
405 [SPL_CONFIG="$withval"])
406 AC_ARG_ENABLE([linux-builtin],
407 [AC_HELP_STRING([--enable-linux-builtin],
408 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
410 [enable_linux_builtin=no])
412 AC_MSG_CHECKING([spl config])
413 AC_MSG_RESULT([$SPL_CONFIG]);
416 case "$SPL_CONFIG" in
417 kernel) SPL_AC_CONFIG_KERNEL ;;
418 user) SPL_AC_CONFIG_USER ;;
419 all) SPL_AC_CONFIG_KERNEL
420 SPL_AC_CONFIG_USER ;;
423 AC_MSG_RESULT([Error!])
424 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
425 user kernel|user|all|srpm]) ;;
428 AM_CONDITIONAL([CONFIG_USER],
429 [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
430 AM_CONDITIONAL([CONFIG_KERNEL],
431 [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
432 [test "x$enable_linux_builtin" != xyes ])
436 dnl # Enable if the SPL should be compiled with internal debugging enabled.
437 dnl # By default this support is disabled.
439 AC_DEFUN([SPL_AC_DEBUG], [
440 AC_MSG_CHECKING([whether debugging is enabled])
441 AC_ARG_ENABLE([debug],
442 [AS_HELP_STRING([--enable-debug],
443 [Enable generic debug support @<:@default=no@:>@])],
447 AS_IF([test "x$enable_debug" = xyes],
449 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
450 DEBUG_CFLAGS="-DDEBUG -Werror"
451 DEBUG_SPL="_with_debug"
453 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
454 DEBUG_CFLAGS="-DNDEBUG"
455 DEBUG_SPL="_without_debug"
458 AC_SUBST(DEBUG_CFLAGS)
460 AC_MSG_RESULT([$enable_debug])
464 dnl # Enabled by default it provides a minimal level of memory tracking.
465 dnl # A total count of bytes allocated is kept for each alloc and free.
466 dnl # Then at module unload time a report to the console will be printed
467 dnl # if memory was leaked.
469 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
470 AC_ARG_ENABLE([debug-kmem],
471 [AS_HELP_STRING([--enable-debug-kmem],
472 [Enable basic kmem accounting @<:@default=no@:>@])],
474 [enable_debug_kmem=no])
476 AS_IF([test "x$enable_debug_kmem" = xyes],
478 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
479 DEBUG_KMEM="_with_debug_kmem"
480 AC_DEFINE([DEBUG_KMEM], [1],
481 [Define to 1 to enable basic kmem accounting])
483 DEBUG_KMEM="_without_debug_kmem"
487 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
488 AC_MSG_RESULT([$enable_debug_kmem])
492 dnl # Disabled by default it provides detailed memory tracking. This
493 dnl # feature also requires --enable-debug-kmem to be set. When enabled
494 dnl # not only will total bytes be tracked but also the location of every
495 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
496 dnl # addresses and where they were allocated will be dumped to the console.
497 dnl # Enabling this feature has a significant impact on performance but it
498 dnl # makes finding memory leaks pretty straight forward.
500 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
501 AC_ARG_ENABLE([debug-kmem-tracking],
502 [AS_HELP_STRING([--enable-debug-kmem-tracking],
503 [Enable detailed kmem tracking @<:@default=no@:>@])],
505 [enable_debug_kmem_tracking=no])
507 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
509 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
510 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
511 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
512 [Define to 1 to enable detailed kmem tracking])
514 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
517 AC_SUBST(DEBUG_KMEM_TRACKING)
518 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
519 AC_MSG_RESULT([$enable_debug_kmem_tracking])
523 dnl # SPL_LINUX_CONFTEST
525 AC_DEFUN([SPL_LINUX_CONFTEST], [
526 cat confdefs.h - <<_ACEOF >conftest.c
532 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
534 m4_define([SPL_LANG_PROGRAM], [
539 dnl Do *not* indent the following line: there may be CPP directives.
540 dnl Don't move the `;' right after for the same reason.
548 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
550 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
551 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
552 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
553 echo "obj-m := conftest.o" >build/Makefile
555 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
557 [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])],
559 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
565 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
567 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
568 [SPL_LINUX_COMPILE_IFELSE(
569 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
571 [test -s build/conftest.o],
576 dnl # SPL_CHECK_SYMBOL_EXPORT
577 dnl # check symbol exported or not
579 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
580 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
581 $LINUX_OBJ/Module*.symvers 2>/dev/null
583 if test $rc -ne 0; then
586 grep -q -E "EXPORT_SYMBOL.*($1)" \
587 "$LINUX_OBJ/$file" 2>/dev/null
589 if test $rc -eq 0; then
594 if test $export -eq 0; then :
605 dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
606 dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
607 dnl # is called if not compiling for builtin
609 AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
610 SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
611 if test $rc -ne 0; then :
614 if test "x$enable_linux_builtin" != xyes; then
615 SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
617 if test $rc -ne 0; then :
626 dnl # SPL_CHECK_SYMBOL_HEADER
627 dnl # check if a symbol prototype is defined in listed headers.
629 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
630 AC_MSG_CHECKING([whether symbol $1 exists in header])
633 grep -q "$2" "$LINUX/$file" 2>/dev/null
635 if test $rc -eq 0; then
640 if test $header -eq 0; then
650 dnl # SPL_CHECK_HEADER
651 dnl # check whether header exists and define HAVE_$2_HEADER
653 AC_DEFUN([SPL_CHECK_HEADER],
654 [AC_MSG_CHECKING([whether header $1 exists])
655 SPL_LINUX_TRY_COMPILE([
660 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
670 dnl # Basic toolchain sanity check. Verify that kernel modules can
671 dnl # be built and which symbols can be used.
673 AC_DEFUN([SPL_AC_TEST_MODULE],
674 [AC_MSG_CHECKING([whether modules can be built])
675 SPL_LINUX_TRY_COMPILE([],[],[
679 if test "x$enable_linux_builtin" != xyes; then
680 AC_MSG_ERROR([*** Unable to build an empty module.])
683 *** Unable to build an empty module.
684 *** Please run 'make scripts' inside the kernel source tree.])
688 AS_IF([test "x$cross_compiling" != xyes], [
691 #include "$LINUX/include/linux/license.h"
693 return !license_is_gpl_compatible(
694 "$SPL_META_LICENSE");
697 AC_DEFINE([SPL_IS_GPL_COMPATIBLE], [1],
698 [Define to 1 if GPL-only symbols can be used])
705 dnl # Use the atomic implemenation based on global spinlocks. This
706 dnl # should only be needed by 32-bit kernels which do not provide
707 dnl # the atomic64_* API. It may be optionally enabled as a fallback
708 dnl # if problems are observed with the direct mapping to the native
709 dnl # Linux atomic operations. You may not disable atomic spinlocks
710 dnl # if you kernel does not an atomic64_* API.
712 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
713 AC_ARG_ENABLE([atomic-spinlocks],
714 [AS_HELP_STRING([--enable-atomic-spinlocks],
715 [Atomic types use spinlocks @<:@default=check@:>@])],
717 [enable_atomic_spinlocks=check])
719 SPL_LINUX_TRY_COMPILE([
720 #include <linux/fs.h>
722 atomic64_t *ptr __attribute__ ((unused));
725 AC_DEFINE(HAVE_ATOMIC64_T, 1,
726 [kernel defines atomic64_t])
731 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
732 AS_IF([test "x$have_atomic64_t" = xyes], [
733 enable_atomic_spinlocks=no
735 enable_atomic_spinlocks=yes
739 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
740 AC_DEFINE([ATOMIC_SPINLOCK], [1],
741 [Atomic types use spinlocks])
743 AS_IF([test "x$have_atomic64_t" = xno], [
745 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
749 AC_MSG_CHECKING([whether atomic types use spinlocks])
750 AC_MSG_RESULT([$enable_atomic_spinlocks])
752 AC_MSG_CHECKING([whether kernel defines atomic64_t])
753 AC_MSG_RESULT([$have_atomic64_t])
756 AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[
757 tmp_flags="$EXTRA_KCFLAGS"
758 EXTRA_KCFLAGS="-Werror"
760 dnl # 2.6.23 to 2.6.34 API change
761 dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask)
763 AC_MSG_CHECKING([whether old 2-argument shrinker exists])
764 SPL_LINUX_TRY_COMPILE([
765 #include <linux/mm.h>
767 int shrinker_cb(int nr_to_scan, gfp_t gfp_mask);
769 struct shrinker cache_shrinker = {
770 .shrink = shrinker_cb,
771 .seeks = DEFAULT_SEEKS,
773 register_shrinker(&cache_shrinker);
776 AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1,
777 [old shrinker callback wants 2 args])
781 dnl # 2.6.35 - 2.6.39 API change
782 dnl # ->shrink(struct shrinker *,
783 dnl # int nr_to_scan, gfp_t gfp_mask)
785 AC_MSG_CHECKING([whether old 3-argument shrinker exists])
786 SPL_LINUX_TRY_COMPILE([
787 #include <linux/mm.h>
789 int shrinker_cb(struct shrinker *, int nr_to_scan,
792 struct shrinker cache_shrinker = {
793 .shrink = shrinker_cb,
794 .seeks = DEFAULT_SEEKS,
796 register_shrinker(&cache_shrinker);
799 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
800 [old shrinker callback wants 3 args])
804 dnl # 3.0 - 3.11 API change
805 dnl # ->shrink(struct shrinker *,
806 dnl # struct shrink_control *sc)
809 [whether new 2-argument shrinker exists])
810 SPL_LINUX_TRY_COMPILE([
811 #include <linux/mm.h>
813 int shrinker_cb(struct shrinker *,
814 struct shrink_control *sc);
816 struct shrinker cache_shrinker = {
817 .shrink = shrinker_cb,
818 .seeks = DEFAULT_SEEKS,
820 register_shrinker(&cache_shrinker);
823 AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1,
824 [new shrinker callback wants 2 args])
828 dnl # 3.12 API change,
829 dnl # ->shrink() is logically split in to
830 dnl # ->count_objects() and ->scan_objects()
833 [whether ->count_objects callback exists])
834 SPL_LINUX_TRY_COMPILE([
835 #include <linux/mm.h>
837 unsigned long shrinker_cb(
839 struct shrink_control *sc);
841 struct shrinker cache_shrinker = {
842 .count_objects = shrinker_cb,
843 .scan_objects = shrinker_cb,
844 .seeks = DEFAULT_SEEKS,
846 register_shrinker(&cache_shrinker);
849 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
850 1, [->count_objects exists])
857 EXTRA_KCFLAGS="$tmp_flags"
861 dnl # 2.6.33 API change,
862 dnl # Removed .ctl_name from struct ctl_table.
864 AC_DEFUN([SPL_AC_CTL_NAME], [
865 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
866 SPL_LINUX_TRY_COMPILE([
867 #include <linux/sysctl.h>
869 struct ctl_table ctl __attribute__ ((unused));
873 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
880 dnl # 3.10 API change,
881 dnl # PDE is replaced by PDE_DATA
883 AC_DEFUN([SPL_AC_PDE_DATA], [
884 AC_MSG_CHECKING([whether PDE_DATA() is available])
885 SPL_LINUX_TRY_COMPILE_SYMBOL([
886 #include <linux/proc_fs.h>
891 AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
899 dnl # set_fs_pwd takes const struct path *
901 AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
902 tmp_flags="$EXTRA_KCFLAGS"
903 EXTRA_KCFLAGS="-Werror"
904 [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
905 SPL_LINUX_TRY_COMPILE([
906 #include <linux/spinlock.h>
907 #include <linux/fs_struct.h>
908 #include <linux/path.h>
909 void (*const set_fs_pwd_func)
910 (struct fs_struct *, const struct path *)
916 AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
917 [set_fs_pwd() needs const path *])
919 SPL_LINUX_TRY_COMPILE([
920 #include <linux/spinlock.h>
921 #include <linux/fs_struct.h>
922 #include <linux/path.h>
923 void (*const set_fs_pwd_func)
924 (struct fs_struct *, struct path *)
931 AC_MSG_ERROR(unknown)
934 EXTRA_KCFLAGS="$tmp_flags"
938 dnl # 3.13 API change
939 dnl # vfs_unlink() updated to take a third delegated_inode argument.
941 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
942 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
943 SPL_LINUX_TRY_COMPILE([
944 #include <linux/fs.h>
946 vfs_unlink((struct inode *) NULL, (struct dentry *) NULL);
949 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
950 [vfs_unlink() wants 2 args])
954 dnl # Linux 3.13 API change
955 dnl # Added delegated inode
957 AC_MSG_CHECKING([whether vfs_unlink() wants 3 args])
958 SPL_LINUX_TRY_COMPILE([
959 #include <linux/fs.h>
961 vfs_unlink((struct inode *) NULL,
962 (struct dentry *) NULL,
963 (struct inode **) NULL);
966 AC_DEFINE(HAVE_3ARGS_VFS_UNLINK, 1,
967 [vfs_unlink() wants 3 args])
976 dnl # 3.13 and 3.15 API changes
977 dnl # Added delegated inode and flags argument.
979 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
980 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
981 SPL_LINUX_TRY_COMPILE([
982 #include <linux/fs.h>
984 vfs_rename((struct inode *) NULL, (struct dentry *) NULL,
985 (struct inode *) NULL, (struct dentry *) NULL);
988 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
989 [vfs_rename() wants 4 args])
993 dnl # Linux 3.13 API change
994 dnl # Added delegated inode
996 AC_MSG_CHECKING([whether vfs_rename() wants 5 args])
997 SPL_LINUX_TRY_COMPILE([
998 #include <linux/fs.h>
1000 vfs_rename((struct inode *) NULL,
1001 (struct dentry *) NULL,
1002 (struct inode *) NULL,
1003 (struct dentry *) NULL,
1004 (struct inode **) NULL);
1007 AC_DEFINE(HAVE_5ARGS_VFS_RENAME, 1,
1008 [vfs_rename() wants 5 args])
1012 dnl # Linux 3.15 API change
1015 AC_MSG_CHECKING([whether vfs_rename() wants 6 args])
1016 SPL_LINUX_TRY_COMPILE([
1017 #include <linux/fs.h>
1019 vfs_rename((struct inode *) NULL,
1020 (struct dentry *) NULL,
1021 (struct inode *) NULL,
1022 (struct dentry *) NULL,
1023 (struct inode **) NULL,
1027 AC_DEFINE(HAVE_6ARGS_VFS_RENAME, 1,
1028 [vfs_rename() wants 6 args])
1037 dnl # 2.6.36 API change,
1038 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1039 dnl # a spinlock_t to improve the fastpath performance.
1041 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1042 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1043 tmp_flags="$EXTRA_KCFLAGS"
1044 EXTRA_KCFLAGS="-Werror"
1045 SPL_LINUX_TRY_COMPILE([
1046 #include <linux/sched.h>
1047 #include <linux/fs_struct.h>
1049 static struct fs_struct fs;
1050 spin_lock_init(&fs.lock);
1053 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1054 [struct fs_struct uses spinlock_t])
1058 EXTRA_KCFLAGS="$tmp_flags"
1062 dnl # User namespaces, use kuid_t in place of uid_t
1063 dnl # where available. Not strictly a user namespaces thing
1064 dnl # but it should prevent surprises
1066 AC_DEFUN([SPL_AC_KUIDGID_T], [
1067 AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
1068 SPL_LINUX_TRY_COMPILE([
1069 #include <linux/uidgid.h>
1071 kuid_t userid = KUIDT_INIT(0);
1072 kgid_t groupid = KGIDT_INIT(0);
1074 SPL_LINUX_TRY_COMPILE([
1075 #include <linux/uidgid.h>
1080 AC_MSG_RESULT(yes; optional)
1082 AC_MSG_RESULT(yes; mandatory)
1083 AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
1091 dnl # 2.6.35 API change,
1092 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
1094 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
1095 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
1096 SPL_LINUX_TRY_COMPILE([
1097 #include <linux/fs.h>
1102 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
1109 dnl # 3.5 API change,
1110 dnl # inode_operations.truncate_range removed
1112 AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
1113 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
1114 SPL_LINUX_TRY_COMPILE([
1115 #include <linux/fs.h>
1117 struct inode_operations ops;
1118 ops.truncate_range = NULL;
1121 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
1122 [truncate_range() inode operation is available])
1129 dnl # Linux 2.6.38 - 3.x API
1131 AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
1132 AC_MSG_CHECKING([whether fops->fallocate() exists])
1133 SPL_LINUX_TRY_COMPILE([
1134 #include <linux/fs.h>
1136 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1137 struct file_operations fops __attribute__ ((unused)) = {
1138 .fallocate = fallocate,
1142 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1149 dnl # Linux 2.6.x - 2.6.37 API
1151 AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
1152 AC_MSG_CHECKING([whether iops->fallocate() exists])
1153 SPL_LINUX_TRY_COMPILE([
1154 #include <linux/fs.h>
1156 long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
1157 struct inode_operations fops __attribute__ ((unused)) = {
1158 .fallocate = fallocate,
1162 AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
1169 dnl # PaX Linux 2.6.38 - 3.x API
1171 AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
1172 AC_MSG_CHECKING([whether fops->fallocate() exists])
1173 SPL_LINUX_TRY_COMPILE([
1174 #include <linux/fs.h>
1176 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1177 struct file_operations_no_const fops __attribute__ ((unused)) = {
1178 .fallocate = fallocate,
1182 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1189 dnl # The fallocate callback was moved from the inode_operations
1190 dnl # structure to the file_operations structure.
1192 AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
1193 SPL_AC_KERNEL_FILE_FALLOCATE
1194 SPL_AC_KERNEL_INODE_FALLOCATE
1195 SPL_AC_PAX_KERNEL_FILE_FALLOCATE
1199 dnl # zlib inflate compat,
1200 dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
1202 AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
1203 AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
1204 SPL_LINUX_TRY_COMPILE([
1205 #if !defined(CONFIG_ZLIB_INFLATE) && \
1206 !defined(CONFIG_ZLIB_INFLATE_MODULE)
1207 #error CONFIG_ZLIB_INFLATE not defined
1210 AC_MSG_RESULT([yes])
1214 *** This kernel does not include the required zlib inflate support.
1215 *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
1220 dnl # zlib deflate compat,
1221 dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
1223 AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
1224 AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
1225 SPL_LINUX_TRY_COMPILE([
1226 #if !defined(CONFIG_ZLIB_DEFLATE) && \
1227 !defined(CONFIG_ZLIB_DEFLATE_MODULE)
1228 #error CONFIG_ZLIB_DEFLATE not defined
1231 AC_MSG_RESULT([yes])
1235 *** This kernel does not include the required zlib deflate support.
1236 *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
1241 dnl # config trim unused symbols,
1242 dnl # Verify the kernel has CONFIG_TRIM_UNUSED_KSYMS DISABLED.
1244 AC_DEFUN([SPL_AC_CONFIG_TRIM_UNUSED_KSYMS], [
1245 AC_MSG_CHECKING([whether CONFIG_TRIM_UNUSED_KSYM is disabled])
1246 SPL_LINUX_TRY_COMPILE([
1247 #if defined(CONFIG_TRIM_UNUSED_KSYMS)
1248 #error CONFIG_TRIM_UNUSED_KSYMS not defined
1251 AC_MSG_RESULT([yes])
1255 *** This kernel has unused symbols trimming enabled, please disable.
1256 *** Rebuild the kernel with CONFIG_TRIM_UNUSED_KSYMS=n set.])
1261 dnl # 2.6.39 API compat,
1262 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
1263 dnl # This was done to avoid always having to allocate the maximum size
1264 dnl # workspace (268K). The caller can now specific the windowBits and
1265 dnl # memLevel compression parameters to get a smaller workspace.
1267 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
1268 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
1269 SPL_LINUX_TRY_COMPILE([
1270 #include <linux/zlib.h>
1272 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
1275 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
1276 [zlib_deflate_workspacesize() wants 2 args])
1283 dnl # 2.6.39 API change,
1284 dnl # Shrinker adjust to use common shrink_control structure.
1286 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
1287 AC_MSG_CHECKING([whether struct shrink_control exists])
1288 SPL_LINUX_TRY_COMPILE([
1289 #include <linux/mm.h>
1291 struct shrink_control sc __attribute__ ((unused));
1294 sc.gfp_mask = GFP_KERNEL;
1297 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
1298 [struct shrink_control exists])
1305 dnl # 3.1 API Change
1307 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
1308 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
1310 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
1311 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
1312 tmp_flags="$EXTRA_KCFLAGS"
1313 EXTRA_KCFLAGS="-Werror"
1314 SPL_LINUX_TRY_COMPILE([
1315 #include <linux/rwsem.h>
1317 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
1318 raw_spinlock_t dummy_lock __attribute__ ((unused)) =
1319 __RAW_SPIN_LOCK_INITIALIZER(dummy_lock);
1320 dummy_semaphore.wait_lock = dummy_lock;
1323 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
1324 [struct rw_semaphore member wait_lock is raw_spinlock_t])
1328 EXTRA_KCFLAGS="$tmp_flags"
1332 dnl # 3.16 API Change
1334 dnl # rwsem-spinlock "->activity" changed to "->count"
1336 AC_DEFUN([SPL_AC_RWSEM_ACTIVITY], [
1337 AC_MSG_CHECKING([whether struct rw_semaphore has member activity])
1338 tmp_flags="$EXTRA_KCFLAGS"
1339 EXTRA_KCFLAGS="-Werror"
1340 SPL_LINUX_TRY_COMPILE([
1341 #include <linux/rwsem.h>
1343 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
1344 dummy_semaphore.activity = 0;
1347 AC_DEFINE(HAVE_RWSEM_ACTIVITY, 1,
1348 [struct rw_semaphore has member activity])
1352 EXTRA_KCFLAGS="$tmp_flags"
1356 dnl # 4.8 API Change
1358 dnl # rwsem "->count" changed to atomic_long_t type
1360 AC_DEFUN([SPL_AC_RWSEM_ATOMIC_LONG_COUNT], [
1362 [whether struct rw_semaphore has atomic_long_t member count])
1363 tmp_flags="$EXTRA_KCFLAGS"
1364 EXTRA_KCFLAGS="-Werror"
1365 SPL_LINUX_TRY_COMPILE([
1366 #include <linux/rwsem.h>
1368 DECLARE_RWSEM(dummy_semaphore);
1369 (void) atomic_long_read(&dummy_semaphore.count);
1372 AC_DEFINE(HAVE_RWSEM_ATOMIC_LONG_COUNT, 1,
1373 [struct rw_semaphore has atomic_long_t member count])
1377 EXTRA_KCFLAGS="$tmp_flags"
1381 dnl # 3.9 API change,
1382 dnl # Moved things from linux/sched.h to linux/sched/rt.h
1384 AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
1385 [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
1386 SPL_LINUX_TRY_COMPILE([
1387 #include <linux/sched.h>
1388 #include <linux/sched/rt.h>
1392 AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
1400 dnl # 4.11 API change,
1401 dnl # Moved things from linux/sched.h to linux/sched/signal.h
1403 AC_DEFUN([SPL_AC_SCHED_SIGNAL_HEADER],
1404 [AC_MSG_CHECKING([whether header linux/sched/signal.h exists])
1405 SPL_LINUX_TRY_COMPILE([
1406 #include <linux/sched.h>
1407 #include <linux/sched/signal.h>
1411 AC_DEFINE(HAVE_SCHED_SIGNAL_HEADER, 1, [linux/sched/signal.h exists])
1419 dnl # 4.11 API, a528d35e@torvalds/linux
1420 dnl # vfs_getattr(const struct path *p, struct kstat *s, u32 m, unsigned int f)
1422 AC_DEFUN([SPL_AC_4ARGS_VFS_GETATTR], [
1423 AC_MSG_CHECKING([whether vfs_getattr() wants 4 args])
1424 SPL_LINUX_TRY_COMPILE([
1425 #include <linux/fs.h>
1427 vfs_getattr((const struct path *)NULL,
1428 (struct kstat *)NULL,
1433 AC_DEFINE(HAVE_4ARGS_VFS_GETATTR, 1,
1434 [vfs_getattr wants 4 args])
1442 dnl # vfs_getattr(struct path *p, struct kstat *s)
1444 AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
1445 AC_MSG_CHECKING([whether vfs_getattr() wants 2 args])
1446 SPL_LINUX_TRY_COMPILE([
1447 #include <linux/fs.h>
1449 vfs_getattr((struct path *) NULL,
1450 (struct kstat *)NULL);
1453 AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
1454 [vfs_getattr wants 2 args])
1462 dnl # vfs_getattr(struct vfsmount *v, struct dentry *d, struct kstat *k)
1464 AC_DEFUN([SPL_AC_3ARGS_VFS_GETATTR], [
1465 AC_MSG_CHECKING([whether vfs_getattr() wants 3 args])
1466 SPL_LINUX_TRY_COMPILE([
1467 #include <linux/fs.h>
1469 vfs_getattr((struct vfsmount *)NULL,
1470 (struct dentry *)NULL,
1471 (struct kstat *)NULL);
1474 AC_DEFINE(HAVE_3ARGS_VFS_GETATTR, 1,
1475 [vfs_getattr wants 3 args])
1482 dnl # 2.6.36 API compatibility.
1483 dnl # Added usleep_range timer.
1484 dnl # usleep_range is a finer precision implementation of msleep
1485 dnl # designed to be a drop-in replacement for udelay where a precise
1486 dnl # sleep / busy-wait is unnecessary.
1488 AC_DEFUN([SPL_AC_USLEEP_RANGE], [
1489 AC_MSG_CHECKING([whether usleep_range() is available])
1490 SPL_LINUX_TRY_COMPILE([
1491 #include <linux/delay.h>
1496 AC_DEFINE(HAVE_USLEEP_RANGE, 1,
1497 [usleep_range is available])
1504 dnl # 2.6.35 API change,
1505 dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are
1506 dnl # private allocation flags which are applied when allocating a new slab
1507 dnl # in kmem_getpages(). Unfortunately there is no public API for setting
1508 dnl # non-default flags.
1510 AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [
1511 AC_MSG_CHECKING([whether struct kmem_cache has allocflags])
1512 SPL_LINUX_TRY_COMPILE([
1513 #include <linux/slab.h>
1515 struct kmem_cache cachep __attribute__ ((unused));
1516 cachep.allocflags = GFP_KERNEL;
1519 AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1,
1520 [struct kmem_cache has allocflags])
1524 AC_MSG_CHECKING([whether struct kmem_cache has gfpflags])
1525 SPL_LINUX_TRY_COMPILE([
1526 #include <linux/slab.h>
1528 struct kmem_cache cachep __attribute__ ((unused));
1529 cachep.gfpflags = GFP_KERNEL;
1532 AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1,
1533 [struct kmem_cache has gfpflags])
1541 dnl # 3.17 API change,
1542 dnl # wait_on_bit() no longer requires an action argument. The former
1543 dnl # "wait_on_bit" interface required an 'action' function to be provided
1544 dnl # which does the actual waiting. There were over 20 such functions in the
1545 dnl # kernel, many of them identical, though most cases can be satisfied by one
1546 dnl # of just two functions: one which uses io_schedule() and one which just
1547 dnl # uses schedule(). This API change was made to consolidate all of those
1548 dnl # redundant wait functions.
1550 AC_DEFUN([SPL_AC_WAIT_ON_BIT], [
1551 AC_MSG_CHECKING([whether wait_on_bit() takes an action])
1552 SPL_LINUX_TRY_COMPILE([
1553 #include <linux/wait.h>
1555 int (*action)(void *) = NULL;
1556 wait_on_bit(NULL, 0, action, 0);
1559 AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes])
1566 dnl # Check whether mutex has owner with task_struct type.
1568 dnl # Note that before Linux 3.0, mutex owner is of type thread_info.
1570 dnl # Note that in Linux 3.18, the condition for owner is changed from
1571 dnl # defined(CONFIG_DEBUG_MUTEXES) || defined(CONFIG_SMP) to
1572 dnl # defined(CONFIG_DEBUG_MUTEXES) || defined(CONFIG_MUTEX_SPIN_ON_OWNER)
1574 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1575 AC_MSG_CHECKING([whether mutex has owner])
1576 tmp_flags="$EXTRA_KCFLAGS"
1577 EXTRA_KCFLAGS="-Werror"
1578 SPL_LINUX_TRY_COMPILE([
1579 #include <linux/mutex.h>
1580 #include <linux/spinlock.h>
1583 struct task_struct *t __attribute__ ((unused));
1587 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [yes])
1591 EXTRA_KCFLAGS="$tmp_flags"
1595 dnl # 4.7 API change
1596 dnl # i_mutex is changed to i_rwsem. Instead of directly using
1597 dnl # i_mutex/i_rwsem, we should use inode_lock() and inode_lock_shared()
1598 dnl # We test inode_lock_shared because inode_lock is introduced earlier.
1600 AC_DEFUN([SPL_AC_INODE_LOCK], [
1601 AC_MSG_CHECKING([whether inode_lock_shared() exists])
1602 tmp_flags="$EXTRA_KCFLAGS"
1603 EXTRA_KCFLAGS="-Werror"
1604 SPL_LINUX_TRY_COMPILE([
1605 #include <linux/fs.h>
1607 struct inode *inode = NULL;
1608 inode_lock_shared(inode);
1611 AC_DEFINE(HAVE_INODE_LOCK_SHARED, 1, [yes])
1615 EXTRA_KCFLAGS="$tmp_flags"
1619 dnl # 4.9 API change
1620 dnl # group_info changed from 2d array via >blocks to 1d array via ->gid
1622 AC_DEFUN([SPL_AC_GROUP_INFO_GID], [
1623 AC_MSG_CHECKING([whether group_info->gid exists])
1624 tmp_flags="$EXTRA_KCFLAGS"
1625 EXTRA_KCFLAGS="-Werror"
1626 SPL_LINUX_TRY_COMPILE([
1627 #include <linux/cred.h>
1629 struct group_info *gi = groups_alloc(1);
1630 gi->gid[0] = KGIDT_INIT(0);
1633 AC_DEFINE(HAVE_GROUP_INFO_GID, 1, [group_info->gid exists])
1637 EXTRA_KCFLAGS="$tmp_flags"
1641 dnl # grsecurity API change,
1642 dnl # kmem_cache_create() with SLAB_USERCOPY flag replaced by
1643 dnl # kmem_cache_create_usercopy().
1645 AC_DEFUN([SPL_AC_KMEM_CACHE_CREATE_USERCOPY], [
1646 AC_MSG_CHECKING([whether kmem_cache_create_usercopy() exists])
1647 tmp_flags="$EXTRA_KCFLAGS"
1648 EXTRA_KCFLAGS="-Werror"
1649 SPL_LINUX_TRY_COMPILE([
1650 #include <linux/slab.h>
1651 static void ctor(void *foo)
1656 struct kmem_cache *skc_linux_cache;
1657 const char *name = "test";
1660 unsigned long flags = 0;
1661 size_t useroffset = 0;
1662 size_t usersize = size - useroffset;
1664 skc_linux_cache = kmem_cache_create_usercopy(
1665 name, size, align, flags, useroffset, usersize, ctor);
1668 AC_DEFINE(HAVE_KMEM_CACHE_CREATE_USERCOPY, 1,
1669 [kmem_cache_create_usercopy() exists])
1673 EXTRA_KCFLAGS="$tmp_flags"
1677 dnl # 4.13 API change
1678 dnl # Renamed struct wait_queue -> struct wait_queue_entry.
1680 AC_DEFUN([SPL_AC_WAIT_QUEUE_ENTRY_T], [
1681 AC_MSG_CHECKING([whether wait_queue_entry_t exists])
1682 SPL_LINUX_TRY_COMPILE([
1683 #include <linux/wait.h>
1685 wait_queue_entry_t *entry __attribute__ ((unused));
1688 AC_DEFINE(HAVE_WAIT_QUEUE_ENTRY_T, 1,
1689 [wait_queue_entry_t exists])
1696 dnl # 4.13 API change
1697 dnl # Renamed wait_queue_head::task_list -> wait_queue_head::head
1698 dnl # Renamed wait_queue_entry::task_list -> wait_queue_entry::entry
1700 AC_DEFUN([SPL_AC_WAIT_QUEUE_HEAD_ENTRY], [
1701 AC_MSG_CHECKING([whether wq_head->head and wq_entry->entry exist])
1702 SPL_LINUX_TRY_COMPILE([
1703 #include <linux/wait.h>
1705 #ifdef HAVE_WAIT_QUEUE_ENTRY_T
1706 typedef wait_queue_head_t spl_wait_queue_head_t;
1707 typedef wait_queue_entry_t spl_wait_queue_entry_t;
1709 typedef wait_queue_head_t spl_wait_queue_head_t;
1710 typedef wait_queue_t spl_wait_queue_entry_t;
1713 spl_wait_queue_head_t wq_head;
1714 spl_wait_queue_entry_t wq_entry;
1715 struct list_head *head __attribute__ ((unused));
1716 struct list_head *entry __attribute__ ((unused));
1718 head = &wq_head.head;
1719 entry = &wq_entry.entry;
1722 AC_DEFINE(HAVE_WAIT_QUEUE_HEAD_ENTRY, 1,
1723 [wq_head->head and wq_entry->entry exist])