]> git.proxmox.com Git - mirror_spl-debian.git/blobdiff - config/spl-build.m4
Imported Upstream version 0.6.5.9
[mirror_spl-debian.git] / config / spl-build.m4
index 6f312e25a7a34de7596adfb7548530a3003274bf..5a2f1ded2534c0938da2fa49b05c1a224fffe77e 100644 (file)
@@ -9,84 +9,66 @@
 AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
        SPL_AC_KERNEL
 
-       dnl # -Wall -fno-strict-aliasing -Wstrict-prototypes and other
-       dnl # compiler options are added by the kernel build system.
-       abs_srcdir=`readlink -f ${srcdir}`
-       KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes -Werror"
-       KERNELCPPFLAGS="$KERNELCPPFLAGS -I${abs_srcdir}/include"
-       KERNELCPPFLAGS="$KERNELCPPFLAGS -include ${abs_srcdir}/spl_config.h"
-
        if test "${LINUX_OBJ}" != "${LINUX}"; then
                KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
        fi
-
        AC_SUBST(KERNELMAKE_PARAMS)
+
+       KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes"
        AC_SUBST(KERNELCPPFLAGS)
 
        SPL_AC_DEBUG
        SPL_AC_DEBUG_KMEM
        SPL_AC_DEBUG_KMEM_TRACKING
+       SPL_AC_TEST_MODULE
        SPL_AC_ATOMIC_SPINLOCK
-       SPL_AC_TYPE_ATOMIC64_CMPXCHG
-       SPL_AC_TYPE_ATOMIC64_XCHG
-       SPL_AC_TYPE_UINTPTR_T
-       SPL_AC_3ARGS_INIT_WORK
-       SPL_AC_2ARGS_REGISTER_SYSCTL
-       SPL_AC_SET_SHRINKER
-       SPL_AC_PATH_IN_NAMEIDATA
-       SPL_AC_TASK_CURR
-       SPL_AC_CTL_UNNUMBERED
-       SPL_AC_FLS64
-       SPL_AC_DEVICE_CREATE
-       SPL_AC_5ARGS_DEVICE_CREATE
-       SPL_AC_CLASS_DEVICE_CREATE
-       SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
-       SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
-       SPL_AC_TIMESPEC_SUB
-       SPL_AC_INIT_UTSNAME
-       SPL_AC_FDTABLE_HEADER
-       SPL_AC_FILES_FDTABLE
-       SPL_AC_UACCESS_HEADER
-       SPL_AC_KMALLOC_NODE
-       SPL_AC_MONOTONIC_CLOCK
-       SPL_AC_INODE_I_MUTEX
-       SPL_AC_MUTEX_OWNER
-       SPL_AC_MUTEX_LOCK_NESTED
-       SPL_AC_DIV64_64
-       SPL_AC_DIV64_U64
-       SPL_AC_3ARGS_ON_EACH_CPU
-       SPL_AC_KALLSYMS_LOOKUP_NAME
-       SPL_AC_GET_VMALLOC_INFO
-       SPL_AC_PGDAT_HELPERS
-       SPL_AC_FIRST_ONLINE_PGDAT
-       SPL_AC_NEXT_ONLINE_PGDAT
-       SPL_AC_NEXT_ZONE
-       SPL_AC_PGDAT_LIST
-       SPL_AC_GLOBAL_PAGE_STATE
-       SPL_AC_ZONE_STAT_ITEM_FREE
-       SPL_AC_ZONE_STAT_ITEM_INACTIVE
-       SPL_AC_ZONE_STAT_ITEM_ACTIVE
-       SPL_AC_GET_ZONE_COUNTS
-       SPL_AC_SET_FS_PWD
-       SPL_AC_2ARGS_SET_FS_PWD
+       SPL_AC_SHRINKER_CALLBACK
+       SPL_AC_CTL_NAME
+       SPL_AC_CONFIG_TRIM_UNUSED_KSYMS
+       SPL_AC_PDE_DATA
+       SPL_AC_SET_FS_PWD_WITH_CONST
        SPL_AC_2ARGS_VFS_UNLINK
        SPL_AC_4ARGS_VFS_RENAME
-       SPL_AC_CRED_STRUCT
-       SPL_AC_GROUPS_SEARCH
+       SPL_AC_2ARGS_VFS_FSYNC
+       SPL_AC_INODE_TRUNCATE_RANGE
+       SPL_AC_FS_STRUCT_SPINLOCK
+       SPL_AC_KUIDGID_T
        SPL_AC_PUT_TASK_STRUCT
-       SPL_AC_5ARGS_PROC_HANDLER
-       SPL_AC_KVASPRINTF
+       SPL_AC_KERNEL_FALLOCATE
+       SPL_AC_CONFIG_ZLIB_INFLATE
+       SPL_AC_CONFIG_ZLIB_DEFLATE
+       SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
+       SPL_AC_SHRINK_CONTROL_STRUCT
+       SPL_AC_RWSEM_SPINLOCK_IS_RAW
+       SPL_AC_RWSEM_ACTIVITY
+       SPL_AC_RWSEM_ATOMIC_LONG_COUNT
+       SPL_AC_SCHED_RT_HEADER
+       SPL_AC_2ARGS_VFS_GETATTR
+       SPL_AC_USLEEP_RANGE
+       SPL_AC_KMEM_CACHE_ALLOCFLAGS
+       SPL_AC_WAIT_ON_BIT
+       SPL_AC_INODE_LOCK
+       SPL_AC_MUTEX_OWNER
+       SPL_AC_GROUP_INFO_GID
 ])
 
 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
        modpost=$LINUX/scripts/Makefile.modpost
        AC_MSG_CHECKING([kernel file name for module symbols])
-       if test -f "$modpost"; then
+       if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
                if grep -q Modules.symvers $modpost; then
                        LINUX_SYMBOLS=Modules.symvers
                else
                        LINUX_SYMBOLS=Module.symvers
                fi
+
+               if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
+                       AC_MSG_ERROR([
+       *** Please make sure the kernel devel package for your distribution
+       *** is installed.  If you are building with a custom kernel, make sure the
+       *** kernel is configured, built, and the '--with-linux=PATH' configure
+       *** option refers to the location of the kernel source.])
+               fi
        else
                LINUX_SYMBOLS=NONE
        fi
@@ -107,22 +89,22 @@ AC_DEFUN([SPL_AC_KERNEL], [
 
        AC_MSG_CHECKING([kernel source directory])
        if test -z "$kernelsrc"; then
-               headersdir="/lib/modules/$(uname -r)/build"
-               if test -e "$headersdir"; then
+               if test -e "/lib/modules/$(uname -r)/source"; then
+                       headersdir="/lib/modules/$(uname -r)/source"
+                       sourcelink=$(readlink -f "$headersdir")
+               elif test -e "/lib/modules/$(uname -r)/build"; then
+                       headersdir="/lib/modules/$(uname -r)/build"
                        sourcelink=$(readlink -f "$headersdir")
                else
                        sourcelink=$(ls -1d /usr/src/kernels/* \
-                                    /usr/src/linux-* \
+                                    /usr/src/linux-* \
                                     2>/dev/null | grep -v obj | tail -1)
                fi
 
-               if test -e ${sourcelink}; then
+               if test -n "$sourcelink" && test -e ${sourcelink}; then
                        kernelsrc=`readlink -f ${sourcelink}`
                else
-                       AC_MSG_RESULT([Not found])
-                       AC_MSG_ERROR([
-                       *** Please specify the location of the kernel source
-                       *** with the '--with-linux=PATH' option])
+                       kernelsrc="[Not found]"
                fi
        else
                if test "$kernelsrc" = "NONE"; then
@@ -131,14 +113,23 @@ AC_DEFUN([SPL_AC_KERNEL], [
        fi
 
        AC_MSG_RESULT([$kernelsrc])
+       if test ! -d "$kernelsrc"; then
+               AC_MSG_ERROR([
+       *** Please make sure the kernel devel package for your distribution
+       *** is installed and then try again.  If that fails, you can specify the
+       *** location of the kernel source with the '--with-linux=PATH' option.])
+       fi
+
        AC_MSG_CHECKING([kernel build directory])
        if test -z "$kernelbuild"; then
-               if test -d ${kernelsrc}-obj/`arch`/`arch`; then
-                       kernelbuild=${kernelsrc}-obj/`arch`/`arch`
-               elif test -d ${kernelsrc}-obj/`arch`/default; then
-                       kernelbuild=${kernelsrc}-obj/`arch`/default
-               elif test -d `dirname ${kernelsrc}`/build-`arch`; then
-                       kernelbuild=`dirname ${kernelsrc}`/build-`arch`
+               if test -e "/lib/modules/$(uname -r)/build"; then
+                       kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
+               elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
+                       kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
+               elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
+                       kernelbuild=${kernelsrc}-obj/${target_cpu}/default
+               elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
+                       kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
                else
                        kernelbuild=${kernelsrc}
                fi
@@ -146,28 +137,36 @@ AC_DEFUN([SPL_AC_KERNEL], [
        AC_MSG_RESULT([$kernelbuild])
 
        AC_MSG_CHECKING([kernel source version])
-       if test -r $kernelbuild/include/linux/version.h && 
-               fgrep -q UTS_RELEASE $kernelbuild/include/linux/version.h; then
-
-               kernsrcver=`(echo "#include <linux/version.h>"; 
-                            echo "kernsrcver=UTS_RELEASE") | 
-                            cpp -I $kernelbuild/include |
-                            grep "^kernsrcver=" | cut -d \" -f 2`
-
-       elif test -r $kernelbuild/include/linux/utsrelease.h && 
-               fgrep -q UTS_RELEASE $kernelbuild/include/linux/utsrelease.h; then
+       utsrelease1=$kernelbuild/include/linux/version.h
+       utsrelease2=$kernelbuild/include/linux/utsrelease.h
+       utsrelease3=$kernelbuild/include/generated/utsrelease.h
+       if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
+               utsrelease=linux/version.h
+       elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
+               utsrelease=linux/utsrelease.h
+       elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
+               utsrelease=generated/utsrelease.h
+       fi
 
-               kernsrcver=`(echo "#include <linux/utsrelease.h>"; 
+       if test "$utsrelease"; then
+               kernsrcver=`(echo "#include <$utsrelease>";
                             echo "kernsrcver=UTS_RELEASE") | 
                             cpp -I $kernelbuild/include |
                             grep "^kernsrcver=" | cut -d \" -f 2`
-       fi
 
-       if test -z "$kernsrcver"; then
+               if test -z "$kernsrcver"; then
+                       AC_MSG_RESULT([Not found])
+                       AC_MSG_ERROR([*** Cannot determine kernel version.])
+               fi
+       else
                AC_MSG_RESULT([Not found])
-               AC_MSG_ERROR([
-               *** Cannot determine the version of the linux kernel source.
-               *** Please prepare the kernel before running this script])
+               if test "x$enable_linux_builtin" != xyes; then
+                       AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
+               else
+                       AC_MSG_ERROR([
+       *** Cannot find UTS_RELEASE definition.
+       *** Please run 'make prepare' inside the kernel source tree.])
+               fi
        fi
 
        AC_MSG_RESULT([$kernsrcver])
@@ -188,43 +187,243 @@ dnl # Default SPL user configuration
 dnl #
 AC_DEFUN([SPL_AC_CONFIG_USER], [])
 
+dnl #
+dnl # Check for rpm+rpmbuild to build RPM packages.  If these tools
+dnl # are missing, it is non-fatal, but you will not be able to build
+dnl # RPM packages and will be warned if you try too.
+dnl #
+dnl # By default, the generic spec file will be used because it requires
+dnl # minimal dependencies.  Distribution specific spec files can be
+dnl # placed under the 'rpm/<distribution>' directory and enabled using
+dnl # the --with-spec=<distribution> configure option.
+dnl #
+AC_DEFUN([SPL_AC_RPM], [
+       RPM=rpm
+       RPMBUILD=rpmbuild
+
+       AC_MSG_CHECKING([whether $RPM is available])
+       AS_IF([tmp=$($RPM --version 2>/dev/null)], [
+               RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
+               HAVE_RPM=yes
+               AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
+       ],[
+               HAVE_RPM=no
+               AC_MSG_RESULT([$HAVE_RPM])
+       ])
+
+       AC_MSG_CHECKING([whether $RPMBUILD is available])
+       AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
+               RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
+               HAVE_RPMBUILD=yes
+               AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
+       ],[
+               HAVE_RPMBUILD=no
+               AC_MSG_RESULT([$HAVE_RPMBUILD])
+       ])
+
+       RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"'
+       RPM_DEFINE_UTIL=
+       RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
+       RPM_DEFINE_DKMS=
+
+       SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
+       SRPM_DEFINE_UTIL=
+       SRPM_DEFINE_KMOD=
+       SRPM_DEFINE_DKMS=
+
+       RPM_SPEC_DIR="rpm/generic"
+       AC_ARG_WITH([spec],
+               AS_HELP_STRING([--with-spec=SPEC],
+               [Spec files 'generic|redhat']),
+               [RPM_SPEC_DIR="rpm/$withval"])
+
+       AC_MSG_CHECKING([whether spec files are available])
+       AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
+
+       AC_SUBST(HAVE_RPM)
+       AC_SUBST(RPM)
+       AC_SUBST(RPM_VERSION)
+
+       AC_SUBST(HAVE_RPMBUILD)
+       AC_SUBST(RPMBUILD)
+       AC_SUBST(RPMBUILD_VERSION)
+
+       AC_SUBST(RPM_SPEC_DIR)
+       AC_SUBST(RPM_DEFINE_UTIL)
+       AC_SUBST(RPM_DEFINE_KMOD)
+       AC_SUBST(RPM_DEFINE_DKMS)
+       AC_SUBST(RPM_DEFINE_COMMON)
+       AC_SUBST(SRPM_DEFINE_UTIL)
+       AC_SUBST(SRPM_DEFINE_KMOD)
+       AC_SUBST(SRPM_DEFINE_DKMS)
+       AC_SUBST(SRPM_DEFINE_COMMON)
+])
+
+dnl #
+dnl # Check for dpkg+dpkg-buildpackage to build DEB packages.  If these
+dnl # tools are missing it is non-fatal but you will not be able to build
+dnl # DEB packages and will be warned if you try too.
+dnl #
+AC_DEFUN([SPL_AC_DPKG], [
+       DPKG=dpkg
+       DPKGBUILD=dpkg-buildpackage
+
+       AC_MSG_CHECKING([whether $DPKG is available])
+       AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
+               DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
+               HAVE_DPKG=yes
+               AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
+       ],[
+               HAVE_DPKG=no
+               AC_MSG_RESULT([$HAVE_DPKG])
+       ])
+
+       AC_MSG_CHECKING([whether $DPKGBUILD is available])
+       AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
+               DPKGBUILD_VERSION=$(echo $tmp | \
+                   $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
+               HAVE_DPKGBUILD=yes
+               AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
+       ],[
+               HAVE_DPKGBUILD=no
+               AC_MSG_RESULT([$HAVE_DPKGBUILD])
+       ])
+
+       AC_SUBST(HAVE_DPKG)
+       AC_SUBST(DPKG)
+       AC_SUBST(DPKG_VERSION)
+
+       AC_SUBST(HAVE_DPKGBUILD)
+       AC_SUBST(DPKGBUILD)
+       AC_SUBST(DPKGBUILD_VERSION)
+])
+
+dnl #
+dnl # Until native packaging for various different packing systems
+dnl # can be added the least we can do is attempt to use alien to
+dnl # convert the RPM packages to the needed package type.  This is
+dnl # a hack but so far it has worked reasonable well.
+dnl #
+AC_DEFUN([SPL_AC_ALIEN], [
+       ALIEN=alien
+
+       AC_MSG_CHECKING([whether $ALIEN is available])
+       AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
+               ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
+               HAVE_ALIEN=yes
+               AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
+       ],[
+               HAVE_ALIEN=no
+               AC_MSG_RESULT([$HAVE_ALIEN])
+       ])
+
+       AC_SUBST(HAVE_ALIEN)
+       AC_SUBST(ALIEN)
+       AC_SUBST(ALIEN_VERSION)
+])
+
+dnl #
+dnl # Using the VENDOR tag from config.guess set the default
+dnl # package type for 'make pkg': (rpm | deb | tgz)
+dnl #
+AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
+       AC_MSG_CHECKING([linux distribution])
+       if test -f /etc/toss-release ; then
+               VENDOR=toss ;
+       elif test -f /etc/fedora-release ; then
+               VENDOR=fedora ;
+       elif test -f /etc/redhat-release ; then
+               VENDOR=redhat ;
+       elif test -f /etc/gentoo-release ; then
+               VENDOR=gentoo ;
+       elif test -f /etc/arch-release ; then
+               VENDOR=arch ;
+       elif test -f /etc/SuSE-release ; then
+               VENDOR=sles ;
+       elif test -f /etc/slackware-version ; then
+               VENDOR=slackware ;
+       elif test -f /etc/lunar.release ; then
+               VENDOR=lunar ;
+       elif test -f /etc/lsb-release ; then
+               VENDOR=ubuntu ;
+       elif test -f /etc/debian_version ; then
+               VENDOR=debian ;
+       else
+               VENDOR= ;
+       fi
+       AC_MSG_RESULT([$VENDOR])
+       AC_SUBST(VENDOR)
+
+       AC_MSG_CHECKING([default package type])
+       case "$VENDOR" in
+               toss)       DEFAULT_PACKAGE=rpm  ;;
+               redhat)     DEFAULT_PACKAGE=rpm  ;;
+               fedora)     DEFAULT_PACKAGE=rpm  ;;
+               gentoo)     DEFAULT_PACKAGE=tgz  ;;
+               arch)       DEFAULT_PACKAGE=tgz  ;;
+               sles)       DEFAULT_PACKAGE=rpm  ;;
+               slackware)  DEFAULT_PACKAGE=tgz  ;;
+               lunar)      DEFAULT_PACKAGE=tgz  ;;
+               ubuntu)     DEFAULT_PACKAGE=deb  ;;
+               debian)     DEFAULT_PACKAGE=deb  ;;
+               *)          DEFAULT_PACKAGE=rpm  ;;
+       esac
+
+       AC_MSG_RESULT([$DEFAULT_PACKAGE])
+       AC_SUBST(DEFAULT_PACKAGE)
+])
+
+dnl #
+dnl # Default SPL user configuration
+dnl #
+AC_DEFUN([SPL_AC_PACKAGE], [
+       SPL_AC_DEFAULT_PACKAGE
+       SPL_AC_RPM
+       SPL_AC_DPKG
+       SPL_AC_ALIEN
+])
+
 AC_DEFUN([SPL_AC_LICENSE], [
+       AC_MSG_CHECKING([spl author])
+       AC_MSG_RESULT([$SPL_META_AUTHOR])
+
        AC_MSG_CHECKING([spl license])
-       LICENSE=GPL
-       AC_MSG_RESULT([$LICENSE])
-       KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
-       AC_SUBST(LICENSE)
+       AC_MSG_RESULT([$SPL_META_LICENSE])
 ])
 
 AC_DEFUN([SPL_AC_CONFIG], [
-        SPL_CONFIG=all
-        AC_ARG_WITH([config],
-                AS_HELP_STRING([--with-config=CONFIG],
-                [Config file 'kernel|user|all|srpm']),
-                [SPL_CONFIG="$withval"])
-
-        AC_MSG_CHECKING([spl config])
-        AC_MSG_RESULT([$SPL_CONFIG]);
-        AC_SUBST(SPL_CONFIG)
-
-        case "$SPL_CONFIG" in
-                kernel) SPL_AC_CONFIG_KERNEL ;;
-                user)   SPL_AC_CONFIG_USER   ;;
-                all)    SPL_AC_CONFIG_KERNEL
-                        SPL_AC_CONFIG_USER   ;;
+       SPL_CONFIG=all
+       AC_ARG_WITH([config],
+               AS_HELP_STRING([--with-config=CONFIG],
+               [Config file 'kernel|user|all|srpm']),
+               [SPL_CONFIG="$withval"])
+       AC_ARG_ENABLE([linux-builtin],
+               [AC_HELP_STRING([--enable-linux-builtin],
+               [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
+               [],
+               [enable_linux_builtin=no])
+
+       AC_MSG_CHECKING([spl config])
+       AC_MSG_RESULT([$SPL_CONFIG]);
+       AC_SUBST(SPL_CONFIG)
+
+       case "$SPL_CONFIG" in
+               kernel) SPL_AC_CONFIG_KERNEL ;;
+               user)   SPL_AC_CONFIG_USER   ;;
+               all)    SPL_AC_CONFIG_KERNEL
+                       SPL_AC_CONFIG_USER   ;;
                srpm)                        ;;
-                *)
-                AC_MSG_RESULT([Error!])
-                AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
-                              user kernel|user|all|srpm]) ;;
-        esac
-
-        AM_CONDITIONAL([CONFIG_USER],
-                       [test "$SPL_CONFIG" = user] ||
-                       [test "$SPL_CONFIG" = all])
-        AM_CONDITIONAL([CONFIG_KERNEL],
-                       [test "$SPL_CONFIG" = kernel] ||
-                       [test "$SPL_CONFIG" = all])
+               *)
+               AC_MSG_RESULT([Error!])
+               AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
+                            user kernel|user|all|srpm]) ;;
+       esac
+
+       AM_CONDITIONAL([CONFIG_USER],
+                      [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
+       AM_CONDITIONAL([CONFIG_KERNEL],
+                      [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
+                      [test "x$enable_linux_builtin" != xyes ])
 ])
 
 dnl #
@@ -232,6 +431,7 @@ dnl # Enable if the SPL should be compiled with internal debugging enabled.
 dnl # By default this support is disabled.
 dnl #
 AC_DEFUN([SPL_AC_DEBUG], [
+       AC_MSG_CHECKING([whether debugging is enabled])
        AC_ARG_ENABLE([debug],
                [AS_HELP_STRING([--enable-debug],
                [Enable generic debug support @<:@default=no@:>@])],
@@ -239,10 +439,18 @@ AC_DEFUN([SPL_AC_DEBUG], [
                [enable_debug=no])
 
        AS_IF([test "x$enable_debug" = xyes],
-               [KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG"],
-               [KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"])
+       [
+               KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
+               DEBUG_CFLAGS="-DDEBUG -Werror"
+               DEBUG_SPL="_with_debug"
+       ], [
+               KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
+               DEBUG_CFLAGS="-DNDEBUG"
+               DEBUG_SPL="_without_debug"
+       ])
 
-       AC_MSG_CHECKING([whether debugging is enabled])
+       AC_SUBST(DEBUG_CFLAGS)
+       AC_SUBST(DEBUG_SPL)
        AC_MSG_RESULT([$enable_debug])
 ])
 
@@ -250,21 +458,26 @@ dnl #
 dnl # Enabled by default it provides a minimal level of memory tracking.
 dnl # A total count of bytes allocated is kept for each alloc and free.
 dnl # Then at module unload time a report to the console will be printed
-dnl # if memory was leaked.  Additionally, /proc/spl/kmem/slab will exist
-dnl # and provide an easy way to inspect the kmem based slab.
+dnl # if memory was leaked.
 dnl #
 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
        AC_ARG_ENABLE([debug-kmem],
                [AS_HELP_STRING([--enable-debug-kmem],
-               [Enable basic kmem accounting @<:@default=yes@:>@])],
+               [Enable basic kmem accounting @<:@default=no@:>@])],
                [],
-               [enable_debug_kmem=yes])
+               [enable_debug_kmem=no])
 
        AS_IF([test "x$enable_debug_kmem" = xyes],
-               [AC_DEFINE([DEBUG_KMEM], [1],
+       [
+               KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
+               DEBUG_KMEM="_with_debug_kmem"
+               AC_DEFINE([DEBUG_KMEM], [1],
                [Define to 1 to enable basic kmem accounting])
-               KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"])
+       ], [
+               DEBUG_KMEM="_without_debug_kmem"
+       ])
 
+       AC_SUBST(DEBUG_KMEM)
        AC_MSG_CHECKING([whether basic kmem accounting is enabled])
        AC_MSG_RESULT([$enable_debug_kmem])
 ])
@@ -286,10 +499,16 @@ AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
                [enable_debug_kmem_tracking=no])
 
        AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
-               [AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
+       [
+               KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
+               DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
+               AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
                [Define to 1 to enable detailed kmem tracking])
-               KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"])
+       ], [
+               DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
+       ])
 
+       AC_SUBST(DEBUG_KMEM_TRACKING)
        AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
        AC_MSG_RESULT([$enable_debug_kmem_tracking])
 ])
@@ -298,7 +517,7 @@ dnl #
 dnl # SPL_LINUX_CONFTEST
 dnl #
 AC_DEFUN([SPL_LINUX_CONFTEST], [
-cat >conftest.c <<_ACEOF
+cat confdefs.h - <<_ACEOF >conftest.c
 $1
 _ACEOF
 ])
@@ -324,12 +543,14 @@ dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
 dnl #
 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
        m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
-       rm -Rf build && mkdir -p build
+       rm -Rf build && mkdir -p build && touch build/conftest.mod.c
        echo "obj-m := conftest.o" >build/Makefile
+       modpost_flag=''
+       test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
        AS_IF(
-               [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) >/dev/null && AC_TRY_COMMAND([$3])],
-               [$4],
-               [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
+               [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])],
+               [$4],
+               [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
        )
        rm -Rf build
 ])
@@ -345,34 +566,11 @@ AC_DEFUN([SPL_LINUX_TRY_COMPILE],
        [$3], [$4])
 ])
 
-dnl #
-dnl # SPL_LINUX_CONFIG
-dnl #
-AC_DEFUN([SPL_LINUX_CONFIG],
-       [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
-       SPL_LINUX_TRY_COMPILE([
-               #ifndef AUTOCONF_INCLUDED
-               #include <linux/config.h>
-               #endif
-       ],[
-               #ifndef CONFIG_$1
-               #error CONFIG_$1 not #defined
-               #endif
-       ],[
-               AC_MSG_RESULT([yes])
-               $2
-       ],[
-               AC_MSG_RESULT([no])
-               $3
-       ])
-])
-
 dnl #
 dnl # SPL_CHECK_SYMBOL_EXPORT
 dnl # check symbol exported or not
 dnl #
-AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
-       [AC_MSG_CHECKING([whether symbol $1 is exported])
+AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
        grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
                $LINUX_OBJ/Module*.symvers 2>/dev/null
        rc=$?
@@ -382,21 +580,63 @@ AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
                        grep -q -E "EXPORT_SYMBOL.*($1)" \
                                "$LINUX_OBJ/$file" 2>/dev/null
                        rc=$?
-                       if test $rc -eq 0; then
-                               export=1
-                               break;
-                       fi
+                       if test $rc -eq 0; then
+                               export=1
+                               break;
+                       fi
                done
-               if test $export -eq 0; then
-                       AC_MSG_RESULT([no])
+               if test $export -eq 0; then :
                        $4
-               else
-                       AC_MSG_RESULT([yes])
+               else :
                        $3
                fi
+       else :
+               $3
+       fi
+])
+
+dnl #
+dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
+dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
+dnl # is called if not compiling for builtin
+dnl #
+AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
+       SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
+       if test $rc -ne 0; then :
+               $6
+       else
+               if test "x$enable_linux_builtin" != xyes; then
+                       SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
+               fi
+               if test $rc -ne 0; then :
+                       $6
+               else :
+                       $5
+               fi
+       fi
+])
+
+dnl #
+dnl # SPL_CHECK_SYMBOL_HEADER
+dnl # check if a symbol prototype is defined in listed headers.
+dnl #
+AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
+       AC_MSG_CHECKING([whether symbol $1 exists in header])
+       header=0
+       for file in $3; do
+               grep -q "$2" "$LINUX/$file" 2>/dev/null
+               rc=$?
+               if test $rc -eq 0; then
+                       header=1
+                       break;
+               fi
+       done
+       if test $header -eq 0; then
+               AC_MSG_RESULT([no])
+               $5
        else
                AC_MSG_RESULT([yes])
-               $3
+               $4
        fi
 ])
 
@@ -420,6 +660,41 @@ AC_DEFUN([SPL_CHECK_HEADER],
        ])
 ])
 
+dnl #
+dnl # Basic toolchain sanity check.  Verify that kernel modules can
+dnl # be built and which symbols can be used.
+dnl #
+AC_DEFUN([SPL_AC_TEST_MODULE],
+       [AC_MSG_CHECKING([whether modules can be built])
+       SPL_LINUX_TRY_COMPILE([],[],[
+               AC_MSG_RESULT([yes])
+       ],[
+               AC_MSG_RESULT([no])
+               if test "x$enable_linux_builtin" != xyes; then
+                       AC_MSG_ERROR([*** Unable to build an empty module.])
+               else
+                       AC_MSG_ERROR([
+       *** Unable to build an empty module.
+       *** Please run 'make scripts' inside the kernel source tree.])
+               fi
+       ])
+
+       AS_IF([test "x$cross_compiling" != xyes], [
+               AC_RUN_IFELSE([
+                       AC_LANG_PROGRAM([
+                               #include "$LINUX/include/linux/license.h"
+                       ], [
+                               return !license_is_gpl_compatible(
+                                   "$SPL_META_LICENSE");
+                       ])
+               ], [
+                       AC_DEFINE([SPL_IS_GPL_COMPATIBLE], [1],
+                           [Define to 1 if GPL-only symbols can be used])
+               ], [
+               ])
+       ])
+])
+
 dnl #
 dnl # Use the atomic implemenation based on global spinlocks.  This
 dnl # should only be needed by 32-bit kernels which do not provide
@@ -436,9 +711,9 @@ AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
                [enable_atomic_spinlocks=check])
 
        SPL_LINUX_TRY_COMPILE([
-               #include <asm/atomic.h>
+               #include <linux/fs.h>
        ],[
-               atomic64_t *ptr;
+               atomic64_t *ptr __attribute__ ((unused));
        ],[
                have_atomic64_t=yes
                AC_DEFINE(HAVE_ATOMIC64_T, 1,
@@ -472,221 +747,305 @@ AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
        AC_MSG_RESULT([$have_atomic64_t])
 ])
 
-dnl #
-dnl # 2.6.24 API change,
-dnl # check if atomic64_cmpxchg is defined
-dnl #
-AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
-       [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
-       SPL_LINUX_TRY_COMPILE([
-               #include <asm/atomic.h>
-       ],[
-               atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
-       ],[
-               AC_MSG_RESULT([yes])
-               AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
-                         [kernel defines atomic64_cmpxchg])
-       ],[
-               AC_MSG_RESULT([no])
-       ])
-])
-
-dnl #
-dnl # 2.6.24 API change,
-dnl # check if atomic64_xchg is defined
-dnl #
-AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
-       [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
-       SPL_LINUX_TRY_COMPILE([
-               #include <asm/atomic.h>
-       ],[
-               atomic64_xchg((atomic64_t *)NULL, 0);
-       ],[
-               AC_MSG_RESULT([yes])
-               AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
-                         [kernel defines atomic64_xchg])
-       ],[
-               AC_MSG_RESULT([no])
-       ])
-])
-
-dnl #
-dnl # 2.6.24 API change,
-dnl # check if uintptr_t typedef is defined
-dnl #
-AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
-       [AC_MSG_CHECKING([whether kernel defines uintptr_t])
+AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[
+       tmp_flags="$EXTRA_KCFLAGS"
+       EXTRA_KCFLAGS="-Werror"
+       dnl #
+       dnl # 2.6.23 to 2.6.34 API change
+       dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask)
+       dnl #
+       AC_MSG_CHECKING([whether old 2-argument shrinker exists])
        SPL_LINUX_TRY_COMPILE([
-               #include <linux/types.h>
-       ],[
-               uintptr_t *ptr;
-       ],[
-               AC_MSG_RESULT([yes])
-               AC_DEFINE(HAVE_UINTPTR_T, 1,
-                         [kernel defines uintptr_t])
-       ],[
-               AC_MSG_RESULT([no])
-       ])
-])
+               #include <linux/mm.h>
 
-dnl #
-dnl # 2.6.20 API change,
-dnl # INIT_WORK use 2 args and not store data inside
-dnl #
-AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
-       [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
-       SPL_LINUX_TRY_COMPILE([
-               #include <linux/workqueue.h>
+               int shrinker_cb(int nr_to_scan, gfp_t gfp_mask);
        ],[
-               struct work_struct work;
-               INIT_WORK(&work, NULL, NULL);
+               struct shrinker cache_shrinker = {
+                       .shrink = shrinker_cb,
+                       .seeks = DEFAULT_SEEKS,
+               };
+               register_shrinker(&cache_shrinker);
        ],[
                AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
-                         [INIT_WORK wants 3 args])
+               AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1,
+                       [old shrinker callback wants 2 args])
        ],[
                AC_MSG_RESULT(no)
+               dnl #
+               dnl # 2.6.35 - 2.6.39 API change
+               dnl # ->shrink(struct shrinker *,
+               dnl #          int nr_to_scan, gfp_t gfp_mask)
+               dnl #
+               AC_MSG_CHECKING([whether old 3-argument shrinker exists])
+               SPL_LINUX_TRY_COMPILE([
+                       #include <linux/mm.h>
+
+                       int shrinker_cb(struct shrinker *, int nr_to_scan,
+                                       gfp_t gfp_mask);
+               ],[
+                       struct shrinker cache_shrinker = {
+                               .shrink = shrinker_cb,
+                               .seeks = DEFAULT_SEEKS,
+                       };
+                       register_shrinker(&cache_shrinker);
+               ],[
+                       AC_MSG_RESULT(yes)
+                       AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
+                               [old shrinker callback wants 3 args])
+               ],[
+                       AC_MSG_RESULT(no)
+                       dnl #
+                       dnl # 3.0 - 3.11 API change
+                       dnl # ->shrink(struct shrinker *,
+                       dnl #          struct shrink_control *sc)
+                       dnl #
+                       AC_MSG_CHECKING(
+                               [whether new 2-argument shrinker exists])
+                       SPL_LINUX_TRY_COMPILE([
+                               #include <linux/mm.h>
+
+                               int shrinker_cb(struct shrinker *,
+                                               struct shrink_control *sc);
+                       ],[
+                               struct shrinker cache_shrinker = {
+                                       .shrink = shrinker_cb,
+                                       .seeks = DEFAULT_SEEKS,
+                               };
+                               register_shrinker(&cache_shrinker);
+                       ],[
+                               AC_MSG_RESULT(yes)
+                               AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1,
+                                       [new shrinker callback wants 2 args])
+                       ],[
+                               AC_MSG_RESULT(no)
+                               dnl #
+                               dnl # 3.12 API change,
+                               dnl # ->shrink() is logically split in to
+                               dnl # ->count_objects() and ->scan_objects()
+                               dnl #
+                               AC_MSG_CHECKING(
+                                   [whether ->count_objects callback exists])
+                               SPL_LINUX_TRY_COMPILE([
+                                       #include <linux/mm.h>
+
+                                       unsigned long shrinker_cb(
+                                               struct shrinker *,
+                                               struct shrink_control *sc);
+                               ],[
+                                       struct shrinker cache_shrinker = {
+                                               .count_objects = shrinker_cb,
+                                               .scan_objects = shrinker_cb,
+                                               .seeks = DEFAULT_SEEKS,
+                                       };
+                                       register_shrinker(&cache_shrinker);
+                               ],[
+                                       AC_MSG_RESULT(yes)
+                                       AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
+                                               1, [->count_objects exists])
+                               ],[
+                                       AC_MSG_ERROR(error)
+                               ])
+                       ])
+               ])
        ])
+       EXTRA_KCFLAGS="$tmp_flags"
 ])
 
 dnl #
-dnl # 2.6.21 API change,
-dnl # 'register_sysctl_table' use only one argument instead of two
+dnl # 2.6.33 API change,
+dnl # Removed .ctl_name from struct ctl_table.
 dnl #
-AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
-       [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
+AC_DEFUN([SPL_AC_CTL_NAME], [
+       AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
        SPL_LINUX_TRY_COMPILE([
                #include <linux/sysctl.h>
        ],[
-               return register_sysctl_table(NULL,0);
+               struct ctl_table ctl __attribute__ ((unused));
+               ctl.ctl_name = 0;
        ],[
                AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
-                         [register_sysctl_table() wants 2 args])
+               AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
        ],[
                AC_MSG_RESULT(no)
        ])
 ])
 
 dnl #
-dnl # 2.6.23 API change
-dnl # Old set_shrinker API replaced with register_shrinker
+dnl # 3.10 API change,
+dnl # PDE is replaced by PDE_DATA
 dnl #
-AC_DEFUN([SPL_AC_SET_SHRINKER], [
-       AC_MSG_CHECKING([whether set_shrinker() available])
-       SPL_LINUX_TRY_COMPILE([
-               #include <linux/mm.h>
-       ],[
-               return set_shrinker(DEFAULT_SEEKS, NULL);
-       ],[
-               AC_MSG_RESULT([yes])
-               AC_DEFINE(HAVE_SET_SHRINKER, 1,
-                         [set_shrinker() available])
+AC_DEFUN([SPL_AC_PDE_DATA], [
+       AC_MSG_CHECKING([whether PDE_DATA() is available])
+       SPL_LINUX_TRY_COMPILE_SYMBOL([
+               #include <linux/proc_fs.h>
+       ], [
+               PDE_DATA(NULL);
+       ], [PDE_DATA], [], [
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
        ],[
-               AC_MSG_RESULT([no])
+               AC_MSG_RESULT(no)
        ])
 ])
 
 dnl #
-dnl # 2.6.25 API change,
-dnl # struct path entry added to struct nameidata
+dnl # 3.9 API change
+dnl # set_fs_pwd takes const struct path *
 dnl #
-AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
-       [AC_MSG_CHECKING([whether struct path used in struct nameidata])
+AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
+       tmp_flags="$EXTRA_KCFLAGS"
+       EXTRA_KCFLAGS="-Werror"
+       [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
        SPL_LINUX_TRY_COMPILE([
-               #include <linux/namei.h>
+               #include <linux/spinlock.h>
+               #include <linux/fs_struct.h>
+               #include <linux/path.h>
+               void (*const set_fs_pwd_func)
+                       (struct fs_struct *, const struct path *)
+                       = set_fs_pwd;
        ],[
-               struct nameidata nd;
-
-               nd.path.mnt = NULL;
-               nd.path.dentry = NULL;
+               return 0;
        ],[
                AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
-                         [struct path used in struct nameidata])
-       ],[
-               AC_MSG_RESULT(no)
+               AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
+                       [set_fs_pwd() needs const path *])
+       ],[
+               SPL_LINUX_TRY_COMPILE([
+                       #include <linux/spinlock.h>
+                       #include <linux/fs_struct.h>
+                       #include <linux/path.h>
+                       void (*const set_fs_pwd_func)
+                               (struct fs_struct *, struct path *)
+                               = set_fs_pwd;
+               ],[
+                       return 0;
+               ],[
+                       AC_MSG_RESULT(no)
+               ],[
+                       AC_MSG_ERROR(unknown)
+               ])
        ])
+       EXTRA_KCFLAGS="$tmp_flags"
 ])
 
 dnl #
-dnl # Custom SPL patch may export this system it is not required
-dnl #
-AC_DEFUN([SPL_AC_TASK_CURR], [
-       SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
-               [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
-               [])
-])
-
-dnl #
-dnl # 2.6.19 API change,
-dnl # Use CTL_UNNUMBERED when binary sysctl is not required
+dnl # 3.13 API change
+dnl # vfs_unlink() updated to take a third delegated_inode argument.
 dnl #
-AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
-       [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
+AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
+       [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
        SPL_LINUX_TRY_COMPILE([
-               #include <linux/sysctl.h>
+               #include <linux/fs.h>
        ],[
-               #ifndef CTL_UNNUMBERED
-               #error CTL_UNNUMBERED undefined
-               #endif
+               vfs_unlink((struct inode *) NULL, (struct dentry *) NULL);
        ],[
                AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
-                         [unnumbered sysctl support exists])
+               AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
+                         [vfs_unlink() wants 2 args])
        ],[
                AC_MSG_RESULT(no)
+               dnl #
+               dnl # Linux 3.13 API change
+               dnl # Added delegated inode
+               dnl #
+               AC_MSG_CHECKING([whether vfs_unlink() wants 3 args])
+               SPL_LINUX_TRY_COMPILE([
+                       #include <linux/fs.h>
+               ],[
+                       vfs_unlink((struct inode *) NULL,
+                               (struct dentry *) NULL,
+                               (struct inode **) NULL);
+               ],[
+                       AC_MSG_RESULT(yes)
+                       AC_DEFINE(HAVE_3ARGS_VFS_UNLINK, 1,
+                                 [vfs_unlink() wants 3 args])
+               ],[
+                       AC_MSG_ERROR(no)
+               ])
+
        ])
 ])
 
 dnl #
-dnl # 2.6.16 API change.
-dnl # Check if 'fls64()' is available
+dnl # 3.13 and 3.15 API changes
+dnl # Added delegated inode and flags argument.
 dnl #
-AC_DEFUN([SPL_AC_FLS64],
-       [AC_MSG_CHECKING([whether fls64() is available])
+AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
+       [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
        SPL_LINUX_TRY_COMPILE([
-               #include <linux/bitops.h>
+               #include <linux/fs.h>
        ],[
-               return fls64(0);
+               vfs_rename((struct inode *) NULL, (struct dentry *) NULL,
+                       (struct inode *) NULL, (struct dentry *) NULL);
        ],[
                AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
+               AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
+                         [vfs_rename() wants 4 args])
        ],[
                AC_MSG_RESULT(no)
+               dnl #
+               dnl # Linux 3.13 API change
+               dnl # Added delegated inode
+               dnl #
+               AC_MSG_CHECKING([whether vfs_rename() wants 5 args])
+               SPL_LINUX_TRY_COMPILE([
+                       #include <linux/fs.h>
+               ],[
+                       vfs_rename((struct inode *) NULL,
+                               (struct dentry *) NULL,
+                               (struct inode *) NULL,
+                               (struct dentry *) NULL,
+                               (struct inode **) NULL);
+               ],[
+                       AC_MSG_RESULT(yes)
+                       AC_DEFINE(HAVE_5ARGS_VFS_RENAME, 1,
+                                 [vfs_rename() wants 5 args])
+               ],[
+                       AC_MSG_RESULT(no)
+                       dnl #
+                       dnl # Linux 3.15 API change
+                       dnl # Added flags
+                       dnl #
+                       AC_MSG_CHECKING([whether vfs_rename() wants 6 args])
+                       SPL_LINUX_TRY_COMPILE([
+                               #include <linux/fs.h>
+                       ],[
+                               vfs_rename((struct inode *) NULL,
+                                       (struct dentry *) NULL,
+                                       (struct inode *) NULL,
+                                       (struct dentry *) NULL,
+                                       (struct inode **) NULL,
+                                       (unsigned int) 0);
+                       ],[
+                               AC_MSG_RESULT(yes)
+                               AC_DEFINE(HAVE_6ARGS_VFS_RENAME, 1,
+                                         [vfs_rename() wants 6 args])
+                       ],[
+                               AC_MSG_ERROR(no)
+                       ])
+               ])
        ])
 ])
 
 dnl #
-dnl # 2.6.18 API change, check whether device_create() is available.
-dnl # Device_create() was introduced in 2.6.18 and depricated 
-dnl # class_device_create() which was fully removed in 2.6.26.
-dnl #
-AC_DEFUN([SPL_AC_DEVICE_CREATE], [
-       SPL_CHECK_SYMBOL_EXPORT(
-               [device_create],
-               [drivers/base/core.c],
-               [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
-               [device_create() is available])],
-               [])
-])
-
-dnl #
-dnl # 2.6.27 API change,
-dnl # device_create() uses 5 args, new 'drvdata' argument.
+dnl # 2.6.36 API change,
+dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
+dnl # a spinlock_t to improve the fastpath performance.
 dnl #
-AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
-       AC_MSG_CHECKING([whether device_create() wants 5 args])
+AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
+       AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
        tmp_flags="$EXTRA_KCFLAGS"
        EXTRA_KCFLAGS="-Werror"
        SPL_LINUX_TRY_COMPILE([
-               #include <linux/device.h>
+               #include <linux/sched.h>
+               #include <linux/fs_struct.h>
        ],[
-               device_create(NULL, NULL, 0, NULL, "%d", 1);
+               static struct fs_struct fs;
+               spin_lock_init(&fs.lock);
        ],[
                AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
-                         [device_create wants 5 args])
+               AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
+                         [struct fs_struct uses spinlock_t])
        ],[
                AC_MSG_RESULT(no)
        ])
@@ -694,722 +1053,547 @@ AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
 ])
 
 dnl #
-dnl # 2.6.13 API change, check whether class_device_create() is available.
-dnl # Class_device_create() was introduced in 2.6.13 and depricated
-dnl # class_simple_device_add() which was fully removed in 2.6.13.
-dnl #
-AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
-       SPL_CHECK_SYMBOL_EXPORT(
-               [class_device_create],
-               [drivers/base/class.c],
-               [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
-               [class_device_create() is available])],
-               [])
-])
-
-dnl #
-dnl # 2.6.26 API change, set_normalized_timespec() is exported.
-dnl #
-AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
-       SPL_CHECK_SYMBOL_EXPORT(
-               [set_normalized_timespec],
-               [kernel/time.c],
-               [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
-               [set_normalized_timespec() is available as export])],
-               [])
-])
-
-dnl #
-dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
-dnl # previously it was available in time.h as an inline.
+dnl # User namespaces, use kuid_t in place of uid_t
+dnl # where available. Not strictly a user namespaces thing
+dnl # but it should prevent surprises
 dnl #
-AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
-       AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
+AC_DEFUN([SPL_AC_KUIDGID_T], [
+       AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
        SPL_LINUX_TRY_COMPILE([
-               #include <linux/time.h>
-               void set_normalized_timespec(struct timespec *ts,
-                                            time_t sec, long nsec) { }
-       ],
-       [],
-       [
-               AC_MSG_RESULT(no)
-       ],[
-               AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
-                         [set_normalized_timespec() is available as inline])
-       ])
-])
-
-dnl #
-dnl # 2.6.18 API change,
-dnl # timespec_sub() inline function available in linux/time.h
-dnl #
-AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
-       AC_MSG_CHECKING([whether timespec_sub() is available])
-       SPL_LINUX_TRY_COMPILE([
-               #include <linux/time.h>
-       ],[
-               struct timespec a, b, c = { 0 };
-               c = timespec_sub(a, b);
-       ],[
-               AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
+               #include <linux/uidgid.h>
+       ], [
+               kuid_t userid = KUIDT_INIT(0);
+               kgid_t groupid = KGIDT_INIT(0);
+       ],[
+               SPL_LINUX_TRY_COMPILE([
+                       #include <linux/uidgid.h>
+               ], [
+                       kuid_t userid = 0;
+                       kgid_t groupid = 0;
+               ],[
+                       AC_MSG_RESULT(yes; optional)
+               ],[
+                       AC_MSG_RESULT(yes; mandatory)
+                       AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
+               ])
        ],[
                AC_MSG_RESULT(no)
        ])
 ])
 
 dnl #
-dnl # 2.6.19 API change,
-dnl # check if init_utsname() is available in linux/utsname.h
+dnl # 2.6.39 API change,
+dnl # __put_task_struct() was exported by the mainline kernel.
 dnl #
-AC_DEFUN([SPL_AC_INIT_UTSNAME], [
-       AC_MSG_CHECKING([whether init_utsname() is available])
-       SPL_LINUX_TRY_COMPILE([
-               #include <linux/utsname.h>
-       ],[
-               struct new_utsname *a = init_utsname();
-       ],[
+AC_DEFUN([SPL_AC_PUT_TASK_STRUCT],
+       [AC_MSG_CHECKING([whether __put_task_struct() is available])
+       SPL_LINUX_TRY_COMPILE_SYMBOL([
+               #include <linux/sched.h>
+       ], [
+               __put_task_struct(NULL);
+       ], [__put_task_struct], [], [
                AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
-       ],[
+               AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
+                         [__put_task_struct() is available])
+       ], [
                AC_MSG_RESULT(no)
        ])
 ])
 
 dnl #
-dnl # 2.6.26 API change,
-dnl # definition of struct fdtable relocated to linux/fdtable.h
-dnl #
-AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
-       SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
-])
-
-dnl #
-dnl # 2.6.14 API change,
-dnl # check whether 'files_fdtable()' exists
+dnl # 2.6.35 API change,
+dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
 dnl #
-AC_DEFUN([SPL_AC_FILES_FDTABLE], [
-       AC_MSG_CHECKING([whether files_fdtable() is available])
+AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
+       AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
        SPL_LINUX_TRY_COMPILE([
-               #include <linux/sched.h>
-               #include <linux/file.h>
-               #ifdef HAVE_FDTABLE_HEADER
-               #include <linux/fdtable.h>
-               #endif
+               #include <linux/fs.h>
        ],[
-               struct files_struct *files = current->files;
-               struct fdtable *fdt = files_fdtable(files);
+               vfs_fsync(NULL, 0);
        ],[
                AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
+               AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
        ],[
                AC_MSG_RESULT(no)
        ])
 ])
 
 dnl #
-dnl # 2.6.18 API change,
-dnl # added linux/uaccess.h
-dnl #
-AC_DEFUN([SPL_AC_UACCESS_HEADER], [
-       SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
-])
-
-dnl #
-dnl # 2.6.12 API change,
-dnl # check whether 'kmalloc_node()' is available.
+dnl # 3.5 API change,
+dnl # inode_operations.truncate_range removed
 dnl #
-AC_DEFUN([SPL_AC_KMALLOC_NODE], [
-       AC_MSG_CHECKING([whether kmalloc_node() is available])
+AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
+       AC_MSG_CHECKING([whether truncate_range() inode operation is available])
        SPL_LINUX_TRY_COMPILE([
-               #include <linux/slab.h>
+               #include <linux/fs.h>
        ],[
-               void *a = kmalloc_node(1, GFP_KERNEL, 0);
+               struct inode_operations ops;
+               ops.truncate_range = NULL;
        ],[
                AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
+               AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
+                       [truncate_range() inode operation is available])
        ],[
                AC_MSG_RESULT(no)
        ])
 ])
 
 dnl #
-dnl # 2.6.9 API change,
-dnl # check whether 'monotonic_clock()' is available it may
-dnl # be available for some archs but not others.
-dnl #
-AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
-       SPL_CHECK_SYMBOL_EXPORT(
-               [monotonic_clock],
-               [],
-               [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
-               [monotonic_clock() is available])],
-               [])
-])
-
-dnl #
-dnl # 2.6.16 API change,
-dnl # check whether 'struct inode' has i_mutex
+dnl # Linux 2.6.38 - 3.x API
 dnl #
-AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
-       AC_MSG_CHECKING([whether struct inode has i_mutex])
+AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
+       AC_MSG_CHECKING([whether fops->fallocate() exists])
        SPL_LINUX_TRY_COMPILE([
                #include <linux/fs.h>
-               #include <linux/mutex.h>
        ],[
-               struct inode i;
-               mutex_init(&i.i_mutex);
+               long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
+               struct file_operations fops __attribute__ ((unused)) = {
+                       .fallocate = fallocate,
+               };
        ],[
                AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
+               AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
        ],[
                AC_MSG_RESULT(no)
        ])
 ])
 
 dnl #
-dnl # 2.6.29 API change,
-dnl # Adaptive mutexs introduced.
+dnl # Linux 2.6.x - 2.6.37 API
 dnl #
-AC_DEFUN([SPL_AC_MUTEX_OWNER], [
-       AC_MSG_CHECKING([whether struct mutex has owner])
+AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
+       AC_MSG_CHECKING([whether iops->fallocate() exists])
        SPL_LINUX_TRY_COMPILE([
-               #include <linux/mutex.h>
+               #include <linux/fs.h>
        ],[
-               struct mutex mtx;
-               mtx.owner = NULL;
+               long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
+               struct inode_operations fops __attribute__ ((unused)) = {
+                       .fallocate = fallocate,
+               };
        ],[
                AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
+               AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
        ],[
                AC_MSG_RESULT(no)
        ])
 ])
 
 dnl #
-dnl # 2.6.18 API change,
-dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
-dnl # as part of the mutex validator.  Fallback to using 'mutex_lock()' 
-dnl # if the mutex validator is disabled or otherwise unavailable.
+dnl # PaX Linux 2.6.38 - 3.x API
 dnl #
-AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
-       AC_MSG_CHECKING([whether mutex_lock_nested() is available])
+AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
+       AC_MSG_CHECKING([whether fops->fallocate() exists])
        SPL_LINUX_TRY_COMPILE([
-               #include <linux/mutex.h>
+               #include <linux/fs.h>
        ],[
-               struct mutex mutex;
-               mutex_init(&mutex);
-               mutex_lock_nested(&mutex, 0);
+               long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
+               struct file_operations_no_const fops __attribute__ ((unused)) = {
+                       .fallocate = fallocate,
+               };
        ],[
                AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
-               [mutex_lock_nested() is available])
+               AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
        ],[
                AC_MSG_RESULT(no)
        ])
 ])
 
 dnl #
-dnl # 2.6.22 API change,
-dnl # First introduced 'div64_64()' in lib/div64.c
-dnl 
-AC_DEFUN([SPL_AC_DIV64_64], [
-       SPL_CHECK_SYMBOL_EXPORT(
-               [div64_64],
-               [],
-               [AC_DEFINE(HAVE_DIV64_64, 1,
-               [div64_64() is available])],
-               [])
-])
-
-dnl #
-dnl # 2.6.26 API change,
-dnl # Renamed 'div64_64()' to 'div64_u64' in lib/div64.c
+dnl # The fallocate callback was moved from the inode_operations
+dnl # structure to the file_operations structure.
 dnl #
-AC_DEFUN([SPL_AC_DIV64_U64], [
-       SPL_CHECK_SYMBOL_EXPORT(
-               [div64_u64],
-               [],
-               [AC_DEFINE(HAVE_DIV64_U64, 1,
-               [div64_u64() is available])],
-               [])
+AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
+       SPL_AC_KERNEL_FILE_FALLOCATE
+       SPL_AC_KERNEL_INODE_FALLOCATE
+       SPL_AC_PAX_KERNEL_FILE_FALLOCATE
 ])
 
 dnl #
-dnl # 2.6.27 API change,
-dnl # on_each_cpu() uses 3 args, no 'retry' argument
+dnl # zlib inflate compat,
+dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
 dnl #
-AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
-       AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
+AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
+       AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
        SPL_LINUX_TRY_COMPILE([
-               #include <linux/smp.h>
-       ],[
-               on_each_cpu(NULL, NULL, 0);
-       ],[
-               AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
-                         [on_each_cpu wants 3 args])
+               #if !defined(CONFIG_ZLIB_INFLATE) && \
+                   !defined(CONFIG_ZLIB_INFLATE_MODULE)
+               #error CONFIG_ZLIB_INFLATE not defined
+               #endif
+       ],[ ],[
+               AC_MSG_RESULT([yes])
        ],[
-               AC_MSG_RESULT(no)
+               AC_MSG_RESULT([no])
+               AC_MSG_ERROR([
+       *** This kernel does not include the required zlib inflate support.
+       *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
        ])
 ])
 
 dnl #
-dnl # 2.6.18 API change,
-dnl # kallsyms_lookup_name no longer exported
+dnl # zlib deflate compat,
+dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
 dnl #
-AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
-       SPL_CHECK_SYMBOL_EXPORT(
-               [kallsyms_lookup_name],
-               [],
-               [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
-               [kallsyms_lookup_name() is available])],
-               [])
-])
-
-dnl #
-dnl # Proposed API change,
-dnl # This symbol is not available in stock kernels.  You may build a
-dnl # custom kernel with the *-spl-export-symbols.patch which will export
-dnl # these symbols for use.  If your already rolling a custom kernel for
-dnl # your environment this is recommended.
-dnl #
-AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
-       SPL_CHECK_SYMBOL_EXPORT(
-               [get_vmalloc_info],
-               [],
-               [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
-               [get_vmalloc_info() is available])],
-               [])
-])
-
-dnl #
-dnl # 2.6.17 API change
-dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
-dnl # next_zone() are introduced to simplify for_each_zone().  These symbols
-dnl # were exported in 2.6.17 for use by modules which was consistent with
-dnl # the previous implementation of for_each_zone().  From 2.6.18 - 2.6.19
-dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
-dnl # were dropped entirely leaving modules no way to directly iterate over
-dnl # the zone list.  Because we need access to the zone helpers we check
-dnl # if the kernel contains the old or new implementation.  Then we check
-dnl # to see if the symbols we need for each version are available.  If they
-dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
-dnl #
-AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
-       AC_MSG_CHECKING([whether symbol *_pgdat exist])
-       grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
-       rc=$?
-       if test $rc -eq 0; then
+AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
+       AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
+       SPL_LINUX_TRY_COMPILE([
+               #if !defined(CONFIG_ZLIB_DEFLATE) && \
+                   !defined(CONFIG_ZLIB_DEFLATE_MODULE)
+               #error CONFIG_ZLIB_DEFLATE not defined
+               #endif
+       ],[ ],[
                AC_MSG_RESULT([yes])
-                AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
-       else
+       ],[
                AC_MSG_RESULT([no])
-       fi
-])
-
-dnl #
-dnl # Proposed API change,
-dnl # This symbol is not available in stock kernels.  You may build a
-dnl # custom kernel with the *-spl-export-symbols.patch which will export
-dnl # these symbols for use.  If your already rolling a custom kernel for
-dnl # your environment this is recommended.
-dnl #
-AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
-       SPL_CHECK_SYMBOL_EXPORT(
-               [first_online_pgdat],
-               [],
-               [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
-               [first_online_pgdat() is available])],
-               [])
-])
-
-dnl #
-dnl # Proposed API change,
-dnl # This symbol is not available in stock kernels.  You may build a
-dnl # custom kernel with the *-spl-export-symbols.patch which will export
-dnl # these symbols for use.  If your already rolling a custom kernel for
-dnl # your environment this is recommended.
-dnl #
-AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
-       SPL_CHECK_SYMBOL_EXPORT(
-               [next_online_pgdat],
-               [],
-               [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
-               [next_online_pgdat() is available])],
-               [])
-])
-
-dnl #
-dnl # Proposed API change,
-dnl # This symbol is not available in stock kernels.  You may build a
-dnl # custom kernel with the *-spl-export-symbols.patch which will export
-dnl # these symbols for use.  If your already rolling a custom kernel for
-dnl # your environment this is recommended.
-dnl #
-AC_DEFUN([SPL_AC_NEXT_ZONE], [
-       SPL_CHECK_SYMBOL_EXPORT(
-               [next_zone],
-               [],
-               [AC_DEFINE(HAVE_NEXT_ZONE, 1,
-               [next_zone() is available])],
-               [])
+               AC_MSG_ERROR([
+       *** This kernel does not include the required zlib deflate support.
+       *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
+       ])
 ])
 
 dnl #
-dnl # 2.6.17 API change,
-dnl # See SPL_AC_PGDAT_HELPERS for details.
+dnl # config trim unused symbols,
+dnl # Verify the kernel has CONFIG_TRIM_UNUSED_KSYMS DISABLED.
 dnl #
-AC_DEFUN([SPL_AC_PGDAT_LIST], [
-       SPL_CHECK_SYMBOL_EXPORT(
-               [pgdat_list],
-               [],
-               [AC_DEFINE(HAVE_PGDAT_LIST, 1,
-               [pgdat_list is available])],
-               [])
+AC_DEFUN([SPL_AC_CONFIG_TRIM_UNUSED_KSYMS], [
+       AC_MSG_CHECKING([whether CONFIG_TRIM_UNUSED_KSYM is disabled])
+       SPL_LINUX_TRY_COMPILE([
+               #if defined(CONFIG_TRIM_UNUSED_KSYMS)
+               #error CONFIG_TRIM_UNUSED_KSYMS not defined
+               #endif
+       ],[ ],[
+               AC_MSG_RESULT([yes])
+       ],[
+               AC_MSG_RESULT([no])
+               AC_MSG_ERROR([
+       *** This kernel has unused symbols trimming enabled, please disable.
+       *** Rebuild the kernel with CONFIG_TRIM_UNUSED_KSYMS=n set.])
+       ])
 ])
 
 dnl #
-dnl # 2.6.18 API change,
-dnl # First introduced global_page_state() support as an inline.
+dnl # 2.6.39 API compat,
+dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
+dnl # This was done to avoid always having to allocate the maximum size
+dnl # workspace (268K).  The caller can now specific the windowBits and
+dnl # memLevel compression parameters to get a smaller workspace.
 dnl #
-AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
-       AC_MSG_CHECKING([whether global_page_state() is available])
+AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
+       [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
        SPL_LINUX_TRY_COMPILE([
-               #include <linux/mm.h>
+               #include <linux/zlib.h>
        ],[
-               unsigned long state;
-               state = global_page_state(0);
+               return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
        ],[
                AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
-                         [global_page_state() is available])
+               AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
+                         [zlib_deflate_workspacesize() wants 2 args])
        ],[
                AC_MSG_RESULT(no)
        ])
 ])
 
 dnl #
-dnl # 2.6.21 API change (plus subsequent naming convention changes),
-dnl # Public global zone stats now include a free page count.  However
-dnl # the enumerated names of the counters have changed since this API
-dnl # was introduced.  We need to deduce the corrent name to use.  This
-dnl # replaces the priviate get_zone_counts() interface.
+dnl # 2.6.39 API change,
+dnl # Shrinker adjust to use common shrink_control structure.
 dnl #
-dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
-dnl # is 2.6.30 as of when this was written.
-dnl #
-AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
-       AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
+AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
+       AC_MSG_CHECKING([whether struct shrink_control exists])
        SPL_LINUX_TRY_COMPILE([
                #include <linux/mm.h>
        ],[
-               enum zone_stat_item zsi;
-               zsi = NR_FREE_PAGES;
+               struct shrink_control sc __attribute__ ((unused));
+
+               sc.nr_to_scan = 0;
+               sc.gfp_mask = GFP_KERNEL;
        ],[
                AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
-                         [Page state NR_FREE_PAGES is available])
+               AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
+                       [struct shrink_control exists])
        ],[
                AC_MSG_RESULT(no)
        ])
 ])
 
 dnl #
-dnl # 2.6.21 API change (plus subsequent naming convention changes),
-dnl # Public global zone stats now include an inactive page count.  However
-dnl # the enumerated names of the counters have changed since this API
-dnl # was introduced.  We need to deduce the corrent name to use.  This
-dnl # replaces the priviate get_zone_counts() interface.
+dnl # 3.1 API Change
 dnl #
-dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
-dnl # anonymous and file inactive pages.  As of 2.6.28 it was split in
-dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
+dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
+dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
 dnl #
-AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
-       AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
-       SPL_LINUX_TRY_COMPILE([
-               #include <linux/mm.h>
-       ],[
-               enum zone_stat_item zsi;
-               zsi = NR_INACTIVE;
-       ],[
-               AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
-                         [Page state NR_INACTIVE is available])
-       ],[
-               AC_MSG_RESULT(no)
-       ])
-
-       AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
+AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
+       AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
+       tmp_flags="$EXTRA_KCFLAGS"
+       EXTRA_KCFLAGS="-Werror"
        SPL_LINUX_TRY_COMPILE([
-               #include <linux/mm.h>
+               #include <linux/rwsem.h>
        ],[
-               enum zone_stat_item zsi;
-               zsi = NR_INACTIVE_ANON;
+               struct rw_semaphore dummy_semaphore __attribute__ ((unused));
+               raw_spinlock_t dummy_lock __attribute__ ((unused));
+               dummy_semaphore.wait_lock = dummy_lock;
        ],[
                AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
-                         [Page state NR_INACTIVE_ANON is available])
+               AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
+               [struct rw_semaphore member wait_lock is raw_spinlock_t])
        ],[
                AC_MSG_RESULT(no)
        ])
+       EXTRA_KCFLAGS="$tmp_flags"
+])
 
-       AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
+dnl #
+dnl # 3.16 API Change
+dnl #
+dnl # rwsem-spinlock "->activity" changed to "->count"
+dnl #
+AC_DEFUN([SPL_AC_RWSEM_ACTIVITY], [
+       AC_MSG_CHECKING([whether struct rw_semaphore has member activity])
+       tmp_flags="$EXTRA_KCFLAGS"
+       EXTRA_KCFLAGS="-Werror"
        SPL_LINUX_TRY_COMPILE([
-               #include <linux/mm.h>
+               #include <linux/rwsem.h>
        ],[
-               enum zone_stat_item zsi;
-               zsi = NR_INACTIVE_FILE;
+               struct rw_semaphore dummy_semaphore __attribute__ ((unused));
+               dummy_semaphore.activity = 0;
        ],[
                AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
-                         [Page state NR_INACTIVE_FILE is available])
+               AC_DEFINE(HAVE_RWSEM_ACTIVITY, 1,
+               [struct rw_semaphore has member activity])
        ],[
                AC_MSG_RESULT(no)
        ])
+       EXTRA_KCFLAGS="$tmp_flags"
 ])
 
 dnl #
-dnl # 2.6.21 API change (plus subsequent naming convention changes),
-dnl # Public global zone stats now include an active page count.  However
-dnl # the enumerated names of the counters have changed since this API
-dnl # was introduced.  We need to deduce the corrent name to use.  This
-dnl # replaces the priviate get_zone_counts() interface.
+dnl # 4.8 API Change
 dnl #
-dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
-dnl # anonymous and file active pages.  As of 2.6.28 it was split in
-dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
+dnl # rwsem "->count" changed to atomic_long_t type
 dnl #
-AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
-       AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
+AC_DEFUN([SPL_AC_RWSEM_ATOMIC_LONG_COUNT], [
+       AC_MSG_CHECKING(
+       [whether struct rw_semaphore has atomic_long_t member count])
+       tmp_flags="$EXTRA_KCFLAGS"
+       EXTRA_KCFLAGS="-Werror"
        SPL_LINUX_TRY_COMPILE([
-               #include <linux/mm.h>
+               #include <linux/rwsem.h>
        ],[
-               enum zone_stat_item zsi;
-               zsi = NR_ACTIVE;
+               DECLARE_RWSEM(dummy_semaphore);
+               (void) atomic_long_read(&dummy_semaphore.count);
        ],[
                AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
-                         [Page state NR_ACTIVE is available])
+               AC_DEFINE(HAVE_RWSEM_ATOMIC_LONG_COUNT, 1,
+               [struct rw_semaphore has atomic_long_t member count])
        ],[
                AC_MSG_RESULT(no)
        ])
+       EXTRA_KCFLAGS="$tmp_flags"
+])
 
-       AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
+dnl #
+dnl # 3.9 API change,
+dnl # Moved things from linux/sched.h to linux/sched/rt.h
+dnl #
+AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
+       [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
        SPL_LINUX_TRY_COMPILE([
-               #include <linux/mm.h>
+               #include <linux/sched.h>
+               #include <linux/sched/rt.h>
        ],[
-               enum zone_stat_item zsi;
-               zsi = NR_ACTIVE_ANON;
+               return 0;
        ],[
+               AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
                AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
-                         [Page state NR_ACTIVE_ANON is available])
        ],[
                AC_MSG_RESULT(no)
        ])
+])
 
-       AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
+dnl #
+dnl # 3.9 API change,
+dnl # vfs_getattr() uses 2 args
+dnl # It takes struct path * instead of struct vfsmount * and struct dentry *
+dnl #
+AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
+       AC_MSG_CHECKING([whether vfs_getattr() wants])
        SPL_LINUX_TRY_COMPILE([
-               #include <linux/mm.h>
+               #include <linux/fs.h>
        ],[
-               enum zone_stat_item zsi;
-               zsi = NR_ACTIVE_FILE;
+               vfs_getattr((struct path *) NULL,
+                       (struct kstat *)NULL);
        ],[
-               AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
-                         [Page state NR_ACTIVE_FILE is available])
+               AC_MSG_RESULT(2 args)
+               AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
+                         [vfs_getattr wants 2 args])
        ],[
-               AC_MSG_RESULT(no)
+               SPL_LINUX_TRY_COMPILE([
+                       #include <linux/fs.h>
+               ],[
+                       vfs_getattr((struct vfsmount *)NULL,
+                               (struct dentry *)NULL,
+                               (struct kstat *)NULL);
+               ],[
+                       AC_MSG_RESULT(3 args)
+               ],[
+                       AC_MSG_ERROR(unknown)
+               ])
        ])
 ])
 
 dnl #
-dnl # Proposed API change for legacy kernels.
-dnl # This symbol is not available in older kernels.  For kernels post
-dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
-dnl # page state information.  This symbol is only used in legacy kernels
-dnl # any only as a last resort.
-dnl
-AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
-       AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
+dnl # 2.6.36 API compatibility.
+dnl # Added usleep_range timer.
+dnl # usleep_range is a finer precision implementation of msleep
+dnl # designed to be a drop-in replacement for udelay where a precise
+dnl # sleep / busy-wait is unnecessary.
+dnl #
+AC_DEFUN([SPL_AC_USLEEP_RANGE], [
+       AC_MSG_CHECKING([whether usleep_range() is available])
        SPL_LINUX_TRY_COMPILE([
+               #include <linux/delay.h>
        ],[
-               #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
-               #error "global_page_state needs NR_FREE_PAGES"
-               #endif
-
-               #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
-                   !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
-                   !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
-               #error "global_page_state needs NR_ACTIVE*"
-               #endif
-
-               #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
-                   !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
-                   !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
-               #error "global_page_state needs NR_INACTIVE*"
-               #endif
-       ],[
-               AC_MSG_RESULT(no)
+               usleep_range(0, 0);
        ],[
                AC_MSG_RESULT(yes)
-               AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
-                         [get_zone_counts() is needed])
-
-               SPL_CHECK_SYMBOL_EXPORT(
-                       [get_zone_counts],
-                       [],
-                       [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
-                       [get_zone_counts() is available])],
-                       [])
+               AC_DEFINE(HAVE_USLEEP_RANGE, 1,
+                         [usleep_range is available])
+       ],[
+               AC_MSG_RESULT(no)
        ])
 ])
 
 dnl #
-dnl # Symbol available in RHEL kernels not in stock kernels.
+dnl # 2.6.35 API change,
+dnl # The cachep->gfpflags member was renamed cachep->allocflags.  These are
+dnl # private allocation flags which are applied when allocating a new slab
+dnl # in kmem_getpages().  Unfortunately there is no public API for setting
+dnl # non-default flags.
 dnl #
-AC_DEFUN([SPL_AC_SET_FS_PWD], [
-       SPL_CHECK_SYMBOL_EXPORT(
-               [set_fs_pwd],
-               [],
-               [AC_DEFINE(HAVE_SET_FS_PWD, 1,
-               [set_fs_pwd() is available])],
-               [])
-])
-
-dnl #
-dnl # 2.6.25 API change,
-dnl # Simplied API by replacing mnt+dentry args with a single path arg.
-dnl #
-AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
-       [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
+AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [
+       AC_MSG_CHECKING([whether struct kmem_cache has allocflags])
        SPL_LINUX_TRY_COMPILE([
-               #include <linux/sched.h>
-               #include <linux/fs_struct.h>
+               #include <linux/slab.h>
        ],[
-               set_fs_pwd(NULL, NULL);
+               struct kmem_cache cachep __attribute__ ((unused));
+               cachep.allocflags = GFP_KERNEL;
        ],[
                AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
-                         [set_fs_pwd() wants 2 args])
+               AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1,
+                       [struct kmem_cache has allocflags])
        ],[
                AC_MSG_RESULT(no)
+
+               AC_MSG_CHECKING([whether struct kmem_cache has gfpflags])
+               SPL_LINUX_TRY_COMPILE([
+                       #include <linux/slab.h>
+               ],[
+                       struct kmem_cache cachep __attribute__ ((unused));
+                       cachep.gfpflags = GFP_KERNEL;
+               ],[
+                       AC_MSG_RESULT(yes)
+                       AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1,
+                               [struct kmem_cache has gfpflags])
+               ],[
+                       AC_MSG_RESULT(no)
+               ])
        ])
 ])
 
 dnl #
-dnl # SLES API change, never adopted in mainline,
-dnl # Third 'struct vfsmount *' argument removed.
+dnl # 3.17 API change,
+dnl # wait_on_bit() no longer requires an action argument. The former
+dnl # "wait_on_bit" interface required an 'action' function to be provided
+dnl # which does the actual waiting. There were over 20 such functions in the
+dnl # kernel, many of them identical, though most cases can be satisfied by one
+dnl # of just two functions: one which uses io_schedule() and one which just
+dnl # uses schedule().  This API change was made to consolidate all of those
+dnl # redundant wait functions.
 dnl #
-AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
-       [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
+AC_DEFUN([SPL_AC_WAIT_ON_BIT], [
+       AC_MSG_CHECKING([whether wait_on_bit() takes an action])
        SPL_LINUX_TRY_COMPILE([
-               #include <linux/fs.h>
+               #include <linux/wait.h>
        ],[
-               vfs_unlink(NULL, NULL);
+               int (*action)(void *) = NULL;
+               wait_on_bit(NULL, 0, action, 0);
        ],[
                AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
-                         [vfs_unlink() wants 2 args])
+               AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes])
        ],[
                AC_MSG_RESULT(no)
        ])
 ])
 
 dnl #
-dnl # SLES API change, never adopted in mainline,
-dnl # Third and sixth 'struct vfsmount *' argument removed.
+dnl # 4.7 API change
+dnl # i_mutex is changed to i_rwsem. Instead of directly using
+dnl # i_mutex/i_rwsem, we should use inode_lock() and inode_lock_shared()
+dnl # We test inode_lock_shared because inode_lock is introduced earlier.
 dnl #
-AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
-       [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
+AC_DEFUN([SPL_AC_INODE_LOCK], [
+       AC_MSG_CHECKING([whether inode_lock_shared() exists])
+       tmp_flags="$EXTRA_KCFLAGS"
+       EXTRA_KCFLAGS="-Werror"
        SPL_LINUX_TRY_COMPILE([
                #include <linux/fs.h>
        ],[
-               vfs_rename(NULL, NULL, NULL, NULL);
+               struct inode *inode = NULL;
+               inode_lock_shared(inode);
        ],[
                AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
-                         [vfs_rename() wants 4 args])
+               AC_DEFINE(HAVE_INODE_LOCK_SHARED, 1, [yes])
        ],[
                AC_MSG_RESULT(no)
        ])
+       EXTRA_KCFLAGS="$tmp_flags"
 ])
 
 dnl #
-dnl # 2.6.29 API change,
-dnl # check whether 'struct cred' exists
+dnl # Check whether mutex has owner with task_struct type.
+dnl #
+dnl # Note that before Linux 3.0, mutex owner is of type thread_info.
+dnl #
+dnl # Note that in Linux 3.18, the condition for owner is changed from
+dnl # defined(CONFIG_DEBUG_MUTEXES) || defined(CONFIG_SMP) to
+dnl # defined(CONFIG_DEBUG_MUTEXES) || defined(CONFIG_MUTEX_SPIN_ON_OWNER)
 dnl #
-AC_DEFUN([SPL_AC_CRED_STRUCT], [
-       AC_MSG_CHECKING([whether struct cred exists])
+AC_DEFUN([SPL_AC_MUTEX_OWNER], [
+       AC_MSG_CHECKING([whether mutex has owner])
+       tmp_flags="$EXTRA_KCFLAGS"
+       EXTRA_KCFLAGS="-Werror"
        SPL_LINUX_TRY_COMPILE([
-               #include <linux/cred.h>
+               #include <linux/mutex.h>
+               #include <linux/spinlock.h>
        ],[
-               struct cred *cr;
-               cr  = NULL;
+               DEFINE_MUTEX(m);
+               struct task_struct *t __attribute__ ((unused));
+               t = m.owner;
        ],[
                AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
+               AC_DEFINE(HAVE_MUTEX_OWNER, 1, [yes])
        ],[
                AC_MSG_RESULT(no)
        ])
+       EXTRA_KCFLAGS="$tmp_flags"
 ])
 
 dnl #
-dnl # Custom SPL patch may export this symbol.
-dnl #
-AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
-       SPL_CHECK_SYMBOL_EXPORT(
-               [groups_search],
-               [],
-               [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
-               [groups_search() is available])],
-               [])
-])
-
-dnl #
-dnl # 2.6.x API change,
-dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
-dnl #
-AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
-       SPL_CHECK_SYMBOL_EXPORT(
-               [__put_task_struct],
-               [],
-               [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
-               [__put_task_struct() is available])],
-               [])
-])
-
-dnl #
-dnl # 2.6.32 API change,
-dnl # Unused 'struct file *' removed from prototype.
+dnl # 4.9 API change
+dnl # group_info changed from 2d array via >blocks to 1d array via ->gid
 dnl #
-AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
-       AC_MSG_CHECKING([whether proc_handler() wants 5 args])
+AC_DEFUN([SPL_AC_GROUP_INFO_GID], [
+       AC_MSG_CHECKING([whether group_info->gid exists])
+       tmp_flags="$EXTRA_KCFLAGS"
+       EXTRA_KCFLAGS="-Werror"
        SPL_LINUX_TRY_COMPILE([
-               #include <linux/sysctl.h>
+               #include <linux/cred.h>
        ],[
-               proc_dostring(NULL, 0, NULL, NULL, NULL);
+               struct group_info *gi = groups_alloc(1);
+               gi->gid[0] = KGIDT_INIT(0);
        ],[
                AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
-                         [proc_handler() wants 5 args])
+               AC_DEFINE(HAVE_GROUP_INFO_GID, 1, [group_info->gid exists])
        ],[
                AC_MSG_RESULT(no)
        ])
-])
-
-dnl #
-dnl # 2.6.x API change,
-dnl # kvasprintf() function added.
-dnl #
-AC_DEFUN([SPL_AC_KVASPRINTF], [
-       SPL_CHECK_SYMBOL_EXPORT(
-               [kvasprintf],
-               [],
-               [AC_DEFINE(HAVE_KVASPRINTF, 1,
-               [kvasprintf() is available])],
-               [])
+       EXTRA_KCFLAGS="$tmp_flags"
 ])