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
61 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
62 modpost=$LINUX/scripts/Makefile.modpost
63 AC_MSG_CHECKING([kernel file name for module symbols])
64 if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
65 if grep -q Modules.symvers $modpost; then
66 LINUX_SYMBOLS=Modules.symvers
68 LINUX_SYMBOLS=Module.symvers
71 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
73 *** Please make sure the kernel devel package for your distribution
74 *** is installed. If you are building with a custom kernel, make sure the
75 *** kernel is configured, built, and the '--with-linux=PATH' configure
76 *** option refers to the location of the kernel source.])
81 AC_MSG_RESULT($LINUX_SYMBOLS)
82 AC_SUBST(LINUX_SYMBOLS)
85 AC_DEFUN([SPL_AC_KERNEL], [
87 AS_HELP_STRING([--with-linux=PATH],
88 [Path to kernel source]),
89 [kernelsrc="$withval"])
91 AC_ARG_WITH([linux-obj],
92 AS_HELP_STRING([--with-linux-obj=PATH],
93 [Path to kernel build objects]),
94 [kernelbuild="$withval"])
96 AC_MSG_CHECKING([kernel source directory])
97 if test -z "$kernelsrc"; then
98 if test -e "/lib/modules/$(uname -r)/source"; then
99 headersdir="/lib/modules/$(uname -r)/source"
100 sourcelink=$(readlink -f "$headersdir")
101 elif test -e "/lib/modules/$(uname -r)/build"; then
102 headersdir="/lib/modules/$(uname -r)/build"
103 sourcelink=$(readlink -f "$headersdir")
105 sourcelink=$(ls -1d /usr/src/kernels/* \
107 2>/dev/null | grep -v obj | tail -1)
110 if test -n "$sourcelink" && test -e ${sourcelink}; then
111 kernelsrc=`readlink -f ${sourcelink}`
113 kernelsrc="[Not found]"
116 if test "$kernelsrc" = "NONE"; then
122 AC_MSG_RESULT([$kernelsrc])
123 if test ! -d "$kernelsrc"; then
125 *** Please make sure the kernel devel package for your distribution
126 *** is installed and then try again. If that fails, you can specify the
127 *** location of the kernel source with the '--with-linux=PATH' option.])
130 AC_MSG_CHECKING([kernel build directory])
131 if test -z "$kernelbuild"; then
132 if test x$withlinux != xyes -a -e "/lib/modules/$(uname -r)/build"; then
133 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
134 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
135 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
136 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
137 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
138 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
139 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
141 kernelbuild=${kernelsrc}
144 AC_MSG_RESULT([$kernelbuild])
146 AC_MSG_CHECKING([kernel source version])
147 utsrelease1=$kernelbuild/include/linux/version.h
148 utsrelease2=$kernelbuild/include/linux/utsrelease.h
149 utsrelease3=$kernelbuild/include/generated/utsrelease.h
150 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
151 utsrelease=linux/version.h
152 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
153 utsrelease=linux/utsrelease.h
154 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
155 utsrelease=generated/utsrelease.h
158 if test "$utsrelease"; then
159 kernsrcver=`(echo "#include <$utsrelease>";
160 echo "kernsrcver=UTS_RELEASE") |
161 cpp -I $kernelbuild/include |
162 grep "^kernsrcver=" | cut -d \" -f 2`
164 if test -z "$kernsrcver"; then
165 AC_MSG_RESULT([Not found])
166 AC_MSG_ERROR([*** Cannot determine kernel version.])
169 AC_MSG_RESULT([Not found])
170 if test "x$enable_linux_builtin" != xyes; then
171 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
174 *** Cannot find UTS_RELEASE definition.
175 *** Please run 'make prepare' inside the kernel source tree.])
179 AC_MSG_RESULT([$kernsrcver])
182 LINUX_OBJ=${kernelbuild}
183 LINUX_VERSION=${kernsrcver}
187 AC_SUBST(LINUX_VERSION)
189 SPL_AC_MODULE_SYMVERS
193 dnl # Default SPL user configuration
195 AC_DEFUN([SPL_AC_CONFIG_USER], [])
198 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
199 dnl # are missing, it is non-fatal, but you will not be able to build
200 dnl # RPM packages and will be warned if you try too.
202 dnl # By default, the generic spec file will be used because it requires
203 dnl # minimal dependencies. Distribution specific spec files can be
204 dnl # placed under the 'rpm/<distribution>' directory and enabled using
205 dnl # the --with-spec=<distribution> configure option.
207 AC_DEFUN([SPL_AC_RPM], [
211 AC_MSG_CHECKING([whether $RPM is available])
212 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
213 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
215 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
218 AC_MSG_RESULT([$HAVE_RPM])
221 AC_MSG_CHECKING([whether $RPMBUILD is available])
222 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
223 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
225 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
228 AC_MSG_RESULT([$HAVE_RPMBUILD])
231 RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"'
233 RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
236 SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
241 RPM_SPEC_DIR="rpm/generic"
243 AS_HELP_STRING([--with-spec=SPEC],
244 [Spec files 'generic|redhat']),
245 [RPM_SPEC_DIR="rpm/$withval"])
247 AC_MSG_CHECKING([whether spec files are available])
248 AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
252 AC_SUBST(RPM_VERSION)
254 AC_SUBST(HAVE_RPMBUILD)
256 AC_SUBST(RPMBUILD_VERSION)
258 AC_SUBST(RPM_SPEC_DIR)
259 AC_SUBST(RPM_DEFINE_UTIL)
260 AC_SUBST(RPM_DEFINE_KMOD)
261 AC_SUBST(RPM_DEFINE_DKMS)
262 AC_SUBST(RPM_DEFINE_COMMON)
263 AC_SUBST(SRPM_DEFINE_UTIL)
264 AC_SUBST(SRPM_DEFINE_KMOD)
265 AC_SUBST(SRPM_DEFINE_DKMS)
266 AC_SUBST(SRPM_DEFINE_COMMON)
270 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
271 dnl # tools are missing it is non-fatal but you will not be able to build
272 dnl # DEB packages and will be warned if you try too.
274 AC_DEFUN([SPL_AC_DPKG], [
276 DPKGBUILD=dpkg-buildpackage
278 AC_MSG_CHECKING([whether $DPKG is available])
279 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
280 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
282 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
285 AC_MSG_RESULT([$HAVE_DPKG])
288 AC_MSG_CHECKING([whether $DPKGBUILD is available])
289 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
290 DPKGBUILD_VERSION=$(echo $tmp | \
291 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
293 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
296 AC_MSG_RESULT([$HAVE_DPKGBUILD])
301 AC_SUBST(DPKG_VERSION)
303 AC_SUBST(HAVE_DPKGBUILD)
305 AC_SUBST(DPKGBUILD_VERSION)
309 dnl # Until native packaging for various different packing systems
310 dnl # can be added the least we can do is attempt to use alien to
311 dnl # convert the RPM packages to the needed package type. This is
312 dnl # a hack but so far it has worked reasonable well.
314 AC_DEFUN([SPL_AC_ALIEN], [
317 AC_MSG_CHECKING([whether $ALIEN is available])
318 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
319 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
321 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
324 AC_MSG_RESULT([$HAVE_ALIEN])
329 AC_SUBST(ALIEN_VERSION)
333 dnl # Using the VENDOR tag from config.guess set the default
334 dnl # package type for 'make pkg': (rpm | deb | tgz)
336 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
337 AC_MSG_CHECKING([linux distribution])
338 if test -f /etc/toss-release ; then
340 elif test -f /etc/fedora-release ; then
342 elif test -f /etc/redhat-release ; then
344 elif test -f /etc/gentoo-release ; then
346 elif test -f /etc/arch-release ; then
348 elif test -f /etc/SuSE-release ; then
350 elif test -f /etc/slackware-version ; then
352 elif test -f /etc/lunar.release ; then
354 elif test -f /etc/lsb-release ; then
356 elif test -f /etc/debian_version ; then
361 AC_MSG_RESULT([$VENDOR])
364 AC_MSG_CHECKING([default package type])
366 toss) DEFAULT_PACKAGE=rpm ;;
367 redhat) DEFAULT_PACKAGE=rpm ;;
368 fedora) DEFAULT_PACKAGE=rpm ;;
369 gentoo) DEFAULT_PACKAGE=tgz ;;
370 arch) DEFAULT_PACKAGE=tgz ;;
371 sles) DEFAULT_PACKAGE=rpm ;;
372 slackware) DEFAULT_PACKAGE=tgz ;;
373 lunar) DEFAULT_PACKAGE=tgz ;;
374 ubuntu) DEFAULT_PACKAGE=deb ;;
375 debian) DEFAULT_PACKAGE=deb ;;
376 *) DEFAULT_PACKAGE=rpm ;;
379 AC_MSG_RESULT([$DEFAULT_PACKAGE])
380 AC_SUBST(DEFAULT_PACKAGE)
384 dnl # Default SPL user configuration
386 AC_DEFUN([SPL_AC_PACKAGE], [
387 SPL_AC_DEFAULT_PACKAGE
393 AC_DEFUN([SPL_AC_LICENSE], [
394 AC_MSG_CHECKING([spl author])
395 AC_MSG_RESULT([$SPL_META_AUTHOR])
397 AC_MSG_CHECKING([spl license])
398 AC_MSG_RESULT([$SPL_META_LICENSE])
401 AC_DEFUN([SPL_AC_CONFIG], [
403 AC_ARG_WITH([config],
404 AS_HELP_STRING([--with-config=CONFIG],
405 [Config file 'kernel|user|all|srpm']),
406 [SPL_CONFIG="$withval"])
407 AC_ARG_ENABLE([linux-builtin],
408 [AC_HELP_STRING([--enable-linux-builtin],
409 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
411 [enable_linux_builtin=no])
413 AC_MSG_CHECKING([spl config])
414 AC_MSG_RESULT([$SPL_CONFIG]);
417 case "$SPL_CONFIG" in
418 kernel) SPL_AC_CONFIG_KERNEL ;;
419 user) SPL_AC_CONFIG_USER ;;
420 all) SPL_AC_CONFIG_KERNEL
421 SPL_AC_CONFIG_USER ;;
424 AC_MSG_RESULT([Error!])
425 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
426 user kernel|user|all|srpm]) ;;
429 AM_CONDITIONAL([CONFIG_USER],
430 [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
431 AM_CONDITIONAL([CONFIG_KERNEL],
432 [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
433 [test "x$enable_linux_builtin" != xyes ])
437 dnl # Enable if the SPL should be compiled with internal debugging enabled.
438 dnl # By default this support is disabled.
440 AC_DEFUN([SPL_AC_DEBUG], [
441 AC_MSG_CHECKING([whether debugging is enabled])
442 AC_ARG_ENABLE([debug],
443 [AS_HELP_STRING([--enable-debug],
444 [Enable generic debug support @<:@default=no@:>@])],
448 AS_IF([test "x$enable_debug" = xyes],
450 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
451 DEBUG_CFLAGS="-DDEBUG -Werror"
452 DEBUG_SPL="_with_debug"
454 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
455 DEBUG_CFLAGS="-DNDEBUG"
456 DEBUG_SPL="_without_debug"
459 AC_SUBST(DEBUG_CFLAGS)
461 AC_MSG_RESULT([$enable_debug])
465 dnl # Enabled by default it provides a minimal level of memory tracking.
466 dnl # A total count of bytes allocated is kept for each alloc and free.
467 dnl # Then at module unload time a report to the console will be printed
468 dnl # if memory was leaked.
470 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
471 AC_ARG_ENABLE([debug-kmem],
472 [AS_HELP_STRING([--enable-debug-kmem],
473 [Enable basic kmem accounting @<:@default=no@:>@])],
475 [enable_debug_kmem=no])
477 AS_IF([test "x$enable_debug_kmem" = xyes],
479 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
480 DEBUG_KMEM="_with_debug_kmem"
481 AC_DEFINE([DEBUG_KMEM], [1],
482 [Define to 1 to enable basic kmem accounting])
484 DEBUG_KMEM="_without_debug_kmem"
488 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
489 AC_MSG_RESULT([$enable_debug_kmem])
493 dnl # Disabled by default it provides detailed memory tracking. This
494 dnl # feature also requires --enable-debug-kmem to be set. When enabled
495 dnl # not only will total bytes be tracked but also the location of every
496 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
497 dnl # addresses and where they were allocated will be dumped to the console.
498 dnl # Enabling this feature has a significant impact on performance but it
499 dnl # makes finding memory leaks pretty straight forward.
501 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
502 AC_ARG_ENABLE([debug-kmem-tracking],
503 [AS_HELP_STRING([--enable-debug-kmem-tracking],
504 [Enable detailed kmem tracking @<:@default=no@:>@])],
506 [enable_debug_kmem_tracking=no])
508 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
510 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
511 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
512 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
513 [Define to 1 to enable detailed kmem tracking])
515 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
518 AC_SUBST(DEBUG_KMEM_TRACKING)
519 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
520 AC_MSG_RESULT([$enable_debug_kmem_tracking])
524 dnl # SPL_LINUX_CONFTEST
526 AC_DEFUN([SPL_LINUX_CONFTEST], [
527 cat confdefs.h - <<_ACEOF >conftest.c
533 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
535 m4_define([SPL_LANG_PROGRAM], [
540 dnl Do *not* indent the following line: there may be CPP directives.
541 dnl Don't move the `;' right after for the same reason.
549 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
551 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
552 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
553 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
554 echo "obj-m := conftest.o" >build/Makefile
556 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
558 [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])],
560 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
566 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
568 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
569 [SPL_LINUX_COMPILE_IFELSE(
570 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
572 [test -s build/conftest.o],
577 dnl # SPL_CHECK_SYMBOL_EXPORT
578 dnl # check symbol exported or not
580 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
581 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
582 $LINUX_OBJ/Module*.symvers 2>/dev/null
584 if test $rc -ne 0; then
587 grep -q -E "EXPORT_SYMBOL.*($1)" \
588 "$LINUX_OBJ/$file" 2>/dev/null
590 if test $rc -eq 0; then
595 if test $export -eq 0; then :
606 dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
607 dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
608 dnl # is called if not compiling for builtin
610 AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
611 SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
612 if test $rc -ne 0; then :
615 if test "x$enable_linux_builtin" != xyes; then
616 SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
618 if test $rc -ne 0; then :
627 dnl # SPL_CHECK_SYMBOL_HEADER
628 dnl # check if a symbol prototype is defined in listed headers.
630 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
631 AC_MSG_CHECKING([whether symbol $1 exists in header])
634 grep -q "$2" "$LINUX/$file" 2>/dev/null
636 if test $rc -eq 0; then
641 if test $header -eq 0; then
651 dnl # SPL_CHECK_HEADER
652 dnl # check whether header exists and define HAVE_$2_HEADER
654 AC_DEFUN([SPL_CHECK_HEADER],
655 [AC_MSG_CHECKING([whether header $1 exists])
656 SPL_LINUX_TRY_COMPILE([
661 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
671 dnl # Basic toolchain sanity check. Verify that kernel modules can
672 dnl # be built and which symbols can be used.
674 AC_DEFUN([SPL_AC_TEST_MODULE],
675 [AC_MSG_CHECKING([whether modules can be built])
676 SPL_LINUX_TRY_COMPILE([],[],[
680 if test "x$enable_linux_builtin" != xyes; then
681 AC_MSG_ERROR([*** Unable to build an empty module.])
684 *** Unable to build an empty module.
685 *** Please run 'make scripts' inside the kernel source tree.])
689 AS_IF([test "x$cross_compiling" != xyes], [
692 #include "$LINUX/include/linux/license.h"
694 return !license_is_gpl_compatible(
695 "$SPL_META_LICENSE");
698 AC_DEFINE([SPL_IS_GPL_COMPATIBLE], [1],
699 [Define to 1 if GPL-only symbols can be used])
706 dnl # Use the atomic implemenation based on global spinlocks. This
707 dnl # should only be needed by 32-bit kernels which do not provide
708 dnl # the atomic64_* API. It may be optionally enabled as a fallback
709 dnl # if problems are observed with the direct mapping to the native
710 dnl # Linux atomic operations. You may not disable atomic spinlocks
711 dnl # if you kernel does not an atomic64_* API.
713 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
714 AC_ARG_ENABLE([atomic-spinlocks],
715 [AS_HELP_STRING([--enable-atomic-spinlocks],
716 [Atomic types use spinlocks @<:@default=check@:>@])],
718 [enable_atomic_spinlocks=check])
720 SPL_LINUX_TRY_COMPILE([
721 #include <linux/fs.h>
723 atomic64_t *ptr __attribute__ ((unused));
726 AC_DEFINE(HAVE_ATOMIC64_T, 1,
727 [kernel defines atomic64_t])
732 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
733 AS_IF([test "x$have_atomic64_t" = xyes], [
734 enable_atomic_spinlocks=no
736 enable_atomic_spinlocks=yes
740 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
741 AC_DEFINE([ATOMIC_SPINLOCK], [1],
742 [Atomic types use spinlocks])
744 AS_IF([test "x$have_atomic64_t" = xno], [
746 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
750 AC_MSG_CHECKING([whether atomic types use spinlocks])
751 AC_MSG_RESULT([$enable_atomic_spinlocks])
753 AC_MSG_CHECKING([whether kernel defines atomic64_t])
754 AC_MSG_RESULT([$have_atomic64_t])
757 AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[
758 tmp_flags="$EXTRA_KCFLAGS"
759 EXTRA_KCFLAGS="-Werror"
761 dnl # 2.6.23 to 2.6.34 API change
762 dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask)
764 AC_MSG_CHECKING([whether old 2-argument shrinker exists])
765 SPL_LINUX_TRY_COMPILE([
766 #include <linux/mm.h>
768 int shrinker_cb(int nr_to_scan, gfp_t gfp_mask);
770 struct shrinker cache_shrinker = {
771 .shrink = shrinker_cb,
772 .seeks = DEFAULT_SEEKS,
774 register_shrinker(&cache_shrinker);
777 AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1,
778 [old shrinker callback wants 2 args])
782 dnl # 2.6.35 - 2.6.39 API change
783 dnl # ->shrink(struct shrinker *,
784 dnl # int nr_to_scan, gfp_t gfp_mask)
786 AC_MSG_CHECKING([whether old 3-argument shrinker exists])
787 SPL_LINUX_TRY_COMPILE([
788 #include <linux/mm.h>
790 int shrinker_cb(struct shrinker *, int nr_to_scan,
793 struct shrinker cache_shrinker = {
794 .shrink = shrinker_cb,
795 .seeks = DEFAULT_SEEKS,
797 register_shrinker(&cache_shrinker);
800 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
801 [old shrinker callback wants 3 args])
805 dnl # 3.0 - 3.11 API change
806 dnl # ->shrink(struct shrinker *,
807 dnl # struct shrink_control *sc)
810 [whether new 2-argument shrinker exists])
811 SPL_LINUX_TRY_COMPILE([
812 #include <linux/mm.h>
814 int shrinker_cb(struct shrinker *,
815 struct shrink_control *sc);
817 struct shrinker cache_shrinker = {
818 .shrink = shrinker_cb,
819 .seeks = DEFAULT_SEEKS,
821 register_shrinker(&cache_shrinker);
824 AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1,
825 [new shrinker callback wants 2 args])
829 dnl # 3.12 API change,
830 dnl # ->shrink() is logically split in to
831 dnl # ->count_objects() and ->scan_objects()
834 [whether ->count_objects callback exists])
835 SPL_LINUX_TRY_COMPILE([
836 #include <linux/mm.h>
838 unsigned long shrinker_cb(
840 struct shrink_control *sc);
842 struct shrinker cache_shrinker = {
843 .count_objects = shrinker_cb,
844 .scan_objects = shrinker_cb,
845 .seeks = DEFAULT_SEEKS,
847 register_shrinker(&cache_shrinker);
850 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
851 1, [->count_objects exists])
858 EXTRA_KCFLAGS="$tmp_flags"
862 dnl # 2.6.33 API change,
863 dnl # Removed .ctl_name from struct ctl_table.
865 AC_DEFUN([SPL_AC_CTL_NAME], [
866 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
867 SPL_LINUX_TRY_COMPILE([
868 #include <linux/sysctl.h>
870 struct ctl_table ctl __attribute__ ((unused));
874 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
881 dnl # 3.10 API change,
882 dnl # PDE is replaced by PDE_DATA
884 AC_DEFUN([SPL_AC_PDE_DATA], [
885 AC_MSG_CHECKING([whether PDE_DATA() is available])
886 SPL_LINUX_TRY_COMPILE_SYMBOL([
887 #include <linux/proc_fs.h>
892 AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
900 dnl # set_fs_pwd takes const struct path *
902 AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
903 tmp_flags="$EXTRA_KCFLAGS"
904 EXTRA_KCFLAGS="-Werror"
905 [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
906 SPL_LINUX_TRY_COMPILE([
907 #include <linux/spinlock.h>
908 #include <linux/fs_struct.h>
909 #include <linux/path.h>
910 void (*const set_fs_pwd_func)
911 (struct fs_struct *, const struct path *)
917 AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
918 [set_fs_pwd() needs const path *])
920 SPL_LINUX_TRY_COMPILE([
921 #include <linux/spinlock.h>
922 #include <linux/fs_struct.h>
923 #include <linux/path.h>
924 void (*const set_fs_pwd_func)
925 (struct fs_struct *, struct path *)
932 AC_MSG_ERROR(unknown)
935 EXTRA_KCFLAGS="$tmp_flags"
939 dnl # 3.13 API change
940 dnl # vfs_unlink() updated to take a third delegated_inode argument.
942 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
943 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
944 SPL_LINUX_TRY_COMPILE([
945 #include <linux/fs.h>
947 vfs_unlink((struct inode *) NULL, (struct dentry *) NULL);
950 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
951 [vfs_unlink() wants 2 args])
955 dnl # Linux 3.13 API change
956 dnl # Added delegated inode
958 AC_MSG_CHECKING([whether vfs_unlink() wants 3 args])
959 SPL_LINUX_TRY_COMPILE([
960 #include <linux/fs.h>
962 vfs_unlink((struct inode *) NULL,
963 (struct dentry *) NULL,
964 (struct inode **) NULL);
967 AC_DEFINE(HAVE_3ARGS_VFS_UNLINK, 1,
968 [vfs_unlink() wants 3 args])
977 dnl # 3.13 and 3.15 API changes
978 dnl # Added delegated inode and flags argument.
980 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
981 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
982 SPL_LINUX_TRY_COMPILE([
983 #include <linux/fs.h>
985 vfs_rename((struct inode *) NULL, (struct dentry *) NULL,
986 (struct inode *) NULL, (struct dentry *) NULL);
989 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
990 [vfs_rename() wants 4 args])
994 dnl # Linux 3.13 API change
995 dnl # Added delegated inode
997 AC_MSG_CHECKING([whether vfs_rename() wants 5 args])
998 SPL_LINUX_TRY_COMPILE([
999 #include <linux/fs.h>
1001 vfs_rename((struct inode *) NULL,
1002 (struct dentry *) NULL,
1003 (struct inode *) NULL,
1004 (struct dentry *) NULL,
1005 (struct inode **) NULL);
1008 AC_DEFINE(HAVE_5ARGS_VFS_RENAME, 1,
1009 [vfs_rename() wants 5 args])
1013 dnl # Linux 3.15 API change
1016 AC_MSG_CHECKING([whether vfs_rename() wants 6 args])
1017 SPL_LINUX_TRY_COMPILE([
1018 #include <linux/fs.h>
1020 vfs_rename((struct inode *) NULL,
1021 (struct dentry *) NULL,
1022 (struct inode *) NULL,
1023 (struct dentry *) NULL,
1024 (struct inode **) NULL,
1028 AC_DEFINE(HAVE_6ARGS_VFS_RENAME, 1,
1029 [vfs_rename() wants 6 args])
1038 dnl # 2.6.36 API change,
1039 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1040 dnl # a spinlock_t to improve the fastpath performance.
1042 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1043 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1044 tmp_flags="$EXTRA_KCFLAGS"
1045 EXTRA_KCFLAGS="-Werror"
1046 SPL_LINUX_TRY_COMPILE([
1047 #include <linux/sched.h>
1048 #include <linux/fs_struct.h>
1050 static struct fs_struct fs;
1051 spin_lock_init(&fs.lock);
1054 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1055 [struct fs_struct uses spinlock_t])
1059 EXTRA_KCFLAGS="$tmp_flags"
1063 dnl # User namespaces, use kuid_t in place of uid_t
1064 dnl # where available. Not strictly a user namespaces thing
1065 dnl # but it should prevent surprises
1067 AC_DEFUN([SPL_AC_KUIDGID_T], [
1068 AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
1069 SPL_LINUX_TRY_COMPILE([
1070 #include <linux/uidgid.h>
1072 kuid_t userid = KUIDT_INIT(0);
1073 kgid_t groupid = KGIDT_INIT(0);
1075 SPL_LINUX_TRY_COMPILE([
1076 #include <linux/uidgid.h>
1081 AC_MSG_RESULT(yes; optional)
1083 AC_MSG_RESULT(yes; mandatory)
1084 AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
1092 dnl # 2.6.35 API change,
1093 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
1095 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
1096 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
1097 SPL_LINUX_TRY_COMPILE([
1098 #include <linux/fs.h>
1103 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
1110 dnl # 3.5 API change,
1111 dnl # inode_operations.truncate_range removed
1113 AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
1114 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
1115 SPL_LINUX_TRY_COMPILE([
1116 #include <linux/fs.h>
1118 struct inode_operations ops;
1119 ops.truncate_range = NULL;
1122 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
1123 [truncate_range() inode operation is available])
1130 dnl # Linux 2.6.38 - 3.x API
1132 AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
1133 AC_MSG_CHECKING([whether fops->fallocate() exists])
1134 SPL_LINUX_TRY_COMPILE([
1135 #include <linux/fs.h>
1137 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1138 struct file_operations fops __attribute__ ((unused)) = {
1139 .fallocate = fallocate,
1143 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1150 dnl # Linux 2.6.x - 2.6.37 API
1152 AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
1153 AC_MSG_CHECKING([whether iops->fallocate() exists])
1154 SPL_LINUX_TRY_COMPILE([
1155 #include <linux/fs.h>
1157 long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
1158 struct inode_operations fops __attribute__ ((unused)) = {
1159 .fallocate = fallocate,
1163 AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
1170 dnl # PaX Linux 2.6.38 - 3.x API
1172 AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
1173 AC_MSG_CHECKING([whether fops->fallocate() exists])
1174 SPL_LINUX_TRY_COMPILE([
1175 #include <linux/fs.h>
1177 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1178 struct file_operations_no_const fops __attribute__ ((unused)) = {
1179 .fallocate = fallocate,
1183 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1190 dnl # The fallocate callback was moved from the inode_operations
1191 dnl # structure to the file_operations structure.
1193 AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
1194 SPL_AC_KERNEL_FILE_FALLOCATE
1195 SPL_AC_KERNEL_INODE_FALLOCATE
1196 SPL_AC_PAX_KERNEL_FILE_FALLOCATE
1200 dnl # zlib inflate compat,
1201 dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
1203 AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
1204 AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
1205 SPL_LINUX_TRY_COMPILE([
1206 #if !defined(CONFIG_ZLIB_INFLATE) && \
1207 !defined(CONFIG_ZLIB_INFLATE_MODULE)
1208 #error CONFIG_ZLIB_INFLATE not defined
1211 AC_MSG_RESULT([yes])
1215 *** This kernel does not include the required zlib inflate support.
1216 *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
1221 dnl # zlib deflate compat,
1222 dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
1224 AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
1225 AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
1226 SPL_LINUX_TRY_COMPILE([
1227 #if !defined(CONFIG_ZLIB_DEFLATE) && \
1228 !defined(CONFIG_ZLIB_DEFLATE_MODULE)
1229 #error CONFIG_ZLIB_DEFLATE not defined
1232 AC_MSG_RESULT([yes])
1236 *** This kernel does not include the required zlib deflate support.
1237 *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
1242 dnl # config trim unused symbols,
1243 dnl # Verify the kernel has CONFIG_TRIM_UNUSED_KSYMS DISABLED.
1245 AC_DEFUN([SPL_AC_CONFIG_TRIM_UNUSED_KSYMS], [
1246 AC_MSG_CHECKING([whether CONFIG_TRIM_UNUSED_KSYM is disabled])
1247 SPL_LINUX_TRY_COMPILE([
1248 #if defined(CONFIG_TRIM_UNUSED_KSYMS)
1249 #error CONFIG_TRIM_UNUSED_KSYMS not defined
1252 AC_MSG_RESULT([yes])
1256 *** This kernel has unused symbols trimming enabled, please disable.
1257 *** Rebuild the kernel with CONFIG_TRIM_UNUSED_KSYMS=n set.])
1262 dnl # 2.6.39 API compat,
1263 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
1264 dnl # This was done to avoid always having to allocate the maximum size
1265 dnl # workspace (268K). The caller can now specific the windowBits and
1266 dnl # memLevel compression parameters to get a smaller workspace.
1268 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
1269 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
1270 SPL_LINUX_TRY_COMPILE([
1271 #include <linux/zlib.h>
1273 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
1276 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
1277 [zlib_deflate_workspacesize() wants 2 args])
1284 dnl # 2.6.39 API change,
1285 dnl # Shrinker adjust to use common shrink_control structure.
1287 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
1288 AC_MSG_CHECKING([whether struct shrink_control exists])
1289 SPL_LINUX_TRY_COMPILE([
1290 #include <linux/mm.h>
1292 struct shrink_control sc __attribute__ ((unused));
1295 sc.gfp_mask = GFP_KERNEL;
1298 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
1299 [struct shrink_control exists])
1306 dnl # 3.1 API Change
1308 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
1309 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
1311 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
1312 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
1313 tmp_flags="$EXTRA_KCFLAGS"
1314 EXTRA_KCFLAGS="-Werror"
1315 SPL_LINUX_TRY_COMPILE([
1316 #include <linux/rwsem.h>
1318 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
1319 raw_spinlock_t dummy_lock __attribute__ ((unused)) =
1320 __RAW_SPIN_LOCK_INITIALIZER(dummy_lock);
1321 dummy_semaphore.wait_lock = dummy_lock;
1324 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
1325 [struct rw_semaphore member wait_lock is raw_spinlock_t])
1329 EXTRA_KCFLAGS="$tmp_flags"
1333 dnl # 3.16 API Change
1335 dnl # rwsem-spinlock "->activity" changed to "->count"
1337 AC_DEFUN([SPL_AC_RWSEM_ACTIVITY], [
1338 AC_MSG_CHECKING([whether struct rw_semaphore has member activity])
1339 tmp_flags="$EXTRA_KCFLAGS"
1340 EXTRA_KCFLAGS="-Werror"
1341 SPL_LINUX_TRY_COMPILE([
1342 #include <linux/rwsem.h>
1344 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
1345 dummy_semaphore.activity = 0;
1348 AC_DEFINE(HAVE_RWSEM_ACTIVITY, 1,
1349 [struct rw_semaphore has member activity])
1353 EXTRA_KCFLAGS="$tmp_flags"
1357 dnl # 4.8 API Change
1359 dnl # rwsem "->count" changed to atomic_long_t type
1361 AC_DEFUN([SPL_AC_RWSEM_ATOMIC_LONG_COUNT], [
1363 [whether struct rw_semaphore has atomic_long_t member count])
1364 tmp_flags="$EXTRA_KCFLAGS"
1365 EXTRA_KCFLAGS="-Werror"
1366 SPL_LINUX_TRY_COMPILE([
1367 #include <linux/rwsem.h>
1369 DECLARE_RWSEM(dummy_semaphore);
1370 (void) atomic_long_read(&dummy_semaphore.count);
1373 AC_DEFINE(HAVE_RWSEM_ATOMIC_LONG_COUNT, 1,
1374 [struct rw_semaphore has atomic_long_t member count])
1378 EXTRA_KCFLAGS="$tmp_flags"
1382 dnl # 3.9 API change,
1383 dnl # Moved things from linux/sched.h to linux/sched/rt.h
1385 AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
1386 [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
1387 SPL_LINUX_TRY_COMPILE([
1388 #include <linux/sched.h>
1389 #include <linux/sched/rt.h>
1393 AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
1401 dnl # 4.11 API change,
1402 dnl # Moved things from linux/sched.h to linux/sched/signal.h
1404 AC_DEFUN([SPL_AC_SCHED_SIGNAL_HEADER],
1405 [AC_MSG_CHECKING([whether header linux/sched/signal.h exists])
1406 SPL_LINUX_TRY_COMPILE([
1407 #include <linux/sched.h>
1408 #include <linux/sched/signal.h>
1412 AC_DEFINE(HAVE_SCHED_SIGNAL_HEADER, 1, [linux/sched/signal.h exists])
1420 dnl # 4.11 API, a528d35e@torvalds/linux
1421 dnl # vfs_getattr(const struct path *p, struct kstat *s, u32 m, unsigned int f)
1423 AC_DEFUN([SPL_AC_4ARGS_VFS_GETATTR], [
1424 AC_MSG_CHECKING([whether vfs_getattr() wants 4 args])
1425 SPL_LINUX_TRY_COMPILE([
1426 #include <linux/fs.h>
1428 vfs_getattr((const struct path *)NULL,
1429 (struct kstat *)NULL,
1434 AC_DEFINE(HAVE_4ARGS_VFS_GETATTR, 1,
1435 [vfs_getattr wants 4 args])
1443 dnl # vfs_getattr(struct path *p, struct kstat *s)
1445 AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
1446 AC_MSG_CHECKING([whether vfs_getattr() wants 2 args])
1447 SPL_LINUX_TRY_COMPILE([
1448 #include <linux/fs.h>
1450 vfs_getattr((struct path *) NULL,
1451 (struct kstat *)NULL);
1454 AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
1455 [vfs_getattr wants 2 args])
1463 dnl # vfs_getattr(struct vfsmount *v, struct dentry *d, struct kstat *k)
1465 AC_DEFUN([SPL_AC_3ARGS_VFS_GETATTR], [
1466 AC_MSG_CHECKING([whether vfs_getattr() wants 3 args])
1467 SPL_LINUX_TRY_COMPILE([
1468 #include <linux/fs.h>
1470 vfs_getattr((struct vfsmount *)NULL,
1471 (struct dentry *)NULL,
1472 (struct kstat *)NULL);
1475 AC_DEFINE(HAVE_3ARGS_VFS_GETATTR, 1,
1476 [vfs_getattr wants 3 args])
1483 dnl # 2.6.36 API compatibility.
1484 dnl # Added usleep_range timer.
1485 dnl # usleep_range is a finer precision implementation of msleep
1486 dnl # designed to be a drop-in replacement for udelay where a precise
1487 dnl # sleep / busy-wait is unnecessary.
1489 AC_DEFUN([SPL_AC_USLEEP_RANGE], [
1490 AC_MSG_CHECKING([whether usleep_range() is available])
1491 SPL_LINUX_TRY_COMPILE([
1492 #include <linux/delay.h>
1497 AC_DEFINE(HAVE_USLEEP_RANGE, 1,
1498 [usleep_range is available])
1505 dnl # 2.6.35 API change,
1506 dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are
1507 dnl # private allocation flags which are applied when allocating a new slab
1508 dnl # in kmem_getpages(). Unfortunately there is no public API for setting
1509 dnl # non-default flags.
1511 AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [
1512 AC_MSG_CHECKING([whether struct kmem_cache has allocflags])
1513 SPL_LINUX_TRY_COMPILE([
1514 #include <linux/slab.h>
1516 struct kmem_cache cachep __attribute__ ((unused));
1517 cachep.allocflags = GFP_KERNEL;
1520 AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1,
1521 [struct kmem_cache has allocflags])
1525 AC_MSG_CHECKING([whether struct kmem_cache has gfpflags])
1526 SPL_LINUX_TRY_COMPILE([
1527 #include <linux/slab.h>
1529 struct kmem_cache cachep __attribute__ ((unused));
1530 cachep.gfpflags = GFP_KERNEL;
1533 AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1,
1534 [struct kmem_cache has gfpflags])
1542 dnl # 3.17 API change,
1543 dnl # wait_on_bit() no longer requires an action argument. The former
1544 dnl # "wait_on_bit" interface required an 'action' function to be provided
1545 dnl # which does the actual waiting. There were over 20 such functions in the
1546 dnl # kernel, many of them identical, though most cases can be satisfied by one
1547 dnl # of just two functions: one which uses io_schedule() and one which just
1548 dnl # uses schedule(). This API change was made to consolidate all of those
1549 dnl # redundant wait functions.
1551 AC_DEFUN([SPL_AC_WAIT_ON_BIT], [
1552 AC_MSG_CHECKING([whether wait_on_bit() takes an action])
1553 SPL_LINUX_TRY_COMPILE([
1554 #include <linux/wait.h>
1556 int (*action)(void *) = NULL;
1557 wait_on_bit(NULL, 0, action, 0);
1560 AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes])
1567 dnl # 4.7 API change
1568 dnl # i_mutex is changed to i_rwsem. Instead of directly using
1569 dnl # i_mutex/i_rwsem, we should use inode_lock() and inode_lock_shared()
1570 dnl # We test inode_lock_shared because inode_lock is introduced earlier.
1572 AC_DEFUN([SPL_AC_INODE_LOCK], [
1573 AC_MSG_CHECKING([whether inode_lock_shared() exists])
1574 tmp_flags="$EXTRA_KCFLAGS"
1575 EXTRA_KCFLAGS="-Werror"
1576 SPL_LINUX_TRY_COMPILE([
1577 #include <linux/fs.h>
1579 struct inode *inode = NULL;
1580 inode_lock_shared(inode);
1583 AC_DEFINE(HAVE_INODE_LOCK_SHARED, 1, [yes])
1587 EXTRA_KCFLAGS="$tmp_flags"
1591 dnl # 4.9 API change
1592 dnl # group_info changed from 2d array via >blocks to 1d array via ->gid
1594 AC_DEFUN([SPL_AC_GROUP_INFO_GID], [
1595 AC_MSG_CHECKING([whether group_info->gid exists])
1596 tmp_flags="$EXTRA_KCFLAGS"
1597 EXTRA_KCFLAGS="-Werror"
1598 SPL_LINUX_TRY_COMPILE([
1599 #include <linux/cred.h>
1601 struct group_info *gi = groups_alloc(1);
1602 gi->gid[0] = KGIDT_INIT(0);
1605 AC_DEFINE(HAVE_GROUP_INFO_GID, 1, [group_info->gid exists])
1609 EXTRA_KCFLAGS="$tmp_flags"
1613 dnl # grsecurity API change,
1614 dnl # kmem_cache_create() with SLAB_USERCOPY flag replaced by
1615 dnl # kmem_cache_create_usercopy().
1617 AC_DEFUN([SPL_AC_KMEM_CACHE_CREATE_USERCOPY], [
1618 AC_MSG_CHECKING([whether kmem_cache_create_usercopy() exists])
1619 tmp_flags="$EXTRA_KCFLAGS"
1620 EXTRA_KCFLAGS="-Werror"
1621 SPL_LINUX_TRY_COMPILE([
1622 #include <linux/slab.h>
1623 static void ctor(void *foo)
1628 struct kmem_cache *skc_linux_cache;
1629 const char *name = "test";
1632 unsigned long flags = 0;
1633 size_t useroffset = 0;
1634 size_t usersize = size - useroffset;
1636 skc_linux_cache = kmem_cache_create_usercopy(
1637 name, size, align, flags, useroffset, usersize, ctor);
1640 AC_DEFINE(HAVE_KMEM_CACHE_CREATE_USERCOPY, 1,
1641 [kmem_cache_create_usercopy() exists])
1645 EXTRA_KCFLAGS="$tmp_flags"
1649 dnl # 4.13 API change
1650 dnl # Renamed struct wait_queue -> struct wait_queue_entry.
1652 AC_DEFUN([SPL_AC_WAIT_QUEUE_ENTRY_T], [
1653 AC_MSG_CHECKING([whether wait_queue_entry_t exists])
1654 SPL_LINUX_TRY_COMPILE([
1655 #include <linux/wait.h>
1657 wait_queue_entry_t *entry __attribute__ ((unused));
1660 AC_DEFINE(HAVE_WAIT_QUEUE_ENTRY_T, 1,
1661 [wait_queue_entry_t exists])
1668 dnl # 4.13 API change
1669 dnl # Renamed wait_queue_head::task_list -> wait_queue_head::head
1670 dnl # Renamed wait_queue_entry::task_list -> wait_queue_entry::entry
1672 AC_DEFUN([SPL_AC_WAIT_QUEUE_HEAD_ENTRY], [
1673 AC_MSG_CHECKING([whether wq_head->head and wq_entry->entry exist])
1674 SPL_LINUX_TRY_COMPILE([
1675 #include <linux/wait.h>
1677 #ifdef HAVE_WAIT_QUEUE_ENTRY_T
1678 typedef wait_queue_head_t spl_wait_queue_head_t;
1679 typedef wait_queue_entry_t spl_wait_queue_entry_t;
1681 typedef wait_queue_head_t spl_wait_queue_head_t;
1682 typedef wait_queue_t spl_wait_queue_entry_t;
1685 spl_wait_queue_head_t wq_head;
1686 spl_wait_queue_entry_t wq_entry;
1687 struct list_head *head __attribute__ ((unused));
1688 struct list_head *entry __attribute__ ((unused));
1690 head = &wq_head.head;
1691 entry = &wq_entry.entry;
1694 AC_DEFINE(HAVE_WAIT_QUEUE_HEAD_ENTRY, 1,
1695 [wq_head->head and wq_entry->entry exist])
1702 dnl # 4.14 API change
1703 dnl # kernel_write() which was introduced in 3.9 was updated to take
1704 dnl # the offset as a pointer which is needed by vn_rdwr().
1706 AC_DEFUN([SPL_AC_KERNEL_WRITE], [
1707 AC_MSG_CHECKING([whether kernel_write() takes loff_t pointer])
1708 tmp_flags="$EXTRA_KCFLAGS"
1709 EXTRA_KCFLAGS="-Werror"
1710 SPL_LINUX_TRY_COMPILE([
1711 #include <linux/fs.h>
1713 struct file *file = NULL;
1714 const void *buf = NULL;
1719 ret = kernel_write(file, buf, count, pos);
1722 AC_DEFINE(HAVE_KERNEL_WRITE_PPOS, 1,
1723 [kernel_write() take loff_t pointer])
1727 EXTRA_KCFLAGS="$tmp_flags"
1731 dnl # 4.14 API change
1732 dnl # kernel_read() which has existed for forever was updated to take
1733 dnl # the offset as a pointer which is needed by vn_rdwr().
1735 AC_DEFUN([SPL_AC_KERNEL_READ], [
1736 AC_MSG_CHECKING([whether kernel_read() takes loff_t pointer])
1737 tmp_flags="$EXTRA_KCFLAGS"
1738 EXTRA_KCFLAGS="-Werror"
1739 SPL_LINUX_TRY_COMPILE([
1740 #include <linux/fs.h>
1742 struct file *file = NULL;
1748 ret = kernel_read(file, buf, count, pos);
1751 AC_DEFINE(HAVE_KERNEL_READ_PPOS, 1,
1752 [kernel_read() take loff_t pointer])
1756 EXTRA_KCFLAGS="$tmp_flags"