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
28 SPL_AC_SET_FS_PWD_WITH_CONST
29 SPL_AC_2ARGS_VFS_UNLINK
30 SPL_AC_4ARGS_VFS_RENAME
31 SPL_AC_2ARGS_VFS_FSYNC
32 SPL_AC_INODE_TRUNCATE_RANGE
33 SPL_AC_FS_STRUCT_SPINLOCK
35 SPL_AC_PUT_TASK_STRUCT
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_SCHED_RT_HEADER
44 SPL_AC_2ARGS_VFS_GETATTR
46 SPL_AC_KMEM_CACHE_ALLOCFLAGS
52 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
53 modpost=$LINUX/scripts/Makefile.modpost
54 AC_MSG_CHECKING([kernel file name for module symbols])
55 if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
56 if grep -q Modules.symvers $modpost; then
57 LINUX_SYMBOLS=Modules.symvers
59 LINUX_SYMBOLS=Module.symvers
62 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
64 *** Please make sure the kernel devel package for your distribution
65 *** is installed. If you are building with a custom kernel, make sure the
66 *** kernel is configured, built, and the '--with-linux=PATH' configure
67 *** option refers to the location of the kernel source.])
72 AC_MSG_RESULT($LINUX_SYMBOLS)
73 AC_SUBST(LINUX_SYMBOLS)
76 AC_DEFUN([SPL_AC_KERNEL], [
78 AS_HELP_STRING([--with-linux=PATH],
79 [Path to kernel source]),
80 [kernelsrc="$withval"])
82 AC_ARG_WITH([linux-obj],
83 AS_HELP_STRING([--with-linux-obj=PATH],
84 [Path to kernel build objects]),
85 [kernelbuild="$withval"])
87 AC_MSG_CHECKING([kernel source directory])
88 if test -z "$kernelsrc"; then
89 if test -e "/lib/modules/$(uname -r)/source"; then
90 headersdir="/lib/modules/$(uname -r)/source"
91 sourcelink=$(readlink -f "$headersdir")
92 elif test -e "/lib/modules/$(uname -r)/build"; then
93 headersdir="/lib/modules/$(uname -r)/build"
94 sourcelink=$(readlink -f "$headersdir")
96 sourcelink=$(ls -1d /usr/src/kernels/* \
98 2>/dev/null | grep -v obj | tail -1)
101 if test -n "$sourcelink" && test -e ${sourcelink}; then
102 kernelsrc=`readlink -f ${sourcelink}`
104 kernelsrc="[Not found]"
107 if test "$kernelsrc" = "NONE"; then
112 AC_MSG_RESULT([$kernelsrc])
113 if test ! -d "$kernelsrc"; then
115 *** Please make sure the kernel devel package for your distribution
116 *** is installed and then try again. If that fails, you can specify the
117 *** location of the kernel source with the '--with-linux=PATH' option.])
120 AC_MSG_CHECKING([kernel build directory])
121 if test -z "$kernelbuild"; then
122 if test -e "/lib/modules/$(uname -r)/build"; then
123 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
124 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
125 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
126 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
127 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
128 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
129 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
131 kernelbuild=${kernelsrc}
134 AC_MSG_RESULT([$kernelbuild])
136 AC_MSG_CHECKING([kernel source version])
137 utsrelease1=$kernelbuild/include/linux/version.h
138 utsrelease2=$kernelbuild/include/linux/utsrelease.h
139 utsrelease3=$kernelbuild/include/generated/utsrelease.h
140 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
141 utsrelease=linux/version.h
142 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
143 utsrelease=linux/utsrelease.h
144 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
145 utsrelease=generated/utsrelease.h
148 if test "$utsrelease"; then
149 kernsrcver=`(echo "#include <$utsrelease>";
150 echo "kernsrcver=UTS_RELEASE") |
151 cpp -I $kernelbuild/include |
152 grep "^kernsrcver=" | cut -d \" -f 2`
154 if test -z "$kernsrcver"; then
155 AC_MSG_RESULT([Not found])
156 AC_MSG_ERROR([*** Cannot determine kernel version.])
159 AC_MSG_RESULT([Not found])
160 if test "x$enable_linux_builtin" != xyes; then
161 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
164 *** Cannot find UTS_RELEASE definition.
165 *** Please run 'make prepare' inside the kernel source tree.])
169 AC_MSG_RESULT([$kernsrcver])
172 LINUX_OBJ=${kernelbuild}
173 LINUX_VERSION=${kernsrcver}
177 AC_SUBST(LINUX_VERSION)
179 SPL_AC_MODULE_SYMVERS
183 dnl # Default SPL user configuration
185 AC_DEFUN([SPL_AC_CONFIG_USER], [])
188 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
189 dnl # are missing, it is non-fatal, but you will not be able to build
190 dnl # RPM packages and will be warned if you try too.
192 dnl # By default, the generic spec file will be used because it requires
193 dnl # minimal dependencies. Distribution specific spec files can be
194 dnl # placed under the 'rpm/<distribution>' directory and enabled using
195 dnl # the --with-spec=<distribution> configure option.
197 AC_DEFUN([SPL_AC_RPM], [
201 AC_MSG_CHECKING([whether $RPM is available])
202 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
203 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
205 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
208 AC_MSG_RESULT([$HAVE_RPM])
211 AC_MSG_CHECKING([whether $RPMBUILD is available])
212 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
213 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
215 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
218 AC_MSG_RESULT([$HAVE_RPMBUILD])
221 RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"'
223 RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
226 SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
231 RPM_SPEC_DIR="rpm/generic"
233 AS_HELP_STRING([--with-spec=SPEC],
234 [Spec files 'generic|redhat']),
235 [RPM_SPEC_DIR="rpm/$withval"])
237 AC_MSG_CHECKING([whether spec files are available])
238 AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
242 AC_SUBST(RPM_VERSION)
244 AC_SUBST(HAVE_RPMBUILD)
246 AC_SUBST(RPMBUILD_VERSION)
248 AC_SUBST(RPM_SPEC_DIR)
249 AC_SUBST(RPM_DEFINE_UTIL)
250 AC_SUBST(RPM_DEFINE_KMOD)
251 AC_SUBST(RPM_DEFINE_DKMS)
252 AC_SUBST(RPM_DEFINE_COMMON)
253 AC_SUBST(SRPM_DEFINE_UTIL)
254 AC_SUBST(SRPM_DEFINE_KMOD)
255 AC_SUBST(SRPM_DEFINE_DKMS)
256 AC_SUBST(SRPM_DEFINE_COMMON)
260 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
261 dnl # tools are missing it is non-fatal but you will not be able to build
262 dnl # DEB packages and will be warned if you try too.
264 AC_DEFUN([SPL_AC_DPKG], [
266 DPKGBUILD=dpkg-buildpackage
268 AC_MSG_CHECKING([whether $DPKG is available])
269 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
270 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
272 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
275 AC_MSG_RESULT([$HAVE_DPKG])
278 AC_MSG_CHECKING([whether $DPKGBUILD is available])
279 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
280 DPKGBUILD_VERSION=$(echo $tmp | \
281 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
283 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
286 AC_MSG_RESULT([$HAVE_DPKGBUILD])
291 AC_SUBST(DPKG_VERSION)
293 AC_SUBST(HAVE_DPKGBUILD)
295 AC_SUBST(DPKGBUILD_VERSION)
299 dnl # Until native packaging for various different packing systems
300 dnl # can be added the least we can do is attempt to use alien to
301 dnl # convert the RPM packages to the needed package type. This is
302 dnl # a hack but so far it has worked reasonable well.
304 AC_DEFUN([SPL_AC_ALIEN], [
307 AC_MSG_CHECKING([whether $ALIEN is available])
308 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
309 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
311 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
314 AC_MSG_RESULT([$HAVE_ALIEN])
319 AC_SUBST(ALIEN_VERSION)
323 dnl # Using the VENDOR tag from config.guess set the default
324 dnl # package type for 'make pkg': (rpm | deb | tgz)
326 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
327 AC_MSG_CHECKING([linux distribution])
328 if test -f /etc/toss-release ; then
330 elif test -f /etc/fedora-release ; then
332 elif test -f /etc/redhat-release ; then
334 elif test -f /etc/gentoo-release ; then
336 elif test -f /etc/arch-release ; then
338 elif test -f /etc/SuSE-release ; then
340 elif test -f /etc/slackware-version ; then
342 elif test -f /etc/lunar.release ; then
344 elif test -f /etc/lsb-release ; then
346 elif test -f /etc/debian_version ; then
351 AC_MSG_RESULT([$VENDOR])
354 AC_MSG_CHECKING([default package type])
356 toss) DEFAULT_PACKAGE=rpm ;;
357 redhat) DEFAULT_PACKAGE=rpm ;;
358 fedora) DEFAULT_PACKAGE=rpm ;;
359 gentoo) DEFAULT_PACKAGE=tgz ;;
360 arch) DEFAULT_PACKAGE=tgz ;;
361 sles) DEFAULT_PACKAGE=rpm ;;
362 slackware) DEFAULT_PACKAGE=tgz ;;
363 lunar) DEFAULT_PACKAGE=tgz ;;
364 ubuntu) DEFAULT_PACKAGE=deb ;;
365 debian) DEFAULT_PACKAGE=deb ;;
366 *) DEFAULT_PACKAGE=rpm ;;
369 AC_MSG_RESULT([$DEFAULT_PACKAGE])
370 AC_SUBST(DEFAULT_PACKAGE)
374 dnl # Default SPL user configuration
376 AC_DEFUN([SPL_AC_PACKAGE], [
377 SPL_AC_DEFAULT_PACKAGE
383 AC_DEFUN([SPL_AC_LICENSE], [
384 AC_MSG_CHECKING([spl author])
385 AC_MSG_RESULT([$SPL_META_AUTHOR])
387 AC_MSG_CHECKING([spl license])
388 AC_MSG_RESULT([$SPL_META_LICENSE])
391 AC_DEFUN([SPL_AC_CONFIG], [
393 AC_ARG_WITH([config],
394 AS_HELP_STRING([--with-config=CONFIG],
395 [Config file 'kernel|user|all|srpm']),
396 [SPL_CONFIG="$withval"])
397 AC_ARG_ENABLE([linux-builtin],
398 [AC_HELP_STRING([--enable-linux-builtin],
399 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
401 [enable_linux_builtin=no])
403 AC_MSG_CHECKING([spl config])
404 AC_MSG_RESULT([$SPL_CONFIG]);
407 case "$SPL_CONFIG" in
408 kernel) SPL_AC_CONFIG_KERNEL ;;
409 user) SPL_AC_CONFIG_USER ;;
410 all) SPL_AC_CONFIG_KERNEL
411 SPL_AC_CONFIG_USER ;;
414 AC_MSG_RESULT([Error!])
415 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
416 user kernel|user|all|srpm]) ;;
419 AM_CONDITIONAL([CONFIG_USER],
420 [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
421 AM_CONDITIONAL([CONFIG_KERNEL],
422 [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
423 [test "x$enable_linux_builtin" != xyes ])
427 dnl # Enable if the SPL should be compiled with internal debugging enabled.
428 dnl # By default this support is disabled.
430 AC_DEFUN([SPL_AC_DEBUG], [
431 AC_MSG_CHECKING([whether debugging is enabled])
432 AC_ARG_ENABLE([debug],
433 [AS_HELP_STRING([--enable-debug],
434 [Enable generic debug support @<:@default=no@:>@])],
438 AS_IF([test "x$enable_debug" = xyes],
440 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
441 DEBUG_CFLAGS="-DDEBUG -Werror"
442 DEBUG_SPL="_with_debug"
444 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
445 DEBUG_CFLAGS="-DNDEBUG"
446 DEBUG_SPL="_without_debug"
449 AC_SUBST(DEBUG_CFLAGS)
451 AC_MSG_RESULT([$enable_debug])
455 dnl # Enabled by default it provides a minimal level of memory tracking.
456 dnl # A total count of bytes allocated is kept for each alloc and free.
457 dnl # Then at module unload time a report to the console will be printed
458 dnl # if memory was leaked.
460 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
461 AC_ARG_ENABLE([debug-kmem],
462 [AS_HELP_STRING([--enable-debug-kmem],
463 [Enable basic kmem accounting @<:@default=no@:>@])],
465 [enable_debug_kmem=no])
467 AS_IF([test "x$enable_debug_kmem" = xyes],
469 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
470 DEBUG_KMEM="_with_debug_kmem"
471 AC_DEFINE([DEBUG_KMEM], [1],
472 [Define to 1 to enable basic kmem accounting])
474 DEBUG_KMEM="_without_debug_kmem"
478 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
479 AC_MSG_RESULT([$enable_debug_kmem])
483 dnl # Disabled by default it provides detailed memory tracking. This
484 dnl # feature also requires --enable-debug-kmem to be set. When enabled
485 dnl # not only will total bytes be tracked but also the location of every
486 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
487 dnl # addresses and where they were allocated will be dumped to the console.
488 dnl # Enabling this feature has a significant impact on performance but it
489 dnl # makes finding memory leaks pretty straight forward.
491 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
492 AC_ARG_ENABLE([debug-kmem-tracking],
493 [AS_HELP_STRING([--enable-debug-kmem-tracking],
494 [Enable detailed kmem tracking @<:@default=no@:>@])],
496 [enable_debug_kmem_tracking=no])
498 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
500 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
501 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
502 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
503 [Define to 1 to enable detailed kmem tracking])
505 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
508 AC_SUBST(DEBUG_KMEM_TRACKING)
509 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
510 AC_MSG_RESULT([$enable_debug_kmem_tracking])
514 dnl # SPL_LINUX_CONFTEST
516 AC_DEFUN([SPL_LINUX_CONFTEST], [
517 cat confdefs.h - <<_ACEOF >conftest.c
523 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
525 m4_define([SPL_LANG_PROGRAM], [
530 dnl Do *not* indent the following line: there may be CPP directives.
531 dnl Don't move the `;' right after for the same reason.
539 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
541 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
542 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
543 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
544 echo "obj-m := conftest.o" >build/Makefile
546 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
548 [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])],
550 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
556 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
558 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
559 [SPL_LINUX_COMPILE_IFELSE(
560 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
562 [test -s build/conftest.o],
567 dnl # SPL_CHECK_SYMBOL_EXPORT
568 dnl # check symbol exported or not
570 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
571 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
572 $LINUX_OBJ/Module*.symvers 2>/dev/null
574 if test $rc -ne 0; then
577 grep -q -E "EXPORT_SYMBOL.*($1)" \
578 "$LINUX_OBJ/$file" 2>/dev/null
580 if test $rc -eq 0; then
585 if test $export -eq 0; then :
596 dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
597 dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
598 dnl # is called if not compiling for builtin
600 AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
601 SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
602 if test $rc -ne 0; then :
605 if test "x$enable_linux_builtin" != xyes; then
606 SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
608 if test $rc -ne 0; then :
617 dnl # SPL_CHECK_SYMBOL_HEADER
618 dnl # check if a symbol prototype is defined in listed headers.
620 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
621 AC_MSG_CHECKING([whether symbol $1 exists in header])
624 grep -q "$2" "$LINUX/$file" 2>/dev/null
626 if test $rc -eq 0; then
631 if test $header -eq 0; then
641 dnl # SPL_CHECK_HEADER
642 dnl # check whether header exists and define HAVE_$2_HEADER
644 AC_DEFUN([SPL_CHECK_HEADER],
645 [AC_MSG_CHECKING([whether header $1 exists])
646 SPL_LINUX_TRY_COMPILE([
651 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
661 dnl # Basic toolchain sanity check. Verify that kernel modules can
662 dnl # be built and which symbols can be used.
664 AC_DEFUN([SPL_AC_TEST_MODULE],
665 [AC_MSG_CHECKING([whether modules can be built])
666 SPL_LINUX_TRY_COMPILE([],[],[
670 if test "x$enable_linux_builtin" != xyes; then
671 AC_MSG_ERROR([*** Unable to build an empty module.])
674 *** Unable to build an empty module.
675 *** Please run 'make scripts' inside the kernel source tree.])
679 AS_IF([test "x$cross_compiling" != xyes], [
682 #include "$LINUX/include/linux/license.h"
684 return !license_is_gpl_compatible(
685 "$SPL_META_LICENSE");
688 AC_DEFINE([SPL_IS_GPL_COMPATIBLE], [1],
689 [Define to 1 if GPL-only symbols can be used])
696 dnl # Use the atomic implemenation based on global spinlocks. This
697 dnl # should only be needed by 32-bit kernels which do not provide
698 dnl # the atomic64_* API. It may be optionally enabled as a fallback
699 dnl # if problems are observed with the direct mapping to the native
700 dnl # Linux atomic operations. You may not disable atomic spinlocks
701 dnl # if you kernel does not an atomic64_* API.
703 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
704 AC_ARG_ENABLE([atomic-spinlocks],
705 [AS_HELP_STRING([--enable-atomic-spinlocks],
706 [Atomic types use spinlocks @<:@default=check@:>@])],
708 [enable_atomic_spinlocks=check])
710 SPL_LINUX_TRY_COMPILE([
711 #include <linux/fs.h>
713 atomic64_t *ptr __attribute__ ((unused));
716 AC_DEFINE(HAVE_ATOMIC64_T, 1,
717 [kernel defines atomic64_t])
722 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
723 AS_IF([test "x$have_atomic64_t" = xyes], [
724 enable_atomic_spinlocks=no
726 enable_atomic_spinlocks=yes
730 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
731 AC_DEFINE([ATOMIC_SPINLOCK], [1],
732 [Atomic types use spinlocks])
734 AS_IF([test "x$have_atomic64_t" = xno], [
736 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
740 AC_MSG_CHECKING([whether atomic types use spinlocks])
741 AC_MSG_RESULT([$enable_atomic_spinlocks])
743 AC_MSG_CHECKING([whether kernel defines atomic64_t])
744 AC_MSG_RESULT([$have_atomic64_t])
747 AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[
748 tmp_flags="$EXTRA_KCFLAGS"
749 EXTRA_KCFLAGS="-Werror"
751 dnl # 2.6.23 to 2.6.34 API change
752 dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask)
754 AC_MSG_CHECKING([whether old 2-argument shrinker exists])
755 SPL_LINUX_TRY_COMPILE([
756 #include <linux/mm.h>
758 int shrinker_cb(int nr_to_scan, gfp_t gfp_mask);
760 struct shrinker cache_shrinker = {
761 .shrink = shrinker_cb,
762 .seeks = DEFAULT_SEEKS,
764 register_shrinker(&cache_shrinker);
767 AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1,
768 [old shrinker callback wants 2 args])
772 dnl # 2.6.35 - 2.6.39 API change
773 dnl # ->shrink(struct shrinker *,
774 dnl # int nr_to_scan, gfp_t gfp_mask)
776 AC_MSG_CHECKING([whether old 3-argument shrinker exists])
777 SPL_LINUX_TRY_COMPILE([
778 #include <linux/mm.h>
780 int shrinker_cb(struct shrinker *, int nr_to_scan,
783 struct shrinker cache_shrinker = {
784 .shrink = shrinker_cb,
785 .seeks = DEFAULT_SEEKS,
787 register_shrinker(&cache_shrinker);
790 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
791 [old shrinker callback wants 3 args])
795 dnl # 3.0 - 3.11 API change
796 dnl # ->shrink(struct shrinker *,
797 dnl # struct shrink_control *sc)
800 [whether new 2-argument shrinker exists])
801 SPL_LINUX_TRY_COMPILE([
802 #include <linux/mm.h>
804 int shrinker_cb(struct shrinker *,
805 struct shrink_control *sc);
807 struct shrinker cache_shrinker = {
808 .shrink = shrinker_cb,
809 .seeks = DEFAULT_SEEKS,
811 register_shrinker(&cache_shrinker);
814 AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1,
815 [new shrinker callback wants 2 args])
819 dnl # 3.12 API change,
820 dnl # ->shrink() is logically split in to
821 dnl # ->count_objects() and ->scan_objects()
824 [whether ->count_objects callback exists])
825 SPL_LINUX_TRY_COMPILE([
826 #include <linux/mm.h>
828 unsigned long shrinker_cb(
830 struct shrink_control *sc);
832 struct shrinker cache_shrinker = {
833 .count_objects = shrinker_cb,
834 .scan_objects = shrinker_cb,
835 .seeks = DEFAULT_SEEKS,
837 register_shrinker(&cache_shrinker);
840 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
841 1, [->count_objects exists])
848 EXTRA_KCFLAGS="$tmp_flags"
852 dnl # 2.6.33 API change,
853 dnl # Removed .ctl_name from struct ctl_table.
855 AC_DEFUN([SPL_AC_CTL_NAME], [
856 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
857 SPL_LINUX_TRY_COMPILE([
858 #include <linux/sysctl.h>
860 struct ctl_table ctl __attribute__ ((unused));
864 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
871 dnl # 3.10 API change,
872 dnl # PDE is replaced by PDE_DATA
874 AC_DEFUN([SPL_AC_PDE_DATA], [
875 AC_MSG_CHECKING([whether PDE_DATA() is available])
876 SPL_LINUX_TRY_COMPILE_SYMBOL([
877 #include <linux/proc_fs.h>
882 AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
890 dnl # set_fs_pwd takes const struct path *
892 AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
893 tmp_flags="$EXTRA_KCFLAGS"
894 EXTRA_KCFLAGS="-Werror"
895 [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
896 SPL_LINUX_TRY_COMPILE([
897 #include <linux/spinlock.h>
898 #include <linux/fs_struct.h>
899 #include <linux/path.h>
900 void (*const set_fs_pwd_func)
901 (struct fs_struct *, const struct path *)
907 AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
908 [set_fs_pwd() needs const path *])
910 SPL_LINUX_TRY_COMPILE([
911 #include <linux/spinlock.h>
912 #include <linux/fs_struct.h>
913 #include <linux/path.h>
914 void (*const set_fs_pwd_func)
915 (struct fs_struct *, struct path *)
922 AC_MSG_ERROR(unknown)
925 EXTRA_KCFLAGS="$tmp_flags"
929 dnl # 3.13 API change
930 dnl # vfs_unlink() updated to take a third delegated_inode argument.
932 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
933 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
934 SPL_LINUX_TRY_COMPILE([
935 #include <linux/fs.h>
937 vfs_unlink((struct inode *) NULL, (struct dentry *) NULL);
940 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
941 [vfs_unlink() wants 2 args])
945 dnl # Linux 3.13 API change
946 dnl # Added delegated inode
948 AC_MSG_CHECKING([whether vfs_unlink() wants 3 args])
949 SPL_LINUX_TRY_COMPILE([
950 #include <linux/fs.h>
952 vfs_unlink((struct inode *) NULL,
953 (struct dentry *) NULL,
954 (struct inode **) NULL);
957 AC_DEFINE(HAVE_3ARGS_VFS_UNLINK, 1,
958 [vfs_unlink() wants 3 args])
967 dnl # 3.13 and 3.15 API changes
968 dnl # Added delegated inode and flags argument.
970 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
971 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
972 SPL_LINUX_TRY_COMPILE([
973 #include <linux/fs.h>
975 vfs_rename((struct inode *) NULL, (struct dentry *) NULL,
976 (struct inode *) NULL, (struct dentry *) NULL);
979 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
980 [vfs_rename() wants 4 args])
984 dnl # Linux 3.13 API change
985 dnl # Added delegated inode
987 AC_MSG_CHECKING([whether vfs_rename() wants 5 args])
988 SPL_LINUX_TRY_COMPILE([
989 #include <linux/fs.h>
991 vfs_rename((struct inode *) NULL,
992 (struct dentry *) NULL,
993 (struct inode *) NULL,
994 (struct dentry *) NULL,
995 (struct inode **) NULL);
998 AC_DEFINE(HAVE_5ARGS_VFS_RENAME, 1,
999 [vfs_rename() wants 5 args])
1003 dnl # Linux 3.15 API change
1006 AC_MSG_CHECKING([whether vfs_rename() wants 6 args])
1007 SPL_LINUX_TRY_COMPILE([
1008 #include <linux/fs.h>
1010 vfs_rename((struct inode *) NULL,
1011 (struct dentry *) NULL,
1012 (struct inode *) NULL,
1013 (struct dentry *) NULL,
1014 (struct inode **) NULL,
1018 AC_DEFINE(HAVE_6ARGS_VFS_RENAME, 1,
1019 [vfs_rename() wants 6 args])
1028 dnl # 2.6.36 API change,
1029 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1030 dnl # a spinlock_t to improve the fastpath performance.
1032 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1033 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1034 tmp_flags="$EXTRA_KCFLAGS"
1035 EXTRA_KCFLAGS="-Werror"
1036 SPL_LINUX_TRY_COMPILE([
1037 #include <linux/sched.h>
1038 #include <linux/fs_struct.h>
1040 static struct fs_struct fs;
1041 spin_lock_init(&fs.lock);
1044 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1045 [struct fs_struct uses spinlock_t])
1049 EXTRA_KCFLAGS="$tmp_flags"
1053 dnl # User namespaces, use kuid_t in place of uid_t
1054 dnl # where available. Not strictly a user namespaces thing
1055 dnl # but it should prevent surprises
1057 AC_DEFUN([SPL_AC_KUIDGID_T], [
1058 AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
1059 SPL_LINUX_TRY_COMPILE([
1060 #include <linux/uidgid.h>
1062 kuid_t userid = KUIDT_INIT(0);
1063 kgid_t groupid = KGIDT_INIT(0);
1065 SPL_LINUX_TRY_COMPILE([
1066 #include <linux/uidgid.h>
1071 AC_MSG_RESULT(yes; optional)
1073 AC_MSG_RESULT(yes; mandatory)
1074 AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
1082 dnl # 2.6.39 API change,
1083 dnl # __put_task_struct() was exported by the mainline kernel.
1085 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT],
1086 [AC_MSG_CHECKING([whether __put_task_struct() is available])
1087 SPL_LINUX_TRY_COMPILE_SYMBOL([
1088 #include <linux/sched.h>
1090 __put_task_struct(NULL);
1091 ], [__put_task_struct], [], [
1093 AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1094 [__put_task_struct() is available])
1101 dnl # 2.6.35 API change,
1102 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
1104 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
1105 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
1106 SPL_LINUX_TRY_COMPILE([
1107 #include <linux/fs.h>
1112 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
1119 dnl # 3.5 API change,
1120 dnl # inode_operations.truncate_range removed
1122 AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
1123 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
1124 SPL_LINUX_TRY_COMPILE([
1125 #include <linux/fs.h>
1127 struct inode_operations ops;
1128 ops.truncate_range = NULL;
1131 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
1132 [truncate_range() inode operation is available])
1139 dnl # Linux 2.6.38 - 3.x API
1141 AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
1142 AC_MSG_CHECKING([whether fops->fallocate() exists])
1143 SPL_LINUX_TRY_COMPILE([
1144 #include <linux/fs.h>
1146 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1147 struct file_operations fops __attribute__ ((unused)) = {
1148 .fallocate = fallocate,
1152 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1159 dnl # Linux 2.6.x - 2.6.37 API
1161 AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
1162 AC_MSG_CHECKING([whether iops->fallocate() exists])
1163 SPL_LINUX_TRY_COMPILE([
1164 #include <linux/fs.h>
1166 long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
1167 struct inode_operations fops __attribute__ ((unused)) = {
1168 .fallocate = fallocate,
1172 AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
1179 dnl # PaX Linux 2.6.38 - 3.x API
1181 AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
1182 AC_MSG_CHECKING([whether fops->fallocate() exists])
1183 SPL_LINUX_TRY_COMPILE([
1184 #include <linux/fs.h>
1186 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1187 struct file_operations_no_const fops __attribute__ ((unused)) = {
1188 .fallocate = fallocate,
1192 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1199 dnl # The fallocate callback was moved from the inode_operations
1200 dnl # structure to the file_operations structure.
1202 AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
1203 SPL_AC_KERNEL_FILE_FALLOCATE
1204 SPL_AC_KERNEL_INODE_FALLOCATE
1205 SPL_AC_PAX_KERNEL_FILE_FALLOCATE
1209 dnl # zlib inflate compat,
1210 dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
1212 AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
1213 AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
1214 SPL_LINUX_TRY_COMPILE([
1215 #if !defined(CONFIG_ZLIB_INFLATE) && \
1216 !defined(CONFIG_ZLIB_INFLATE_MODULE)
1217 #error CONFIG_ZLIB_INFLATE not defined
1220 AC_MSG_RESULT([yes])
1224 *** This kernel does not include the required zlib inflate support.
1225 *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
1230 dnl # zlib deflate compat,
1231 dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
1233 AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
1234 AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
1235 SPL_LINUX_TRY_COMPILE([
1236 #if !defined(CONFIG_ZLIB_DEFLATE) && \
1237 !defined(CONFIG_ZLIB_DEFLATE_MODULE)
1238 #error CONFIG_ZLIB_DEFLATE not defined
1241 AC_MSG_RESULT([yes])
1245 *** This kernel does not include the required zlib deflate support.
1246 *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
1251 dnl # 2.6.39 API compat,
1252 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
1253 dnl # This was done to avoid always having to allocate the maximum size
1254 dnl # workspace (268K). The caller can now specific the windowBits and
1255 dnl # memLevel compression parameters to get a smaller workspace.
1257 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
1258 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
1259 SPL_LINUX_TRY_COMPILE([
1260 #include <linux/zlib.h>
1262 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
1265 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
1266 [zlib_deflate_workspacesize() wants 2 args])
1273 dnl # 2.6.39 API change,
1274 dnl # Shrinker adjust to use common shrink_control structure.
1276 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
1277 AC_MSG_CHECKING([whether struct shrink_control exists])
1278 SPL_LINUX_TRY_COMPILE([
1279 #include <linux/mm.h>
1281 struct shrink_control sc __attribute__ ((unused));
1284 sc.gfp_mask = GFP_KERNEL;
1287 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
1288 [struct shrink_control exists])
1295 dnl # 3.1 API Change
1297 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
1298 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
1300 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
1301 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
1302 tmp_flags="$EXTRA_KCFLAGS"
1303 EXTRA_KCFLAGS="-Werror"
1304 SPL_LINUX_TRY_COMPILE([
1305 #include <linux/rwsem.h>
1307 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
1308 raw_spinlock_t dummy_lock __attribute__ ((unused));
1309 dummy_semaphore.wait_lock = dummy_lock;
1312 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
1313 [struct rw_semaphore member wait_lock is raw_spinlock_t])
1317 EXTRA_KCFLAGS="$tmp_flags"
1321 dnl # 3.16 API Change
1323 dnl # rwsem-spinlock "->activity" changed to "->count"
1325 AC_DEFUN([SPL_AC_RWSEM_ACTIVITY], [
1326 AC_MSG_CHECKING([whether struct rw_semaphore has member activity])
1327 tmp_flags="$EXTRA_KCFLAGS"
1328 EXTRA_KCFLAGS="-Werror"
1329 SPL_LINUX_TRY_COMPILE([
1330 #include <linux/rwsem.h>
1332 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
1333 dummy_semaphore.activity = 0;
1336 AC_DEFINE(HAVE_RWSEM_ACTIVITY, 1,
1337 [struct rw_semaphore has member activity])
1341 EXTRA_KCFLAGS="$tmp_flags"
1345 dnl # 3.9 API change,
1346 dnl # Moved things from linux/sched.h to linux/sched/rt.h
1348 AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
1349 [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
1350 SPL_LINUX_TRY_COMPILE([
1351 #include <linux/sched.h>
1352 #include <linux/sched/rt.h>
1356 AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
1364 dnl # 3.9 API change,
1365 dnl # vfs_getattr() uses 2 args
1366 dnl # It takes struct path * instead of struct vfsmount * and struct dentry *
1368 AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
1369 AC_MSG_CHECKING([whether vfs_getattr() wants])
1370 SPL_LINUX_TRY_COMPILE([
1371 #include <linux/fs.h>
1373 vfs_getattr((struct path *) NULL,
1374 (struct kstat *)NULL);
1376 AC_MSG_RESULT(2 args)
1377 AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
1378 [vfs_getattr wants 2 args])
1380 SPL_LINUX_TRY_COMPILE([
1381 #include <linux/fs.h>
1383 vfs_getattr((struct vfsmount *)NULL,
1384 (struct dentry *)NULL,
1385 (struct kstat *)NULL);
1387 AC_MSG_RESULT(3 args)
1389 AC_MSG_ERROR(unknown)
1395 dnl # 2.6.36 API compatibility.
1396 dnl # Added usleep_range timer.
1397 dnl # usleep_range is a finer precision implementation of msleep
1398 dnl # designed to be a drop-in replacement for udelay where a precise
1399 dnl # sleep / busy-wait is unnecessary.
1401 AC_DEFUN([SPL_AC_USLEEP_RANGE], [
1402 AC_MSG_CHECKING([whether usleep_range() is available])
1403 SPL_LINUX_TRY_COMPILE([
1404 #include <linux/delay.h>
1409 AC_DEFINE(HAVE_USLEEP_RANGE, 1,
1410 [usleep_range is available])
1417 dnl # 2.6.35 API change,
1418 dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are
1419 dnl # private allocation flags which are applied when allocating a new slab
1420 dnl # in kmem_getpages(). Unfortunately there is no public API for setting
1421 dnl # non-default flags.
1423 AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [
1424 AC_MSG_CHECKING([whether struct kmem_cache has allocflags])
1425 SPL_LINUX_TRY_COMPILE([
1426 #include <linux/slab.h>
1428 struct kmem_cache cachep __attribute__ ((unused));
1429 cachep.allocflags = GFP_KERNEL;
1432 AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1,
1433 [struct kmem_cache has allocflags])
1437 AC_MSG_CHECKING([whether struct kmem_cache has gfpflags])
1438 SPL_LINUX_TRY_COMPILE([
1439 #include <linux/slab.h>
1441 struct kmem_cache cachep __attribute__ ((unused));
1442 cachep.gfpflags = GFP_KERNEL;
1445 AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1,
1446 [struct kmem_cache has gfpflags])
1454 dnl # 3.17 API change,
1455 dnl # wait_on_bit() no longer requires an action argument. The former
1456 dnl # "wait_on_bit" interface required an 'action' function to be provided
1457 dnl # which does the actual waiting. There were over 20 such functions in the
1458 dnl # kernel, many of them identical, though most cases can be satisfied by one
1459 dnl # of just two functions: one which uses io_schedule() and one which just
1460 dnl # uses schedule(). This API change was made to consolidate all of those
1461 dnl # redundant wait functions.
1463 AC_DEFUN([SPL_AC_WAIT_ON_BIT], [
1464 AC_MSG_CHECKING([whether wait_on_bit() takes an action])
1465 SPL_LINUX_TRY_COMPILE([
1466 #include <linux/wait.h>
1468 int (*action)(void *) = NULL;
1469 wait_on_bit(NULL, 0, action, 0);
1472 AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes])
1479 dnl # Check whether mutex has owner with task_struct type.
1481 dnl # Note that before Linux 3.0, mutex owner is of type thread_info.
1483 dnl # Note that in Linux 3.18, the condition for owner is changed from
1484 dnl # defined(CONFIG_DEBUG_MUTEXES) || defined(CONFIG_SMP) to
1485 dnl # defined(CONFIG_DEBUG_MUTEXES) || defined(CONFIG_MUTEX_SPIN_ON_OWNER)
1487 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1488 AC_MSG_CHECKING([whether mutex has owner])
1489 tmp_flags="$EXTRA_KCFLAGS"
1490 EXTRA_KCFLAGS="-Werror"
1491 SPL_LINUX_TRY_COMPILE([
1492 #include <linux/mutex.h>
1495 struct task_struct *t __attribute__ ((unused));
1499 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [yes])
1503 EXTRA_KCFLAGS="$tmp_flags"
1507 dnl # 4.7 API change
1508 dnl # i_mutex is changed to i_rwsem. Instead of directly using
1509 dnl # i_mutex/i_rwsem, we should use inode_lock() and inode_lock_shared()
1510 dnl # We test inode_lock_shared because inode_lock is introduced earlier.
1512 AC_DEFUN([SPL_AC_INODE_LOCK], [
1513 AC_MSG_CHECKING([whether inode_lock_shared() exists])
1514 tmp_flags="$EXTRA_KCFLAGS"
1515 EXTRA_KCFLAGS="-Werror"
1516 SPL_LINUX_TRY_COMPILE([
1517 #include <linux/fs.h>
1519 struct inode *inode = NULL;
1520 inode_lock_shared(inode);
1523 AC_DEFINE(HAVE_INODE_LOCK_SHARED, 1, [yes])
1527 EXTRA_KCFLAGS="$tmp_flags"