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
54 SPL_AC_KMEM_CACHE_CREATE_USERCOPY
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
120 AC_MSG_RESULT([$kernelsrc])
121 if test ! -d "$kernelsrc"; then
123 *** Please make sure the kernel devel package for your distribution
124 *** is installed and then try again. If that fails, you can specify the
125 *** location of the kernel source with the '--with-linux=PATH' option.])
128 AC_MSG_CHECKING([kernel build directory])
129 if test -z "$kernelbuild"; then
130 if test x$withlinux != xyes -a -e "/lib/modules/$(uname -r)/build"; then
131 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
132 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
133 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
134 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
135 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
136 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
137 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
139 kernelbuild=${kernelsrc}
142 AC_MSG_RESULT([$kernelbuild])
144 AC_MSG_CHECKING([kernel source version])
145 utsrelease1=$kernelbuild/include/linux/version.h
146 utsrelease2=$kernelbuild/include/linux/utsrelease.h
147 utsrelease3=$kernelbuild/include/generated/utsrelease.h
148 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
149 utsrelease=linux/version.h
150 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
151 utsrelease=linux/utsrelease.h
152 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
153 utsrelease=generated/utsrelease.h
156 if test "$utsrelease"; then
157 kernsrcver=`(echo "#include <$utsrelease>";
158 echo "kernsrcver=UTS_RELEASE") |
159 cpp -I $kernelbuild/include |
160 grep "^kernsrcver=" | cut -d \" -f 2`
162 if test -z "$kernsrcver"; then
163 AC_MSG_RESULT([Not found])
164 AC_MSG_ERROR([*** Cannot determine kernel version.])
167 AC_MSG_RESULT([Not found])
168 if test "x$enable_linux_builtin" != xyes; then
169 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
172 *** Cannot find UTS_RELEASE definition.
173 *** Please run 'make prepare' inside the kernel source tree.])
177 AC_MSG_RESULT([$kernsrcver])
180 LINUX_OBJ=${kernelbuild}
181 LINUX_VERSION=${kernsrcver}
185 AC_SUBST(LINUX_VERSION)
187 SPL_AC_MODULE_SYMVERS
191 dnl # Default SPL user configuration
193 AC_DEFUN([SPL_AC_CONFIG_USER], [])
196 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
197 dnl # are missing, it is non-fatal, but you will not be able to build
198 dnl # RPM packages and will be warned if you try too.
200 dnl # By default, the generic spec file will be used because it requires
201 dnl # minimal dependencies. Distribution specific spec files can be
202 dnl # placed under the 'rpm/<distribution>' directory and enabled using
203 dnl # the --with-spec=<distribution> configure option.
205 AC_DEFUN([SPL_AC_RPM], [
209 AC_MSG_CHECKING([whether $RPM is available])
210 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
211 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
213 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
216 AC_MSG_RESULT([$HAVE_RPM])
219 AC_MSG_CHECKING([whether $RPMBUILD is available])
220 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
221 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
223 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
226 AC_MSG_RESULT([$HAVE_RPMBUILD])
229 RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"'
231 RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
234 SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
239 RPM_SPEC_DIR="rpm/generic"
241 AS_HELP_STRING([--with-spec=SPEC],
242 [Spec files 'generic|redhat']),
243 [RPM_SPEC_DIR="rpm/$withval"])
245 AC_MSG_CHECKING([whether spec files are available])
246 AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
250 AC_SUBST(RPM_VERSION)
252 AC_SUBST(HAVE_RPMBUILD)
254 AC_SUBST(RPMBUILD_VERSION)
256 AC_SUBST(RPM_SPEC_DIR)
257 AC_SUBST(RPM_DEFINE_UTIL)
258 AC_SUBST(RPM_DEFINE_KMOD)
259 AC_SUBST(RPM_DEFINE_DKMS)
260 AC_SUBST(RPM_DEFINE_COMMON)
261 AC_SUBST(SRPM_DEFINE_UTIL)
262 AC_SUBST(SRPM_DEFINE_KMOD)
263 AC_SUBST(SRPM_DEFINE_DKMS)
264 AC_SUBST(SRPM_DEFINE_COMMON)
268 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
269 dnl # tools are missing it is non-fatal but you will not be able to build
270 dnl # DEB packages and will be warned if you try too.
272 AC_DEFUN([SPL_AC_DPKG], [
274 DPKGBUILD=dpkg-buildpackage
276 AC_MSG_CHECKING([whether $DPKG is available])
277 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
278 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
280 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
283 AC_MSG_RESULT([$HAVE_DPKG])
286 AC_MSG_CHECKING([whether $DPKGBUILD is available])
287 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
288 DPKGBUILD_VERSION=$(echo $tmp | \
289 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
291 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
294 AC_MSG_RESULT([$HAVE_DPKGBUILD])
299 AC_SUBST(DPKG_VERSION)
301 AC_SUBST(HAVE_DPKGBUILD)
303 AC_SUBST(DPKGBUILD_VERSION)
307 dnl # Until native packaging for various different packing systems
308 dnl # can be added the least we can do is attempt to use alien to
309 dnl # convert the RPM packages to the needed package type. This is
310 dnl # a hack but so far it has worked reasonable well.
312 AC_DEFUN([SPL_AC_ALIEN], [
315 AC_MSG_CHECKING([whether $ALIEN is available])
316 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
317 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
319 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
322 AC_MSG_RESULT([$HAVE_ALIEN])
327 AC_SUBST(ALIEN_VERSION)
331 dnl # Using the VENDOR tag from config.guess set the default
332 dnl # package type for 'make pkg': (rpm | deb | tgz)
334 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
335 AC_MSG_CHECKING([linux distribution])
336 if test -f /etc/toss-release ; then
338 elif test -f /etc/fedora-release ; then
340 elif test -f /etc/redhat-release ; then
342 elif test -f /etc/gentoo-release ; then
344 elif test -f /etc/arch-release ; then
346 elif test -f /etc/SuSE-release ; then
348 elif test -f /etc/slackware-version ; then
350 elif test -f /etc/lunar.release ; then
352 elif test -f /etc/lsb-release ; then
354 elif test -f /etc/debian_version ; then
359 AC_MSG_RESULT([$VENDOR])
362 AC_MSG_CHECKING([default package type])
364 toss) DEFAULT_PACKAGE=rpm ;;
365 redhat) DEFAULT_PACKAGE=rpm ;;
366 fedora) DEFAULT_PACKAGE=rpm ;;
367 gentoo) DEFAULT_PACKAGE=tgz ;;
368 arch) DEFAULT_PACKAGE=tgz ;;
369 sles) DEFAULT_PACKAGE=rpm ;;
370 slackware) DEFAULT_PACKAGE=tgz ;;
371 lunar) DEFAULT_PACKAGE=tgz ;;
372 ubuntu) DEFAULT_PACKAGE=deb ;;
373 debian) DEFAULT_PACKAGE=deb ;;
374 *) DEFAULT_PACKAGE=rpm ;;
377 AC_MSG_RESULT([$DEFAULT_PACKAGE])
378 AC_SUBST(DEFAULT_PACKAGE)
382 dnl # Default SPL user configuration
384 AC_DEFUN([SPL_AC_PACKAGE], [
385 SPL_AC_DEFAULT_PACKAGE
391 AC_DEFUN([SPL_AC_LICENSE], [
392 AC_MSG_CHECKING([spl author])
393 AC_MSG_RESULT([$SPL_META_AUTHOR])
395 AC_MSG_CHECKING([spl license])
396 AC_MSG_RESULT([$SPL_META_LICENSE])
399 AC_DEFUN([SPL_AC_CONFIG], [
401 AC_ARG_WITH([config],
402 AS_HELP_STRING([--with-config=CONFIG],
403 [Config file 'kernel|user|all|srpm']),
404 [SPL_CONFIG="$withval"])
405 AC_ARG_ENABLE([linux-builtin],
406 [AC_HELP_STRING([--enable-linux-builtin],
407 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
409 [enable_linux_builtin=no])
411 AC_MSG_CHECKING([spl config])
412 AC_MSG_RESULT([$SPL_CONFIG]);
415 case "$SPL_CONFIG" in
416 kernel) SPL_AC_CONFIG_KERNEL ;;
417 user) SPL_AC_CONFIG_USER ;;
418 all) SPL_AC_CONFIG_KERNEL
419 SPL_AC_CONFIG_USER ;;
422 AC_MSG_RESULT([Error!])
423 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
424 user kernel|user|all|srpm]) ;;
427 AM_CONDITIONAL([CONFIG_USER],
428 [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
429 AM_CONDITIONAL([CONFIG_KERNEL],
430 [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
431 [test "x$enable_linux_builtin" != xyes ])
435 dnl # Enable if the SPL should be compiled with internal debugging enabled.
436 dnl # By default this support is disabled.
438 AC_DEFUN([SPL_AC_DEBUG], [
439 AC_MSG_CHECKING([whether debugging is enabled])
440 AC_ARG_ENABLE([debug],
441 [AS_HELP_STRING([--enable-debug],
442 [Enable generic debug support @<:@default=no@:>@])],
446 AS_IF([test "x$enable_debug" = xyes],
448 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
449 DEBUG_CFLAGS="-DDEBUG -Werror"
450 DEBUG_SPL="_with_debug"
452 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
453 DEBUG_CFLAGS="-DNDEBUG"
454 DEBUG_SPL="_without_debug"
457 AC_SUBST(DEBUG_CFLAGS)
459 AC_MSG_RESULT([$enable_debug])
463 dnl # Enabled by default it provides a minimal level of memory tracking.
464 dnl # A total count of bytes allocated is kept for each alloc and free.
465 dnl # Then at module unload time a report to the console will be printed
466 dnl # if memory was leaked.
468 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
469 AC_ARG_ENABLE([debug-kmem],
470 [AS_HELP_STRING([--enable-debug-kmem],
471 [Enable basic kmem accounting @<:@default=no@:>@])],
473 [enable_debug_kmem=no])
475 AS_IF([test "x$enable_debug_kmem" = xyes],
477 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
478 DEBUG_KMEM="_with_debug_kmem"
479 AC_DEFINE([DEBUG_KMEM], [1],
480 [Define to 1 to enable basic kmem accounting])
482 DEBUG_KMEM="_without_debug_kmem"
486 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
487 AC_MSG_RESULT([$enable_debug_kmem])
491 dnl # Disabled by default it provides detailed memory tracking. This
492 dnl # feature also requires --enable-debug-kmem to be set. When enabled
493 dnl # not only will total bytes be tracked but also the location of every
494 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
495 dnl # addresses and where they were allocated will be dumped to the console.
496 dnl # Enabling this feature has a significant impact on performance but it
497 dnl # makes finding memory leaks pretty straight forward.
499 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
500 AC_ARG_ENABLE([debug-kmem-tracking],
501 [AS_HELP_STRING([--enable-debug-kmem-tracking],
502 [Enable detailed kmem tracking @<:@default=no@:>@])],
504 [enable_debug_kmem_tracking=no])
506 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
508 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
509 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
510 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
511 [Define to 1 to enable detailed kmem tracking])
513 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
516 AC_SUBST(DEBUG_KMEM_TRACKING)
517 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
518 AC_MSG_RESULT([$enable_debug_kmem_tracking])
522 dnl # SPL_LINUX_CONFTEST
524 AC_DEFUN([SPL_LINUX_CONFTEST], [
525 cat confdefs.h - <<_ACEOF >conftest.c
531 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
533 m4_define([SPL_LANG_PROGRAM], [
538 dnl Do *not* indent the following line: there may be CPP directives.
539 dnl Don't move the `;' right after for the same reason.
547 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
549 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
550 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
551 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
552 echo "obj-m := conftest.o" >build/Makefile
554 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
556 [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])],
558 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
564 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
566 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
567 [SPL_LINUX_COMPILE_IFELSE(
568 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
570 [test -s build/conftest.o],
575 dnl # SPL_CHECK_SYMBOL_EXPORT
576 dnl # check symbol exported or not
578 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
579 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
580 $LINUX_OBJ/Module*.symvers 2>/dev/null
582 if test $rc -ne 0; then
585 grep -q -E "EXPORT_SYMBOL.*($1)" \
586 "$LINUX_OBJ/$file" 2>/dev/null
588 if test $rc -eq 0; then
593 if test $export -eq 0; then :
604 dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
605 dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
606 dnl # is called if not compiling for builtin
608 AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
609 SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
610 if test $rc -ne 0; then :
613 if test "x$enable_linux_builtin" != xyes; then
614 SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
616 if test $rc -ne 0; then :
625 dnl # SPL_CHECK_SYMBOL_HEADER
626 dnl # check if a symbol prototype is defined in listed headers.
628 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
629 AC_MSG_CHECKING([whether symbol $1 exists in header])
632 grep -q "$2" "$LINUX/$file" 2>/dev/null
634 if test $rc -eq 0; then
639 if test $header -eq 0; then
649 dnl # SPL_CHECK_HEADER
650 dnl # check whether header exists and define HAVE_$2_HEADER
652 AC_DEFUN([SPL_CHECK_HEADER],
653 [AC_MSG_CHECKING([whether header $1 exists])
654 SPL_LINUX_TRY_COMPILE([
659 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
669 dnl # Basic toolchain sanity check. Verify that kernel modules can
670 dnl # be built and which symbols can be used.
672 AC_DEFUN([SPL_AC_TEST_MODULE],
673 [AC_MSG_CHECKING([whether modules can be built])
674 SPL_LINUX_TRY_COMPILE([],[],[
678 if test "x$enable_linux_builtin" != xyes; then
679 AC_MSG_ERROR([*** Unable to build an empty module.])
682 *** Unable to build an empty module.
683 *** Please run 'make scripts' inside the kernel source tree.])
687 AS_IF([test "x$cross_compiling" != xyes], [
690 #include "$LINUX/include/linux/license.h"
692 return !license_is_gpl_compatible(
693 "$SPL_META_LICENSE");
696 AC_DEFINE([SPL_IS_GPL_COMPATIBLE], [1],
697 [Define to 1 if GPL-only symbols can be used])
704 dnl # Use the atomic implemenation based on global spinlocks. This
705 dnl # should only be needed by 32-bit kernels which do not provide
706 dnl # the atomic64_* API. It may be optionally enabled as a fallback
707 dnl # if problems are observed with the direct mapping to the native
708 dnl # Linux atomic operations. You may not disable atomic spinlocks
709 dnl # if you kernel does not an atomic64_* API.
711 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
712 AC_ARG_ENABLE([atomic-spinlocks],
713 [AS_HELP_STRING([--enable-atomic-spinlocks],
714 [Atomic types use spinlocks @<:@default=check@:>@])],
716 [enable_atomic_spinlocks=check])
718 SPL_LINUX_TRY_COMPILE([
719 #include <linux/fs.h>
721 atomic64_t *ptr __attribute__ ((unused));
724 AC_DEFINE(HAVE_ATOMIC64_T, 1,
725 [kernel defines atomic64_t])
730 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
731 AS_IF([test "x$have_atomic64_t" = xyes], [
732 enable_atomic_spinlocks=no
734 enable_atomic_spinlocks=yes
738 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
739 AC_DEFINE([ATOMIC_SPINLOCK], [1],
740 [Atomic types use spinlocks])
742 AS_IF([test "x$have_atomic64_t" = xno], [
744 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
748 AC_MSG_CHECKING([whether atomic types use spinlocks])
749 AC_MSG_RESULT([$enable_atomic_spinlocks])
751 AC_MSG_CHECKING([whether kernel defines atomic64_t])
752 AC_MSG_RESULT([$have_atomic64_t])
755 AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[
756 tmp_flags="$EXTRA_KCFLAGS"
757 EXTRA_KCFLAGS="-Werror"
759 dnl # 2.6.23 to 2.6.34 API change
760 dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask)
762 AC_MSG_CHECKING([whether old 2-argument shrinker exists])
763 SPL_LINUX_TRY_COMPILE([
764 #include <linux/mm.h>
766 int shrinker_cb(int nr_to_scan, gfp_t gfp_mask);
768 struct shrinker cache_shrinker = {
769 .shrink = shrinker_cb,
770 .seeks = DEFAULT_SEEKS,
772 register_shrinker(&cache_shrinker);
775 AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1,
776 [old shrinker callback wants 2 args])
780 dnl # 2.6.35 - 2.6.39 API change
781 dnl # ->shrink(struct shrinker *,
782 dnl # int nr_to_scan, gfp_t gfp_mask)
784 AC_MSG_CHECKING([whether old 3-argument shrinker exists])
785 SPL_LINUX_TRY_COMPILE([
786 #include <linux/mm.h>
788 int shrinker_cb(struct shrinker *, int nr_to_scan,
791 struct shrinker cache_shrinker = {
792 .shrink = shrinker_cb,
793 .seeks = DEFAULT_SEEKS,
795 register_shrinker(&cache_shrinker);
798 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
799 [old shrinker callback wants 3 args])
803 dnl # 3.0 - 3.11 API change
804 dnl # ->shrink(struct shrinker *,
805 dnl # struct shrink_control *sc)
808 [whether new 2-argument shrinker exists])
809 SPL_LINUX_TRY_COMPILE([
810 #include <linux/mm.h>
812 int shrinker_cb(struct shrinker *,
813 struct shrink_control *sc);
815 struct shrinker cache_shrinker = {
816 .shrink = shrinker_cb,
817 .seeks = DEFAULT_SEEKS,
819 register_shrinker(&cache_shrinker);
822 AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1,
823 [new shrinker callback wants 2 args])
827 dnl # 3.12 API change,
828 dnl # ->shrink() is logically split in to
829 dnl # ->count_objects() and ->scan_objects()
832 [whether ->count_objects callback exists])
833 SPL_LINUX_TRY_COMPILE([
834 #include <linux/mm.h>
836 unsigned long shrinker_cb(
838 struct shrink_control *sc);
840 struct shrinker cache_shrinker = {
841 .count_objects = shrinker_cb,
842 .scan_objects = shrinker_cb,
843 .seeks = DEFAULT_SEEKS,
845 register_shrinker(&cache_shrinker);
848 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
849 1, [->count_objects exists])
856 EXTRA_KCFLAGS="$tmp_flags"
860 dnl # 2.6.33 API change,
861 dnl # Removed .ctl_name from struct ctl_table.
863 AC_DEFUN([SPL_AC_CTL_NAME], [
864 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
865 SPL_LINUX_TRY_COMPILE([
866 #include <linux/sysctl.h>
868 struct ctl_table ctl __attribute__ ((unused));
872 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
879 dnl # 3.10 API change,
880 dnl # PDE is replaced by PDE_DATA
882 AC_DEFUN([SPL_AC_PDE_DATA], [
883 AC_MSG_CHECKING([whether PDE_DATA() is available])
884 SPL_LINUX_TRY_COMPILE_SYMBOL([
885 #include <linux/proc_fs.h>
890 AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
898 dnl # set_fs_pwd takes const struct path *
900 AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
901 tmp_flags="$EXTRA_KCFLAGS"
902 EXTRA_KCFLAGS="-Werror"
903 [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
904 SPL_LINUX_TRY_COMPILE([
905 #include <linux/spinlock.h>
906 #include <linux/fs_struct.h>
907 #include <linux/path.h>
908 void (*const set_fs_pwd_func)
909 (struct fs_struct *, const struct path *)
915 AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
916 [set_fs_pwd() needs const path *])
918 SPL_LINUX_TRY_COMPILE([
919 #include <linux/spinlock.h>
920 #include <linux/fs_struct.h>
921 #include <linux/path.h>
922 void (*const set_fs_pwd_func)
923 (struct fs_struct *, struct path *)
930 AC_MSG_ERROR(unknown)
933 EXTRA_KCFLAGS="$tmp_flags"
937 dnl # 3.13 API change
938 dnl # vfs_unlink() updated to take a third delegated_inode argument.
940 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
941 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
942 SPL_LINUX_TRY_COMPILE([
943 #include <linux/fs.h>
945 vfs_unlink((struct inode *) NULL, (struct dentry *) NULL);
948 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
949 [vfs_unlink() wants 2 args])
953 dnl # Linux 3.13 API change
954 dnl # Added delegated inode
956 AC_MSG_CHECKING([whether vfs_unlink() wants 3 args])
957 SPL_LINUX_TRY_COMPILE([
958 #include <linux/fs.h>
960 vfs_unlink((struct inode *) NULL,
961 (struct dentry *) NULL,
962 (struct inode **) NULL);
965 AC_DEFINE(HAVE_3ARGS_VFS_UNLINK, 1,
966 [vfs_unlink() wants 3 args])
975 dnl # 3.13 and 3.15 API changes
976 dnl # Added delegated inode and flags argument.
978 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
979 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
980 SPL_LINUX_TRY_COMPILE([
981 #include <linux/fs.h>
983 vfs_rename((struct inode *) NULL, (struct dentry *) NULL,
984 (struct inode *) NULL, (struct dentry *) NULL);
987 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
988 [vfs_rename() wants 4 args])
992 dnl # Linux 3.13 API change
993 dnl # Added delegated inode
995 AC_MSG_CHECKING([whether vfs_rename() wants 5 args])
996 SPL_LINUX_TRY_COMPILE([
997 #include <linux/fs.h>
999 vfs_rename((struct inode *) NULL,
1000 (struct dentry *) NULL,
1001 (struct inode *) NULL,
1002 (struct dentry *) NULL,
1003 (struct inode **) NULL);
1006 AC_DEFINE(HAVE_5ARGS_VFS_RENAME, 1,
1007 [vfs_rename() wants 5 args])
1011 dnl # Linux 3.15 API change
1014 AC_MSG_CHECKING([whether vfs_rename() wants 6 args])
1015 SPL_LINUX_TRY_COMPILE([
1016 #include <linux/fs.h>
1018 vfs_rename((struct inode *) NULL,
1019 (struct dentry *) NULL,
1020 (struct inode *) NULL,
1021 (struct dentry *) NULL,
1022 (struct inode **) NULL,
1026 AC_DEFINE(HAVE_6ARGS_VFS_RENAME, 1,
1027 [vfs_rename() wants 6 args])
1036 dnl # 2.6.36 API change,
1037 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1038 dnl # a spinlock_t to improve the fastpath performance.
1040 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1041 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1042 tmp_flags="$EXTRA_KCFLAGS"
1043 EXTRA_KCFLAGS="-Werror"
1044 SPL_LINUX_TRY_COMPILE([
1045 #include <linux/sched.h>
1046 #include <linux/fs_struct.h>
1048 static struct fs_struct fs;
1049 spin_lock_init(&fs.lock);
1052 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1053 [struct fs_struct uses spinlock_t])
1057 EXTRA_KCFLAGS="$tmp_flags"
1061 dnl # User namespaces, use kuid_t in place of uid_t
1062 dnl # where available. Not strictly a user namespaces thing
1063 dnl # but it should prevent surprises
1065 AC_DEFUN([SPL_AC_KUIDGID_T], [
1066 AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
1067 SPL_LINUX_TRY_COMPILE([
1068 #include <linux/uidgid.h>
1070 kuid_t userid = KUIDT_INIT(0);
1071 kgid_t groupid = KGIDT_INIT(0);
1073 SPL_LINUX_TRY_COMPILE([
1074 #include <linux/uidgid.h>
1079 AC_MSG_RESULT(yes; optional)
1081 AC_MSG_RESULT(yes; mandatory)
1082 AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
1090 dnl # 2.6.35 API change,
1091 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
1093 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
1094 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
1095 SPL_LINUX_TRY_COMPILE([
1096 #include <linux/fs.h>
1101 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
1108 dnl # 3.5 API change,
1109 dnl # inode_operations.truncate_range removed
1111 AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
1112 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
1113 SPL_LINUX_TRY_COMPILE([
1114 #include <linux/fs.h>
1116 struct inode_operations ops;
1117 ops.truncate_range = NULL;
1120 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
1121 [truncate_range() inode operation is available])
1128 dnl # Linux 2.6.38 - 3.x API
1130 AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
1131 AC_MSG_CHECKING([whether fops->fallocate() exists])
1132 SPL_LINUX_TRY_COMPILE([
1133 #include <linux/fs.h>
1135 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1136 struct file_operations fops __attribute__ ((unused)) = {
1137 .fallocate = fallocate,
1141 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1148 dnl # Linux 2.6.x - 2.6.37 API
1150 AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
1151 AC_MSG_CHECKING([whether iops->fallocate() exists])
1152 SPL_LINUX_TRY_COMPILE([
1153 #include <linux/fs.h>
1155 long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
1156 struct inode_operations fops __attribute__ ((unused)) = {
1157 .fallocate = fallocate,
1161 AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
1168 dnl # PaX Linux 2.6.38 - 3.x API
1170 AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
1171 AC_MSG_CHECKING([whether fops->fallocate() exists])
1172 SPL_LINUX_TRY_COMPILE([
1173 #include <linux/fs.h>
1175 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1176 struct file_operations_no_const fops __attribute__ ((unused)) = {
1177 .fallocate = fallocate,
1181 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1188 dnl # The fallocate callback was moved from the inode_operations
1189 dnl # structure to the file_operations structure.
1191 AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
1192 SPL_AC_KERNEL_FILE_FALLOCATE
1193 SPL_AC_KERNEL_INODE_FALLOCATE
1194 SPL_AC_PAX_KERNEL_FILE_FALLOCATE
1198 dnl # zlib inflate compat,
1199 dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
1201 AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
1202 AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
1203 SPL_LINUX_TRY_COMPILE([
1204 #if !defined(CONFIG_ZLIB_INFLATE) && \
1205 !defined(CONFIG_ZLIB_INFLATE_MODULE)
1206 #error CONFIG_ZLIB_INFLATE not defined
1209 AC_MSG_RESULT([yes])
1213 *** This kernel does not include the required zlib inflate support.
1214 *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
1219 dnl # zlib deflate compat,
1220 dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
1222 AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
1223 AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
1224 SPL_LINUX_TRY_COMPILE([
1225 #if !defined(CONFIG_ZLIB_DEFLATE) && \
1226 !defined(CONFIG_ZLIB_DEFLATE_MODULE)
1227 #error CONFIG_ZLIB_DEFLATE not defined
1230 AC_MSG_RESULT([yes])
1234 *** This kernel does not include the required zlib deflate support.
1235 *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
1240 dnl # config trim unused symbols,
1241 dnl # Verify the kernel has CONFIG_TRIM_UNUSED_KSYMS DISABLED.
1243 AC_DEFUN([SPL_AC_CONFIG_TRIM_UNUSED_KSYMS], [
1244 AC_MSG_CHECKING([whether CONFIG_TRIM_UNUSED_KSYM is disabled])
1245 SPL_LINUX_TRY_COMPILE([
1246 #if defined(CONFIG_TRIM_UNUSED_KSYMS)
1247 #error CONFIG_TRIM_UNUSED_KSYMS not defined
1250 AC_MSG_RESULT([yes])
1254 *** This kernel has unused symbols trimming enabled, please disable.
1255 *** Rebuild the kernel with CONFIG_TRIM_UNUSED_KSYMS=n set.])
1260 dnl # 2.6.39 API compat,
1261 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
1262 dnl # This was done to avoid always having to allocate the maximum size
1263 dnl # workspace (268K). The caller can now specific the windowBits and
1264 dnl # memLevel compression parameters to get a smaller workspace.
1266 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
1267 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
1268 SPL_LINUX_TRY_COMPILE([
1269 #include <linux/zlib.h>
1271 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
1274 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
1275 [zlib_deflate_workspacesize() wants 2 args])
1282 dnl # 2.6.39 API change,
1283 dnl # Shrinker adjust to use common shrink_control structure.
1285 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
1286 AC_MSG_CHECKING([whether struct shrink_control exists])
1287 SPL_LINUX_TRY_COMPILE([
1288 #include <linux/mm.h>
1290 struct shrink_control sc __attribute__ ((unused));
1293 sc.gfp_mask = GFP_KERNEL;
1296 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
1297 [struct shrink_control exists])
1304 dnl # 3.1 API Change
1306 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
1307 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
1309 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
1310 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
1311 tmp_flags="$EXTRA_KCFLAGS"
1312 EXTRA_KCFLAGS="-Werror"
1313 SPL_LINUX_TRY_COMPILE([
1314 #include <linux/rwsem.h>
1316 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
1317 raw_spinlock_t dummy_lock __attribute__ ((unused)) =
1318 __RAW_SPIN_LOCK_INITIALIZER(dummy_lock);
1319 dummy_semaphore.wait_lock = dummy_lock;
1322 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
1323 [struct rw_semaphore member wait_lock is raw_spinlock_t])
1327 EXTRA_KCFLAGS="$tmp_flags"
1331 dnl # 3.16 API Change
1333 dnl # rwsem-spinlock "->activity" changed to "->count"
1335 AC_DEFUN([SPL_AC_RWSEM_ACTIVITY], [
1336 AC_MSG_CHECKING([whether struct rw_semaphore has member activity])
1337 tmp_flags="$EXTRA_KCFLAGS"
1338 EXTRA_KCFLAGS="-Werror"
1339 SPL_LINUX_TRY_COMPILE([
1340 #include <linux/rwsem.h>
1342 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
1343 dummy_semaphore.activity = 0;
1346 AC_DEFINE(HAVE_RWSEM_ACTIVITY, 1,
1347 [struct rw_semaphore has member activity])
1351 EXTRA_KCFLAGS="$tmp_flags"
1355 dnl # 4.8 API Change
1357 dnl # rwsem "->count" changed to atomic_long_t type
1359 AC_DEFUN([SPL_AC_RWSEM_ATOMIC_LONG_COUNT], [
1361 [whether struct rw_semaphore has atomic_long_t member count])
1362 tmp_flags="$EXTRA_KCFLAGS"
1363 EXTRA_KCFLAGS="-Werror"
1364 SPL_LINUX_TRY_COMPILE([
1365 #include <linux/rwsem.h>
1367 DECLARE_RWSEM(dummy_semaphore);
1368 (void) atomic_long_read(&dummy_semaphore.count);
1371 AC_DEFINE(HAVE_RWSEM_ATOMIC_LONG_COUNT, 1,
1372 [struct rw_semaphore has atomic_long_t member count])
1376 EXTRA_KCFLAGS="$tmp_flags"
1380 dnl # 3.9 API change,
1381 dnl # Moved things from linux/sched.h to linux/sched/rt.h
1383 AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
1384 [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
1385 SPL_LINUX_TRY_COMPILE([
1386 #include <linux/sched.h>
1387 #include <linux/sched/rt.h>
1391 AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
1399 dnl # 4.11 API change,
1400 dnl # Moved things from linux/sched.h to linux/sched/signal.h
1402 AC_DEFUN([SPL_AC_SCHED_SIGNAL_HEADER],
1403 [AC_MSG_CHECKING([whether header linux/sched/signal.h exists])
1404 SPL_LINUX_TRY_COMPILE([
1405 #include <linux/sched.h>
1406 #include <linux/sched/signal.h>
1410 AC_DEFINE(HAVE_SCHED_SIGNAL_HEADER, 1, [linux/sched/signal.h exists])
1418 dnl # 4.11 API, a528d35e@torvalds/linux
1419 dnl # vfs_getattr(const struct path *p, struct kstat *s, u32 m, unsigned int f)
1421 AC_DEFUN([SPL_AC_4ARGS_VFS_GETATTR], [
1422 AC_MSG_CHECKING([whether vfs_getattr() wants 4 args])
1423 SPL_LINUX_TRY_COMPILE([
1424 #include <linux/fs.h>
1426 vfs_getattr((const struct path *)NULL,
1427 (struct kstat *)NULL,
1432 AC_DEFINE(HAVE_4ARGS_VFS_GETATTR, 1,
1433 [vfs_getattr wants 4 args])
1441 dnl # vfs_getattr(struct path *p, struct kstat *s)
1443 AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
1444 AC_MSG_CHECKING([whether vfs_getattr() wants 2 args])
1445 SPL_LINUX_TRY_COMPILE([
1446 #include <linux/fs.h>
1448 vfs_getattr((struct path *) NULL,
1449 (struct kstat *)NULL);
1452 AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
1453 [vfs_getattr wants 2 args])
1461 dnl # vfs_getattr(struct vfsmount *v, struct dentry *d, struct kstat *k)
1463 AC_DEFUN([SPL_AC_3ARGS_VFS_GETATTR], [
1464 AC_MSG_CHECKING([whether vfs_getattr() wants 3 args])
1465 SPL_LINUX_TRY_COMPILE([
1466 #include <linux/fs.h>
1468 vfs_getattr((struct vfsmount *)NULL,
1469 (struct dentry *)NULL,
1470 (struct kstat *)NULL);
1473 AC_DEFINE(HAVE_3ARGS_VFS_GETATTR, 1,
1474 [vfs_getattr wants 3 args])
1481 dnl # 2.6.36 API compatibility.
1482 dnl # Added usleep_range timer.
1483 dnl # usleep_range is a finer precision implementation of msleep
1484 dnl # designed to be a drop-in replacement for udelay where a precise
1485 dnl # sleep / busy-wait is unnecessary.
1487 AC_DEFUN([SPL_AC_USLEEP_RANGE], [
1488 AC_MSG_CHECKING([whether usleep_range() is available])
1489 SPL_LINUX_TRY_COMPILE([
1490 #include <linux/delay.h>
1495 AC_DEFINE(HAVE_USLEEP_RANGE, 1,
1496 [usleep_range is available])
1503 dnl # 2.6.35 API change,
1504 dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are
1505 dnl # private allocation flags which are applied when allocating a new slab
1506 dnl # in kmem_getpages(). Unfortunately there is no public API for setting
1507 dnl # non-default flags.
1509 AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [
1510 AC_MSG_CHECKING([whether struct kmem_cache has allocflags])
1511 SPL_LINUX_TRY_COMPILE([
1512 #include <linux/slab.h>
1514 struct kmem_cache cachep __attribute__ ((unused));
1515 cachep.allocflags = GFP_KERNEL;
1518 AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1,
1519 [struct kmem_cache has allocflags])
1523 AC_MSG_CHECKING([whether struct kmem_cache has gfpflags])
1524 SPL_LINUX_TRY_COMPILE([
1525 #include <linux/slab.h>
1527 struct kmem_cache cachep __attribute__ ((unused));
1528 cachep.gfpflags = GFP_KERNEL;
1531 AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1,
1532 [struct kmem_cache has gfpflags])
1540 dnl # 3.17 API change,
1541 dnl # wait_on_bit() no longer requires an action argument. The former
1542 dnl # "wait_on_bit" interface required an 'action' function to be provided
1543 dnl # which does the actual waiting. There were over 20 such functions in the
1544 dnl # kernel, many of them identical, though most cases can be satisfied by one
1545 dnl # of just two functions: one which uses io_schedule() and one which just
1546 dnl # uses schedule(). This API change was made to consolidate all of those
1547 dnl # redundant wait functions.
1549 AC_DEFUN([SPL_AC_WAIT_ON_BIT], [
1550 AC_MSG_CHECKING([whether wait_on_bit() takes an action])
1551 SPL_LINUX_TRY_COMPILE([
1552 #include <linux/wait.h>
1554 int (*action)(void *) = NULL;
1555 wait_on_bit(NULL, 0, action, 0);
1558 AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes])
1565 dnl # 4.7 API change
1566 dnl # i_mutex is changed to i_rwsem. Instead of directly using
1567 dnl # i_mutex/i_rwsem, we should use inode_lock() and inode_lock_shared()
1568 dnl # We test inode_lock_shared because inode_lock is introduced earlier.
1570 AC_DEFUN([SPL_AC_INODE_LOCK], [
1571 AC_MSG_CHECKING([whether inode_lock_shared() exists])
1572 tmp_flags="$EXTRA_KCFLAGS"
1573 EXTRA_KCFLAGS="-Werror"
1574 SPL_LINUX_TRY_COMPILE([
1575 #include <linux/fs.h>
1577 struct inode *inode = NULL;
1578 inode_lock_shared(inode);
1581 AC_DEFINE(HAVE_INODE_LOCK_SHARED, 1, [yes])
1585 EXTRA_KCFLAGS="$tmp_flags"
1589 dnl # 4.9 API change
1590 dnl # group_info changed from 2d array via >blocks to 1d array via ->gid
1592 AC_DEFUN([SPL_AC_GROUP_INFO_GID], [
1593 AC_MSG_CHECKING([whether group_info->gid exists])
1594 tmp_flags="$EXTRA_KCFLAGS"
1595 EXTRA_KCFLAGS="-Werror"
1596 SPL_LINUX_TRY_COMPILE([
1597 #include <linux/cred.h>
1599 struct group_info *gi = groups_alloc(1);
1600 gi->gid[0] = KGIDT_INIT(0);
1603 AC_DEFINE(HAVE_GROUP_INFO_GID, 1, [group_info->gid exists])
1607 EXTRA_KCFLAGS="$tmp_flags"
1611 dnl # grsecurity API change,
1612 dnl # kmem_cache_create() with SLAB_USERCOPY flag replaced by
1613 dnl # kmem_cache_create_usercopy().
1615 AC_DEFUN([SPL_AC_KMEM_CACHE_CREATE_USERCOPY], [
1616 AC_MSG_CHECKING([whether kmem_cache_create_usercopy() exists])
1617 tmp_flags="$EXTRA_KCFLAGS"
1618 EXTRA_KCFLAGS="-Werror"
1619 SPL_LINUX_TRY_COMPILE([
1620 #include <linux/slab.h>
1621 static void ctor(void *foo)
1626 struct kmem_cache *skc_linux_cache;
1627 const char *name = "test";
1630 unsigned long flags = 0;
1631 size_t useroffset = 0;
1632 size_t usersize = size - useroffset;
1634 skc_linux_cache = kmem_cache_create_usercopy(
1635 name, size, align, flags, useroffset, usersize, ctor);
1638 AC_DEFINE(HAVE_KMEM_CACHE_CREATE_USERCOPY, 1,
1639 [kmem_cache_create_usercopy() exists])
1643 EXTRA_KCFLAGS="$tmp_flags"
1647 dnl # 4.13 API change
1648 dnl # Renamed struct wait_queue -> struct wait_queue_entry.
1650 AC_DEFUN([SPL_AC_WAIT_QUEUE_ENTRY_T], [
1651 AC_MSG_CHECKING([whether wait_queue_entry_t exists])
1652 SPL_LINUX_TRY_COMPILE([
1653 #include <linux/wait.h>
1655 wait_queue_entry_t *entry __attribute__ ((unused));
1658 AC_DEFINE(HAVE_WAIT_QUEUE_ENTRY_T, 1,
1659 [wait_queue_entry_t exists])
1666 dnl # 4.13 API change
1667 dnl # Renamed wait_queue_head::task_list -> wait_queue_head::head
1668 dnl # Renamed wait_queue_entry::task_list -> wait_queue_entry::entry
1670 AC_DEFUN([SPL_AC_WAIT_QUEUE_HEAD_ENTRY], [
1671 AC_MSG_CHECKING([whether wq_head->head and wq_entry->entry exist])
1672 SPL_LINUX_TRY_COMPILE([
1673 #include <linux/wait.h>
1675 #ifdef HAVE_WAIT_QUEUE_ENTRY_T
1676 typedef wait_queue_head_t spl_wait_queue_head_t;
1677 typedef wait_queue_entry_t spl_wait_queue_entry_t;
1679 typedef wait_queue_head_t spl_wait_queue_head_t;
1680 typedef wait_queue_t spl_wait_queue_entry_t;
1683 spl_wait_queue_head_t wq_head;
1684 spl_wait_queue_entry_t wq_entry;
1685 struct list_head *head __attribute__ ((unused));
1686 struct list_head *entry __attribute__ ((unused));
1688 head = &wq_head.head;
1689 entry = &wq_entry.entry;
1692 AC_DEFINE(HAVE_WAIT_QUEUE_HEAD_ENTRY, 1,
1693 [wq_head->head and wq_entry->entry exist])