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)
23 SPL_AC_DEBUG_KMEM_TRACKING
25 SPL_AC_ATOMIC_SPINLOCK
26 SPL_AC_SHRINKER_CALLBACK
30 SPL_AC_MUTEX_OWNER_TASK_STRUCT
32 SPL_AC_SET_FS_PWD_WITH_CONST
33 SPL_AC_2ARGS_VFS_UNLINK
34 SPL_AC_4ARGS_VFS_RENAME
36 SPL_AC_2ARGS_VFS_FSYNC
37 SPL_AC_INODE_TRUNCATE_RANGE
38 SPL_AC_FS_STRUCT_SPINLOCK
42 SPL_AC_PUT_TASK_STRUCT
43 SPL_AC_5ARGS_PROC_HANDLER
45 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
46 SPL_AC_KERNEL_FALLOCATE
48 SPL_AC_CONFIG_ZLIB_INFLATE
49 SPL_AC_CONFIG_ZLIB_DEFLATE
50 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
51 SPL_AC_SHRINK_CONTROL_STRUCT
52 SPL_AC_RWSEM_SPINLOCK_IS_RAW
53 SPL_AC_SCHED_RT_HEADER
54 SPL_AC_2ARGS_VFS_GETATTR
56 SPL_AC_KMEM_CACHE_ALLOCFLAGS
60 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
61 modpost=$LINUX/scripts/Makefile.modpost
62 AC_MSG_CHECKING([kernel file name for module symbols])
63 if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
64 if grep -q Modules.symvers $modpost; then
65 LINUX_SYMBOLS=Modules.symvers
67 LINUX_SYMBOLS=Module.symvers
70 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
72 *** Please make sure the kernel devel package for your distribution
73 *** is installed. If you are building with a custom kernel, make sure the
74 *** kernel is configured, built, and the '--with-linux=PATH' configure
75 *** option refers to the location of the kernel source.])
80 AC_MSG_RESULT($LINUX_SYMBOLS)
81 AC_SUBST(LINUX_SYMBOLS)
84 AC_DEFUN([SPL_AC_KERNEL], [
86 AS_HELP_STRING([--with-linux=PATH],
87 [Path to kernel source]),
88 [kernelsrc="$withval"])
90 AC_ARG_WITH([linux-obj],
91 AS_HELP_STRING([--with-linux-obj=PATH],
92 [Path to kernel build objects]),
93 [kernelbuild="$withval"])
95 AC_MSG_CHECKING([kernel source directory])
96 if test -z "$kernelsrc"; then
97 if test -e "/lib/modules/$(uname -r)/source"; then
98 headersdir="/lib/modules/$(uname -r)/source"
99 sourcelink=$(readlink -f "$headersdir")
100 elif test -e "/lib/modules/$(uname -r)/build"; then
101 headersdir="/lib/modules/$(uname -r)/build"
102 sourcelink=$(readlink -f "$headersdir")
104 sourcelink=$(ls -1d /usr/src/kernels/* \
106 2>/dev/null | grep -v obj | tail -1)
109 if test -n "$sourcelink" && test -e ${sourcelink}; then
110 kernelsrc=`readlink -f ${sourcelink}`
112 kernelsrc="[Not found]"
115 if test "$kernelsrc" = "NONE"; then
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 -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_LOG) 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|fedora']),
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 basic debug log infrastructure.
464 dnl # Each subsystem registers itself with a name and logs messages
465 dnl # using predefined types. If the debug mask it set to allow the
466 dnl # message type it will be written to the internal log. The log
467 dnl # can be dumped to a file by echoing 1 to the 'dump' proc entry,
468 dnl # after dumping the log it must be decoded using the spl utility.
470 dnl # echo 1 >/proc/sys/kernel/spl/debug/dump
471 dnl # spl /tmp/spl-log.xxx.yyy /tmp/spl-log.xxx.yyy.txt
473 AC_DEFUN([SPL_AC_DEBUG_LOG], [
474 AC_ARG_ENABLE([debug-log],
475 [AS_HELP_STRING([--enable-debug-log],
476 [Enable basic debug logging @<:@default=yes@:>@])],
478 [enable_debug_log=yes])
480 AS_IF([test "x$enable_debug_log" = xyes],
482 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG"
483 DEBUG_LOG="_with_debug_log"
484 AC_DEFINE([DEBUG_LOG], [1],
485 [Define to 1 to enable basic debug logging])
487 DEBUG_LOG="_without_debug_log"
491 AC_MSG_CHECKING([whether basic debug logging is enabled])
492 AC_MSG_RESULT([$enable_debug_log])
496 dnl # Enabled by default it provides a minimal level of memory tracking.
497 dnl # A total count of bytes allocated is kept for each alloc and free.
498 dnl # Then at module unload time a report to the console will be printed
499 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
500 dnl # and provide an easy way to inspect the kmem based slab.
502 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
503 AC_ARG_ENABLE([debug-kmem],
504 [AS_HELP_STRING([--enable-debug-kmem],
505 [Enable basic kmem accounting @<:@default=yes@:>@])],
507 [enable_debug_kmem=yes])
509 AS_IF([test "x$enable_debug_kmem" = xyes],
511 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
512 DEBUG_KMEM="_with_debug_kmem"
513 AC_DEFINE([DEBUG_KMEM], [1],
514 [Define to 1 to enable basic kmem accounting])
516 DEBUG_KMEM="_without_debug_kmem"
520 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
521 AC_MSG_RESULT([$enable_debug_kmem])
525 dnl # Disabled by default it provides detailed memory tracking. This
526 dnl # feature also requires --enable-debug-kmem to be set. When enabled
527 dnl # not only will total bytes be tracked but also the location of every
528 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
529 dnl # addresses and where they were allocated will be dumped to the console.
530 dnl # Enabling this feature has a significant impact on performance but it
531 dnl # makes finding memory leaks pretty straight forward.
533 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
534 AC_ARG_ENABLE([debug-kmem-tracking],
535 [AS_HELP_STRING([--enable-debug-kmem-tracking],
536 [Enable detailed kmem tracking @<:@default=no@:>@])],
538 [enable_debug_kmem_tracking=no])
540 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
542 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
543 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
544 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
545 [Define to 1 to enable detailed kmem tracking])
547 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
550 AC_SUBST(DEBUG_KMEM_TRACKING)
551 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
552 AC_MSG_RESULT([$enable_debug_kmem_tracking])
556 dnl # SPL_LINUX_CONFTEST
558 AC_DEFUN([SPL_LINUX_CONFTEST], [
559 cat confdefs.h - <<_ACEOF >conftest.c
565 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
567 m4_define([SPL_LANG_PROGRAM], [
572 dnl Do *not* indent the following line: there may be CPP directives.
573 dnl Don't move the `;' right after for the same reason.
581 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
583 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
584 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
585 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
586 echo "obj-m := conftest.o" >build/Makefile
588 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
590 [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])],
592 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
598 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
600 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
601 [SPL_LINUX_COMPILE_IFELSE(
602 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
604 [test -s build/conftest.o],
609 dnl # SPL_CHECK_SYMBOL_EXPORT
610 dnl # check symbol exported or not
612 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
613 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
614 $LINUX_OBJ/Module*.symvers 2>/dev/null
616 if test $rc -ne 0; then
619 grep -q -E "EXPORT_SYMBOL.*($1)" \
620 "$LINUX_OBJ/$file" 2>/dev/null
622 if test $rc -eq 0; then
627 if test $export -eq 0; then :
638 dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
639 dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
640 dnl # is called if not compiling for builtin
642 AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
643 SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
644 if test $rc -ne 0; then :
647 if test "x$enable_linux_builtin" != xyes; then
648 SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
650 if test $rc -ne 0; then :
659 dnl # SPL_CHECK_SYMBOL_HEADER
660 dnl # check if a symbol prototype is defined in listed headers.
662 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
663 AC_MSG_CHECKING([whether symbol $1 exists in header])
666 grep -q "$2" "$LINUX/$file" 2>/dev/null
668 if test $rc -eq 0; then
673 if test $header -eq 0; then
683 dnl # SPL_CHECK_HEADER
684 dnl # check whether header exists and define HAVE_$2_HEADER
686 AC_DEFUN([SPL_CHECK_HEADER],
687 [AC_MSG_CHECKING([whether header $1 exists])
688 SPL_LINUX_TRY_COMPILE([
693 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
703 dnl # Basic toolchain sanity check. Verify that kernel modules can
704 dnl # be built and which symbols can be used.
706 AC_DEFUN([SPL_AC_TEST_MODULE],
707 [AC_MSG_CHECKING([whether modules can be built])
708 SPL_LINUX_TRY_COMPILE([],[],[
712 if test "x$enable_linux_builtin" != xyes; then
713 AC_MSG_ERROR([*** Unable to build an empty module.])
716 *** Unable to build an empty module.
717 *** Please run 'make scripts' inside the kernel source tree.])
723 #include "$LINUX/include/linux/license.h"
725 return !license_is_gpl_compatible("$SPL_META_LICENSE");
728 AC_DEFINE([SPL_IS_GPL_COMPATIBLE], [1],
729 [Define to 1 if GPL-only symbols can be used])
735 dnl # Use the atomic implemenation based on global spinlocks. This
736 dnl # should only be needed by 32-bit kernels which do not provide
737 dnl # the atomic64_* API. It may be optionally enabled as a fallback
738 dnl # if problems are observed with the direct mapping to the native
739 dnl # Linux atomic operations. You may not disable atomic spinlocks
740 dnl # if you kernel does not an atomic64_* API.
742 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
743 AC_ARG_ENABLE([atomic-spinlocks],
744 [AS_HELP_STRING([--enable-atomic-spinlocks],
745 [Atomic types use spinlocks @<:@default=check@:>@])],
747 [enable_atomic_spinlocks=check])
749 SPL_LINUX_TRY_COMPILE([
750 #include <linux/fs.h>
752 atomic64_t *ptr __attribute__ ((unused));
755 AC_DEFINE(HAVE_ATOMIC64_T, 1,
756 [kernel defines atomic64_t])
761 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
762 AS_IF([test "x$have_atomic64_t" = xyes], [
763 enable_atomic_spinlocks=no
765 enable_atomic_spinlocks=yes
769 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
770 AC_DEFINE([ATOMIC_SPINLOCK], [1],
771 [Atomic types use spinlocks])
773 AS_IF([test "x$have_atomic64_t" = xno], [
775 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
779 AC_MSG_CHECKING([whether atomic types use spinlocks])
780 AC_MSG_RESULT([$enable_atomic_spinlocks])
782 AC_MSG_CHECKING([whether kernel defines atomic64_t])
783 AC_MSG_RESULT([$have_atomic64_t])
786 AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[
787 tmp_flags="$EXTRA_KCFLAGS"
788 EXTRA_KCFLAGS="-Werror"
790 dnl # 2.6.23 to 2.6.34 API change
791 dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask)
793 AC_MSG_CHECKING([whether old 2-argument shrinker exists])
794 SPL_LINUX_TRY_COMPILE([
795 #include <linux/mm.h>
797 int shrinker_cb(int nr_to_scan, gfp_t gfp_mask);
799 struct shrinker cache_shrinker = {
800 .shrink = shrinker_cb,
801 .seeks = DEFAULT_SEEKS,
803 register_shrinker(&cache_shrinker);
806 AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1,
807 [old shrinker callback wants 2 args])
811 dnl # 2.6.35 - 2.6.39 API change
812 dnl # ->shrink(struct shrinker *,
813 dnl # int nr_to_scan, gfp_t gfp_mask)
815 AC_MSG_CHECKING([whether old 3-argument shrinker exists])
816 SPL_LINUX_TRY_COMPILE([
817 #include <linux/mm.h>
819 int shrinker_cb(struct shrinker *, int nr_to_scan,
822 struct shrinker cache_shrinker = {
823 .shrink = shrinker_cb,
824 .seeks = DEFAULT_SEEKS,
826 register_shrinker(&cache_shrinker);
829 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
830 [old shrinker callback wants 3 args])
834 dnl # 3.0 - 3.11 API change
835 dnl # ->shrink(struct shrinker *,
836 dnl # struct shrink_control *sc)
839 [whether new 2-argument shrinker exists])
840 SPL_LINUX_TRY_COMPILE([
841 #include <linux/mm.h>
843 int shrinker_cb(struct shrinker *,
844 struct shrink_control *sc);
846 struct shrinker cache_shrinker = {
847 .shrink = shrinker_cb,
848 .seeks = DEFAULT_SEEKS,
850 register_shrinker(&cache_shrinker);
853 AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1,
854 [new shrinker callback wants 2 args])
858 dnl # 3.12 API change,
859 dnl # ->shrink() is logically split in to
860 dnl # ->count_objects() and ->scan_objects()
863 [whether ->count_objects callback exists])
864 SPL_LINUX_TRY_COMPILE([
865 #include <linux/mm.h>
867 unsigned long shrinker_cb(
869 struct shrink_control *sc);
871 struct shrinker cache_shrinker = {
872 .count_objects = shrinker_cb,
873 .scan_objects = shrinker_cb,
874 .seeks = DEFAULT_SEEKS,
876 register_shrinker(&cache_shrinker);
879 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
880 1, [->count_objects exists])
887 EXTRA_KCFLAGS="$tmp_flags"
891 dnl # 2.6.33 API change,
892 dnl # Removed .ctl_name from struct ctl_table.
894 AC_DEFUN([SPL_AC_CTL_NAME], [
895 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
896 SPL_LINUX_TRY_COMPILE([
897 #include <linux/sysctl.h>
899 struct ctl_table ctl __attribute__ ((unused));
903 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
910 dnl # 2.6.29 API change,
911 dnl # Adaptive mutexs were introduced which track the mutex owner. The
912 dnl # mutex wrappers leverage this functionality to avoid tracking the
913 dnl # owner multipe times.
915 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
916 AC_MSG_CHECKING([whether struct mutex has owner])
917 SPL_LINUX_TRY_COMPILE([
918 #include <linux/mutex.h>
920 struct mutex mtx __attribute__ ((unused));
924 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
931 dnl # 2.6.39 API change,
932 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
933 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
934 dnl # was defined. As of 2.6.39 this was changed to a task_struct
935 dnl # pointer which frankly makes a lot more sense.
937 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
938 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
939 tmp_flags="$EXTRA_KCFLAGS"
940 EXTRA_KCFLAGS="-Werror"
941 SPL_LINUX_TRY_COMPILE([
942 #include <linux/mutex.h>
943 #include <linux/sched.h>
945 struct mutex mtx __attribute__ ((unused));
949 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
950 [struct mutex owner is a task_struct])
954 EXTRA_KCFLAGS="$tmp_flags"
958 dnl # 3.10 API change,
959 dnl # PDE is replaced by PDE_DATA
961 AC_DEFUN([SPL_AC_PDE_DATA], [
962 AC_MSG_CHECKING([whether PDE_DATA() is available])
963 SPL_LINUX_TRY_COMPILE_SYMBOL([
964 #include <linux/proc_fs.h>
969 AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
976 dnl # Symbol available in RHEL kernels not in stock kernels.
978 AC_DEFUN([SPL_AC_SET_FS_PWD],
979 [AC_MSG_CHECKING([whether set_fs_pwd() is available])
980 SPL_LINUX_TRY_COMPILE_SYMBOL([
981 #include <linux/spinlock.h>
982 #include <linux/fs_struct.h>
985 ], [set_fs_pwd], [], [
987 AC_DEFINE(HAVE_SET_FS_PWD, 1, [set_fs_pwd() is available])
995 dnl # set_fs_pwd takes const struct path *
997 AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
998 tmp_flags="$EXTRA_KCFLAGS"
999 EXTRA_KCFLAGS="-Werror"
1000 [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
1001 SPL_LINUX_TRY_COMPILE([
1002 #include <linux/spinlock.h>
1003 #include <linux/fs_struct.h>
1004 #include <linux/path.h>
1005 void (*const set_fs_pwd_func)
1006 (struct fs_struct *, const struct path *)
1012 AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
1013 [set_fs_pwd() needs const path *])
1015 SPL_LINUX_TRY_COMPILE([
1016 #include <linux/spinlock.h>
1017 #include <linux/fs_struct.h>
1018 #include <linux/path.h>
1019 void (*const set_fs_pwd_func)
1020 (struct fs_struct *, struct path *)
1027 AC_MSG_ERROR(unknown)
1030 EXTRA_KCFLAGS="$tmp_flags"
1033 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1034 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1035 SPL_LINUX_TRY_COMPILE([
1036 #include <linux/fs.h>
1038 vfs_unlink((struct inode *) NULL, (struct dentry *) NULL);
1041 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1042 [vfs_unlink() wants 2 args])
1046 dnl # Linux 3.13 API change
1047 dnl # Added delegated inode
1049 AC_MSG_CHECKING([whether vfs_unlink() wants 3 args])
1050 SPL_LINUX_TRY_COMPILE([
1051 #include <linux/fs.h>
1053 vfs_unlink((struct inode *) NULL,
1054 (struct dentry *) NULL,
1055 (struct inode **) NULL);
1058 AC_DEFINE(HAVE_3ARGS_VFS_UNLINK, 1,
1059 [vfs_unlink() wants 3 args])
1067 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1068 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1069 SPL_LINUX_TRY_COMPILE([
1070 #include <linux/fs.h>
1072 vfs_rename((struct inode *) NULL, (struct dentry *) NULL,
1073 (struct inode *) NULL, (struct dentry *) NULL);
1076 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1077 [vfs_rename() wants 4 args])
1081 dnl # Linux 3.13 API change
1082 dnl # Added delegated inode
1084 AC_MSG_CHECKING([whether vfs_rename() wants 5 args])
1085 SPL_LINUX_TRY_COMPILE([
1086 #include <linux/fs.h>
1088 vfs_rename((struct inode *) NULL,
1089 (struct dentry *) NULL,
1090 (struct inode *) NULL,
1091 (struct dentry *) NULL,
1092 (struct inode **) NULL);
1095 AC_DEFINE(HAVE_5ARGS_VFS_RENAME, 1,
1096 [vfs_rename() wants 5 args])
1100 dnl # Linux 3.15 API change
1103 AC_MSG_CHECKING([whether vfs_rename() wants 6 args])
1104 SPL_LINUX_TRY_COMPILE([
1105 #include <linux/fs.h>
1107 vfs_rename((struct inode *) NULL,
1108 (struct dentry *) NULL,
1109 (struct inode *) NULL,
1110 (struct dentry *) NULL,
1111 (struct inode **) NULL,
1115 AC_DEFINE(HAVE_6ARGS_VFS_RENAME, 1,
1116 [vfs_rename() wants 6 args])
1125 dnl # 2.6.36 API change,
1126 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1127 dnl # a spinlock_t to improve the fastpath performance.
1129 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1130 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1131 tmp_flags="$EXTRA_KCFLAGS"
1132 EXTRA_KCFLAGS="-Werror"
1133 SPL_LINUX_TRY_COMPILE([
1134 #include <linux/sched.h>
1135 #include <linux/fs_struct.h>
1137 struct fs_struct fs;
1138 spin_lock_init(&fs.lock);
1141 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1142 [struct fs_struct uses spinlock_t])
1146 EXTRA_KCFLAGS="$tmp_flags"
1150 dnl # 2.6.29 API change,
1151 dnl # check whether 'struct cred' exists
1153 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1154 AC_MSG_CHECKING([whether struct cred exists])
1155 SPL_LINUX_TRY_COMPILE([
1156 #include <linux/cred.h>
1158 struct cred *cr __attribute__ ((unused));
1162 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1170 dnl # User namespaces, use kuid_t in place of uid_t
1171 dnl # where available. Not strictly a user namespaces thing
1172 dnl # but it should prevent surprises
1174 AC_DEFUN([SPL_AC_KUIDGID_T], [
1175 AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
1176 SPL_LINUX_TRY_COMPILE([
1177 #include <linux/uidgid.h>
1179 kuid_t userid = KUIDT_INIT(0);
1180 kgid_t groupid = KGIDT_INIT(0);
1182 SPL_LINUX_TRY_COMPILE([
1183 #include <linux/uidgid.h>
1188 AC_MSG_RESULT(yes; optional)
1190 AC_MSG_RESULT(yes; mandatory)
1191 AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
1199 dnl # Custom SPL patch may export this symbol.
1201 AC_DEFUN([SPL_AC_GROUPS_SEARCH],
1202 [AC_MSG_CHECKING([whether groups_search() is available])
1203 SPL_LINUX_TRY_COMPILE_SYMBOL([
1204 #include <linux/cred.h>
1205 #ifdef HAVE_KUIDGID_T
1206 #include <linux/uidgid.h>
1209 #ifdef HAVE_KUIDGID_T
1210 groups_search(NULL, KGIDT_INIT(0));
1212 groups_search(NULL, 0);
1214 ], [groups_search], [], [
1216 AC_DEFINE(HAVE_GROUPS_SEARCH, 1, [groups_search() is available])
1223 dnl # 2.6.x API change,
1224 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1226 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT],
1227 [AC_MSG_CHECKING([whether __put_task_struct() is available])
1228 SPL_LINUX_TRY_COMPILE_SYMBOL([
1229 #include <linux/sched.h>
1231 __put_task_struct(NULL);
1232 ], [__put_task_struct], [], [
1234 AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1235 [__put_task_struct() is available])
1242 dnl # 2.6.32 API change,
1243 dnl # Unused 'struct file *' removed from prototype.
1245 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1246 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1247 SPL_LINUX_TRY_COMPILE([
1248 #include <linux/sysctl.h>
1250 proc_dostring(NULL, 0, NULL, NULL, NULL);
1253 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1254 [proc_handler() wants 5 args])
1261 dnl # 2.6.x API change,
1262 dnl # kvasprintf() function added.
1264 AC_DEFUN([SPL_AC_KVASPRINTF],
1265 [AC_MSG_CHECKING([whether kvasprintf() is available])
1266 SPL_LINUX_TRY_COMPILE_SYMBOL([
1267 #include <linux/kernel.h>
1269 kvasprintf(0, NULL, *((va_list*)NULL));
1270 ], [kvasprintf], [], [
1272 AC_DEFINE(HAVE_KVASPRINTF, 1, [kvasprintf() is available])
1279 dnl # 2.6.29 API change,
1280 dnl # vfs_fsync() funcation added, prior to this use file_fsync().
1282 AC_DEFUN([SPL_AC_VFS_FSYNC],
1283 [AC_MSG_CHECKING([whether vfs_fsync() is available])
1284 SPL_LINUX_TRY_COMPILE_SYMBOL([
1285 #include <linux/fs.h>
1288 ], [vfs_fsync], [fs/sync.c], [
1290 AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])
1297 dnl # 2.6.35 API change,
1298 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
1300 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
1301 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
1302 SPL_LINUX_TRY_COMPILE([
1303 #include <linux/fs.h>
1308 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
1315 dnl # 3.5 API change,
1316 dnl # inode_operations.truncate_range removed
1318 AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
1319 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
1320 SPL_LINUX_TRY_COMPILE([
1321 #include <linux/fs.h>
1323 struct inode_operations ops;
1324 ops.truncate_range = NULL;
1327 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
1328 [truncate_range() inode operation is available])
1335 dnl # Linux 2.6.38 - 3.x API
1337 AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
1338 AC_MSG_CHECKING([whether fops->fallocate() exists])
1339 SPL_LINUX_TRY_COMPILE([
1340 #include <linux/fs.h>
1342 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1343 struct file_operations fops __attribute__ ((unused)) = {
1344 .fallocate = fallocate,
1348 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1355 dnl # Linux 2.6.x - 2.6.37 API
1357 AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
1358 AC_MSG_CHECKING([whether iops->fallocate() exists])
1359 SPL_LINUX_TRY_COMPILE([
1360 #include <linux/fs.h>
1362 long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
1363 struct inode_operations fops __attribute__ ((unused)) = {
1364 .fallocate = fallocate,
1368 AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
1375 dnl # PaX Linux 2.6.38 - 3.x API
1377 AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
1378 AC_MSG_CHECKING([whether fops->fallocate() exists])
1379 SPL_LINUX_TRY_COMPILE([
1380 #include <linux/fs.h>
1382 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1383 struct file_operations_no_const fops __attribute__ ((unused)) = {
1384 .fallocate = fallocate,
1388 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1395 dnl # The fallocate callback was moved from the inode_operations
1396 dnl # structure to the file_operations structure.
1398 AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
1399 SPL_AC_KERNEL_FILE_FALLOCATE
1400 SPL_AC_KERNEL_INODE_FALLOCATE
1401 SPL_AC_PAX_KERNEL_FILE_FALLOCATE
1405 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
1406 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
1407 dnl # condition. The fixed version is exported as a symbol. The race
1408 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
1409 dnl # call that version while holding sem->wait_lock.
1411 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED],
1412 [AC_MSG_CHECKING([whether rwsem_is_locked() acquires sem->wait_lock])
1413 SPL_LINUX_TRY_COMPILE_SYMBOL([
1414 #include <linux/rwsem.h>
1415 int rwsem_is_locked(struct rw_semaphore *sem) { return 0; }
1416 ], [], [rwsem_is_locked], [lib/rwsem-spinlock.c], [
1418 AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
1419 [rwsem_is_locked() acquires sem->wait_lock])
1426 dnl # 2.6.28 API change
1427 dnl # The kern_path() function has been introduced. We adopt it as the new way
1428 dnl # of looking up paths. When it is not available, we emulate it using the
1429 dnl # older interfaces.
1431 AC_DEFUN([SPL_AC_KERN_PATH],
1432 [AC_MSG_CHECKING([whether kern_path() is available])
1433 SPL_LINUX_TRY_COMPILE_SYMBOL([
1434 #include <linux/namei.h>
1436 int r = kern_path(NULL, 0, NULL);
1437 ], [kern_path], [fs/namei.c], [
1439 AC_DEFINE(HAVE_KERN_PATH, 1,
1440 [kern_path() is available])
1443 AC_MSG_CHECKING([whether path_lookup() is available])
1444 SPL_LINUX_TRY_COMPILE_SYMBOL([
1445 #include <linux/namei.h>
1447 int r = path_lookup(NULL, 0, NULL);
1448 ], [path_lookup], [fs/namei.c], [
1450 AC_DEFINE(HAVE_KERN_PATH, 1,
1451 [kern_path() is available])
1455 *** Neither kern_path() nor path_lookup() is available.
1456 *** Please file an issue:
1457 *** https://github.com/zfsonlinux/spl/issues/new])
1464 dnl # zlib inflate compat,
1465 dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
1467 AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
1468 AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
1469 SPL_LINUX_TRY_COMPILE([
1470 #if !defined(CONFIG_ZLIB_INFLATE) && \
1471 !defined(CONFIG_ZLIB_INFLATE_MODULE)
1472 #error CONFIG_ZLIB_INFLATE not defined
1475 AC_MSG_RESULT([yes])
1479 *** This kernel does not include the required zlib inflate support.
1480 *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
1485 dnl # zlib deflate compat,
1486 dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
1488 AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
1489 AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
1490 SPL_LINUX_TRY_COMPILE([
1491 #if !defined(CONFIG_ZLIB_DEFLATE) && \
1492 !defined(CONFIG_ZLIB_DEFLATE_MODULE)
1493 #error CONFIG_ZLIB_DEFLATE not defined
1496 AC_MSG_RESULT([yes])
1500 *** This kernel does not include the required zlib deflate support.
1501 *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
1506 dnl # 2.6.39 API compat,
1507 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
1508 dnl # This was done to avoid always having to allocate the maximum size
1509 dnl # workspace (268K). The caller can now specific the windowBits and
1510 dnl # memLevel compression parameters to get a smaller workspace.
1512 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
1513 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
1514 SPL_LINUX_TRY_COMPILE([
1515 #include <linux/zlib.h>
1517 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
1520 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
1521 [zlib_deflate_workspacesize() wants 2 args])
1528 dnl # 2.6.39 API change,
1529 dnl # Shrinker adjust to use common shrink_control structure.
1531 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
1532 AC_MSG_CHECKING([whether struct shrink_control exists])
1533 SPL_LINUX_TRY_COMPILE([
1534 #include <linux/mm.h>
1536 struct shrink_control sc __attribute__ ((unused));
1539 sc.gfp_mask = GFP_KERNEL;
1542 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
1543 [struct shrink_control exists])
1550 dnl # 3.1 API Change
1552 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
1553 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
1555 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
1556 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
1557 tmp_flags="$EXTRA_KCFLAGS"
1558 EXTRA_KCFLAGS="-Werror"
1559 SPL_LINUX_TRY_COMPILE([
1560 #include <linux/rwsem.h>
1562 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
1563 raw_spinlock_t dummy_lock __attribute__ ((unused));
1564 dummy_semaphore.wait_lock = dummy_lock;
1567 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
1568 [struct rw_semaphore member wait_lock is raw_spinlock_t])
1572 EXTRA_KCFLAGS="$tmp_flags"
1576 dnl # 3.9 API change,
1577 dnl # Moved things from linux/sched.h to linux/sched/rt.h
1579 AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
1580 [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
1581 SPL_LINUX_TRY_COMPILE([
1582 #include <linux/sched.h>
1583 #include <linux/sched/rt.h>
1587 AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
1595 dnl # 3.9 API change,
1596 dnl # vfs_getattr() uses 2 args
1597 dnl # It takes struct path * instead of struct vfsmount * and struct dentry *
1599 AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
1600 AC_MSG_CHECKING([whether vfs_getattr() wants])
1601 SPL_LINUX_TRY_COMPILE([
1602 #include <linux/fs.h>
1604 vfs_getattr((struct path *) NULL,
1605 (struct kstat *)NULL);
1607 AC_MSG_RESULT(2 args)
1608 AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
1609 [vfs_getattr wants 2 args])
1611 SPL_LINUX_TRY_COMPILE([
1612 #include <linux/fs.h>
1614 vfs_getattr((struct vfsmount *)NULL,
1615 (struct dentry *)NULL,
1616 (struct kstat *)NULL);
1618 AC_MSG_RESULT(3 args)
1620 AC_MSG_ERROR(unknown)
1626 dnl # 2.6.36 API compatibility.
1627 dnl # Added usleep_range timer.
1628 dnl # usleep_range is a finer precision implementation of msleep
1629 dnl # designed to be a drop-in replacement for udelay where a precise
1630 dnl # sleep / busy-wait is unnecessary.
1632 AC_DEFUN([SPL_AC_USLEEP_RANGE], [
1633 AC_MSG_CHECKING([whether usleep_range() is available])
1634 SPL_LINUX_TRY_COMPILE([
1635 #include <linux/delay.h>
1640 AC_DEFINE(HAVE_USLEEP_RANGE, 1,
1641 [usleep_range is available])
1648 dnl # 2.6.35 API change,
1649 dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are
1650 dnl # private allocation flags which are applied when allocating a new slab
1651 dnl # in kmem_getpages(). Unfortunately there is no public API for setting
1652 dnl # non-default flags.
1654 AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [
1655 AC_MSG_CHECKING([whether struct kmem_cache has allocflags])
1656 SPL_LINUX_TRY_COMPILE([
1657 #include <linux/slab.h>
1659 struct kmem_cache cachep __attribute__ ((unused));
1660 cachep.allocflags = GFP_KERNEL;
1663 AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1,
1664 [struct kmem_cache has allocflags])
1668 AC_MSG_CHECKING([whether struct kmem_cache has gfpflags])
1669 SPL_LINUX_TRY_COMPILE([
1670 #include <linux/slab.h>
1672 struct kmem_cache cachep __attribute__ ((unused));
1673 cachep.gfpflags = GFP_KERNEL;
1676 AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1,
1677 [struct kmem_cache has gfpflags])
1685 dnl # 3.17 API change,
1686 dnl # wait_on_bit() no longer requires an action argument. The former
1687 dnl # "wait_on_bit" interface required an 'action' function to be provided
1688 dnl # which does the actual waiting. There were over 20 such functions in the
1689 dnl # kernel, many of them identical, though most cases can be satisfied by one
1690 dnl # of just two functions: one which uses io_schedule() and one which just
1691 dnl # uses schedule(). This API change was made to consolidate all of those
1692 dnl # redundant wait functions.
1694 AC_DEFUN([SPL_AC_WAIT_ON_BIT], [
1695 AC_MSG_CHECKING([whether wait_on_bit() takes an action])
1696 SPL_LINUX_TRY_COMPILE([
1697 #include <linux/wait.h>
1699 int (*action)(void *) = NULL;
1700 wait_on_bit(NULL, 0, action, 0);
1703 AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes])