X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=config%2Fspl-build.m4;h=f54c5b166bb8eac72143d7d6988608dcbbecbc60;hb=80093b6f72408aee7e88abbf52537d9fc1feb008;hp=90ff680840fb6b248b13335f5b30d25424083984;hpb=5f6c14b1eda9c7b47d11a3b90e78dea6a7f429e0;p=mirror_spl-debian.git diff --git a/config/spl-build.m4 b/config/spl-build.m4 index 90ff680..f54c5b1 100644 --- a/config/spl-build.m4 +++ b/config/spl-build.m4 @@ -8,7 +8,6 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [ SPL_AC_KERNEL - SPL_AC_KERNEL_CONFIG if test "${LINUX_OBJ}" != "${LINUX}"; then KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ" @@ -19,13 +18,14 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [ AC_SUBST(KERNELCPPFLAGS) SPL_AC_DEBUG + SPL_AC_DEBUG_LOG 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_3ARGS_SHRINKER_CALLBACK @@ -33,6 +33,8 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [ SPL_AC_TASK_CURR SPL_AC_CTL_UNNUMBERED SPL_AC_CTL_NAME + SPL_AC_VMALLOC_INFO + SPL_AC_PDE_DATA SPL_AC_FLS64 SPL_AC_DEVICE_CREATE SPL_AC_5ARGS_DEVICE_CREATE @@ -41,8 +43,6 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [ 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 @@ -65,32 +65,40 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [ SPL_AC_GET_ZONE_COUNTS SPL_AC_USER_PATH_DIR SPL_AC_SET_FS_PWD - SPL_AC_2ARGS_SET_FS_PWD + SPL_AC_SET_FS_PWD_WITH_CONST SPL_AC_2ARGS_VFS_UNLINK SPL_AC_4ARGS_VFS_RENAME SPL_AC_VFS_FSYNC SPL_AC_2ARGS_VFS_FSYNC + SPL_AC_INODE_TRUNCATE_RANGE SPL_AC_FS_STRUCT_SPINLOCK SPL_AC_CRED_STRUCT + SPL_AC_KUIDGID_T SPL_AC_GROUPS_SEARCH SPL_AC_PUT_TASK_STRUCT SPL_AC_5ARGS_PROC_HANDLER SPL_AC_KVASPRINTF SPL_AC_EXPORTED_RWSEM_IS_LOCKED - SPL_AC_KERNEL_INVALIDATE_INODES - SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES + SPL_AC_KERNEL_FALLOCATE SPL_AC_SHRINK_DCACHE_MEMORY SPL_AC_SHRINK_ICACHE_MEMORY SPL_AC_KERN_PATH_PARENT_HEADER SPL_AC_KERN_PATH_PARENT_SYMBOL + SPL_AC_KERN_PATH_LOCKED + SPL_AC_CONFIG_KALLSYMS + 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_SCHED_RT_HEADER + SPL_AC_2ARGS_VFS_GETATTR ]) 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 @@ -100,7 +108,7 @@ AC_DEFUN([SPL_AC_MODULE_SYMVERS], [ if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then AC_MSG_ERROR([ *** Please make sure the kernel devel package for your distribution - *** is installed. If your building with a custom kernel make sure the + *** 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 @@ -132,18 +140,14 @@ AC_DEFUN([SPL_AC_KERNEL], [ 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 -n "$sourcelink" && test -e ${sourcelink}; then kernelsrc=`readlink -f ${sourcelink}` else - AC_MSG_RESULT([Not found]) - AC_MSG_ERROR([ - *** Please make sure the kernel devel package for your distribution - *** is installed then try again. If that fails you can specify the - *** location of the kernel source with the '--with-linux=PATH' option.]) + kernelsrc="[Not found]" fi else if test "$kernelsrc" = "NONE"; then @@ -152,6 +156,13 @@ 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 -e "/lib/modules/$(uname -r)/build"; then @@ -192,7 +203,13 @@ AC_DEFUN([SPL_AC_KERNEL], [ fi else AC_MSG_RESULT([Not found]) - AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.]) + 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]) @@ -208,13 +225,6 @@ AC_DEFUN([SPL_AC_KERNEL], [ SPL_AC_MODULE_SYMVERS ]) -AC_DEFUN([SPL_AC_KERNEL_CONFIG], [ - SPL_LINUX_CONFIG([PREEMPT], - AC_MSG_ERROR([ - *** Kernel built with CONFIG_PREEMPT which is not supported. - ** You must rebuild your kernel without this option.]), []) -]) - dnl # dnl # Default SPL user configuration dnl # @@ -222,9 +232,14 @@ 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 # 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/' directory and enabled using +dnl # the --with-spec= configure option. +dnl # AC_DEFUN([SPL_AC_RPM], [ RPM=rpm RPMBUILD=rpmbuild @@ -249,6 +264,25 @@ AC_DEFUN([SPL_AC_RPM], [ AC_MSG_RESULT([$HAVE_RPMBUILD]) ]) + RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_LOG) 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|fedora']), + [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) @@ -256,6 +290,16 @@ AC_DEFUN([SPL_AC_RPM], [ 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 # @@ -297,48 +341,6 @@ AC_DEFUN([SPL_AC_DPKG], [ AC_SUBST(DPKGBUILD_VERSION) ]) -dnl # -dnl # Check for pacman+makepkg to build Arch Linux packages. If these -dnl # tools are missing it is non-fatal but you will not be able to -dnl # build Arch Linux packages and will be warned if you try too. -dnl # -AC_DEFUN([SPL_AC_PACMAN], [ - PACMAN=pacman - MAKEPKG=makepkg - - AC_MSG_CHECKING([whether $PACMAN is available]) - tmp=$($PACMAN --version 2>/dev/null) - AS_IF([test -n "$tmp"], [ - PACMAN_VERSION=$(echo $tmp | - $AWK '/Pacman/ { print $[3] }' | - $SED 's/^v//') - HAVE_PACMAN=yes - AC_MSG_RESULT([$HAVE_PACMAN ($PACMAN_VERSION)]) - ],[ - HAVE_PACMAN=no - AC_MSG_RESULT([$HAVE_PACMAN]) - ]) - - AC_MSG_CHECKING([whether $MAKEPKG is available]) - tmp=$($MAKEPKG --version 2>/dev/null) - AS_IF([test -n "$tmp"], [ - MAKEPKG_VERSION=$(echo $tmp | $AWK '/makepkg/ { print $[3] }') - HAVE_MAKEPKG=yes - AC_MSG_RESULT([$HAVE_MAKEPKG ($MAKEPKG_VERSION)]) - ],[ - HAVE_MAKEPKG=no - AC_MSG_RESULT([$HAVE_MAKEPKG]) - ]) - - AC_SUBST(HAVE_PACMAN) - AC_SUBST(PACMAN) - AC_SUBST(PACMAN_VERSION) - - AC_SUBST(HAVE_MAKEPKG) - AC_SUBST(MAKEPKG) - AC_SUBST(MAKEPKG_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 @@ -369,22 +371,26 @@ 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/redhat-release ; then - VENDOR=redhat ; + 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/lsb-release ; then - VENDOR=ubuntu ; - elif test -f /etc/debian_version ; then - VENDOR=debian ; elif test -f /etc/SuSE-release ; then VENDOR=sles ; elif test -f /etc/slackware-version ; then VENDOR=slackware ; - elif test -f /etc/gentoo-release ; then - VENDOR=gentoo ; + 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 @@ -393,14 +399,17 @@ AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [ AC_MSG_CHECKING([default package type]) case "$VENDOR" in - fedora) DEFAULT_PACKAGE=rpm ;; - redhat) DEFAULT_PACKAGE=rpm ;; - sles) DEFAULT_PACKAGE=rpm ;; - ubuntu) DEFAULT_PACKAGE=deb ;; - debian) DEFAULT_PACKAGE=deb ;; - slackware) DEFAULT_PACKAGE=tgz ;; - arch) DEFAULT_PACKAGE=arch;; - *) DEFAULT_PACKAGE=rpm ;; + 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]) @@ -411,11 +420,10 @@ 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 - SPL_AC_PACMAN - SPL_AC_DEFAULT_PACKAGE ]) AC_DEFUN([SPL_AC_LICENSE], [ @@ -427,34 +435,38 @@ AC_DEFUN([SPL_AC_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 + *) + 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]) + 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 # @@ -473,16 +485,51 @@ AC_DEFUN([SPL_AC_DEBUG], [ [ KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror" DEBUG_CFLAGS="-DDEBUG -Werror" - ], - [ + DEBUG_SPL="_with_debug" + ], [ KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG" DEBUG_CFLAGS="-DNDEBUG" + DEBUG_SPL="_without_debug" ]) AC_SUBST(DEBUG_CFLAGS) + AC_SUBST(DEBUG_SPL) AC_MSG_RESULT([$enable_debug]) ]) +dnl # +dnl # Enabled by default it provides a basic debug log infrastructure. +dnl # Each subsystem registers itself with a name and logs messages +dnl # using predefined types. If the debug mask it set to allow the +dnl # message type it will be written to the internal log. The log +dnl # can be dumped to a file by echoing 1 to the 'dump' proc entry, +dnl # after dumping the log it must be decoded using the spl utility. +dnl # +dnl # echo 1 >/proc/sys/kernel/spl/debug/dump +dnl # spl /tmp/spl-log.xxx.yyy /tmp/spl-log.xxx.yyy.txt +dnl # +AC_DEFUN([SPL_AC_DEBUG_LOG], [ + AC_ARG_ENABLE([debug-log], + [AS_HELP_STRING([--enable-debug-log], + [Enable basic debug logging @<:@default=yes@:>@])], + [], + [enable_debug_log=yes]) + + AS_IF([test "x$enable_debug_log" = xyes], + [ + KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG" + DEBUG_LOG="_with_debug_log" + AC_DEFINE([DEBUG_LOG], [1], + [Define to 1 to enable basic debug logging]) + ], [ + DEBUG_LOG="_without_debug_log" + ]) + + AC_SUBST(DEBUG_LOG) + AC_MSG_CHECKING([whether basic debug logging is enabled]) + AC_MSG_RESULT([$enable_debug_log]) +]) + 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. @@ -498,10 +545,16 @@ AC_DEFUN([SPL_AC_DEBUG_KMEM], [ [enable_debug_kmem=yes]) 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]) ]) @@ -523,10 +576,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]) ]) @@ -561,12 +620,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 ]) @@ -582,32 +643,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([ - #include - ],[ - #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=$? @@ -617,24 +657,42 @@ 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 - AC_MSG_RESULT([yes]) + 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. @@ -645,10 +703,10 @@ AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [ for file in $3; do grep -q "$2" "$LINUX/$file" 2>/dev/null rc=$? - if test $rc -eq 0; then - header=1 - break; - fi + if test $rc -eq 0; then + header=1 + break; + fi done if test $header -eq 0; then AC_MSG_RESULT([no]) @@ -679,6 +737,25 @@ AC_DEFUN([SPL_CHECK_HEADER], ]) ]) +dnl # +dnl # Basic toolchain sanity check. +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 + ]) +]) + dnl # dnl # Use the atomic implemenation based on global spinlocks. This dnl # should only be needed by 32-bit kernels which do not provide @@ -695,7 +772,7 @@ AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [ [enable_atomic_spinlocks=check]) SPL_LINUX_TRY_COMPILE([ - #include + #include ],[ atomic64_t *ptr __attribute__ ((unused)); ],[ @@ -738,8 +815,7 @@ dnl # AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG], [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg]) SPL_LINUX_TRY_COMPILE([ - #include - #include + #include ],[ atomic64_cmpxchg((atomic64_t *)NULL, 0, 0); ],[ @@ -758,7 +834,7 @@ dnl # AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG], [AC_MSG_CHECKING([whether kernel defines atomic64_xchg]) SPL_LINUX_TRY_COMPILE([ - #include + #include ],[ atomic64_xchg((atomic64_t *)NULL, 0); ],[ @@ -789,26 +865,6 @@ AC_DEFUN([SPL_AC_TYPE_UINTPTR_T], ]) ]) -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 - ],[ - struct work_struct work __attribute__ ((unused)); - INIT_WORK(&work, NULL, NULL); - ],[ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1, - [INIT_WORK wants 3 args]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - dnl # dnl # 2.6.21 API change, dnl # 'register_sysctl_table' use only one argument instead of two @@ -900,10 +956,18 @@ AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA], 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])], - []) +AC_DEFUN([SPL_AC_TASK_CURR], + [AC_MSG_CHECKING([whether task_curr() is available]) + SPL_LINUX_TRY_COMPILE_SYMBOL([ + #include + ], [ + task_curr(NULL); + ], [task_curr], [kernel/sched.c], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() is available]) + ], [ + AC_MSG_RESULT(no) + ]) ]) dnl # @@ -969,13 +1033,15 @@ 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])], - []) +AC_DEFUN([SPL_AC_DEVICE_CREATE], + [AC_MSG_CHECKING([whether device_create() is available]) + SPL_CHECK_SYMBOL_EXPORT([device_create], [drivers/base/core.c], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_DEVICE_CREATE, 1, + [device_create() is available]) + ], [ + AC_MSG_RESULT(no) + ]) ]) dnl # @@ -1005,25 +1071,37 @@ 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])], - []) +AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], + [AC_MSG_CHECKING([whether class_device_create() is available]) + SPL_LINUX_TRY_COMPILE_SYMBOL([ + #include + ], [ + class_device_create(NULL, NULL, 0, NULL, NULL); + ], [class_device_create], [drivers/base/class.c], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1, + [class_device_create() is available]) + ], [ + AC_MSG_RESULT(no) + ]) ]) 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])], - []) +AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], + [AC_MSG_CHECKING([whether set_normalized_timespec() is available as export]) + SPL_LINUX_TRY_COMPILE_SYMBOL([ + #include + ], [ + set_normalized_timespec(NULL, 0, 0); + ], [set_normalized_timespec], [kernel/time.c], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1, + [set_normalized_timespec() is available as export]) + ], [ + AC_MSG_RESULT(no) + ]) ]) dnl # @@ -1087,38 +1165,6 @@ AC_DEFUN([SPL_AC_INIT_UTSNAME], [ ]) ]) -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 # -AC_DEFUN([SPL_AC_FILES_FDTABLE], [ - AC_MSG_CHECKING([whether files_fdtable() is available]) - SPL_LINUX_TRY_COMPILE([ - #include - #include - #ifdef HAVE_FDTABLE_HEADER - #include - #endif - ],[ - struct files_struct *files = current->files; - struct fdtable *fdt __attribute__ ((unused)); - fdt = files_fdtable(files); - ],[ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - dnl # dnl # 2.6.18 API change, dnl # added linux/uaccess.h @@ -1151,13 +1197,19 @@ 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])], - []) +AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], + [AC_MSG_CHECKING([whether monotonic_clock() is available]) + SPL_LINUX_TRY_COMPILE_SYMBOL([ + #include + ], [ + monotonic_clock(); + ], [monotonic_clock], [], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1, + [monotonic_clock() is available]) + ], [ + AC_MSG_RESULT(no) + ]) ]) dnl # @@ -1212,6 +1264,7 @@ AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [ EXTRA_KCFLAGS="-Werror" SPL_LINUX_TRY_COMPILE([ #include + #include ],[ struct mutex mtx __attribute__ ((unused)); mtx.owner = current; @@ -1255,9 +1308,12 @@ dnl # AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [ AC_MSG_CHECKING([whether on_each_cpu() wants 3 args]) SPL_LINUX_TRY_COMPILE([ + #include #include + + void on_each_cpu_func(void *data) { return; } ],[ - on_each_cpu(NULL, NULL, 0); + on_each_cpu(on_each_cpu_func, NULL, 0); ],[ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1, @@ -1271,13 +1327,19 @@ dnl # dnl # 2.6.18 API change, dnl # kallsyms_lookup_name no longer exported 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])], - []) +AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], + [AC_MSG_CHECKING([whether kallsyms_lookup_name() is available]) + SPL_LINUX_TRY_COMPILE_SYMBOL([ + #include + ], [ + kallsyms_lookup_name(NULL); + ], [kallsyms_lookup_name], [], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1, + [kallsyms_lookup_name() is available]) + ], [ + AC_MSG_RESULT(no) + ]) ]) dnl # @@ -1287,13 +1349,52 @@ 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])], - []) +AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], + [AC_MSG_CHECKING([whether get_vmalloc_info() is available]) + SPL_CHECK_SYMBOL_EXPORT([get_vmalloc_info], [], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1, + [get_vmalloc_info() is available]) + ], [ + AC_MSG_RESULT(no) + ]) +]) + +dnl # +dnl # 3.10 API change, +dnl # struct vmalloc_info is now declared in linux/vmalloc.h +dnl # +AC_DEFUN([SPL_AC_VMALLOC_INFO], [ + AC_MSG_CHECKING([whether struct vmalloc_info is declared]) + SPL_LINUX_TRY_COMPILE([ + #include + struct vmalloc_info { void *a; }; + ],[ + return 0; + ],[ + AC_MSG_RESULT(no) + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_VMALLOC_INFO, 1, [yes]) + ]) +]) + +dnl # +dnl # 3.10 API change, +dnl # PDE is replaced by PDE_DATA +dnl # +AC_DEFUN([SPL_AC_PDE_DATA], [ + AC_MSG_CHECKING([whether PDE_DATA() is available]) + SPL_LINUX_TRY_COMPILE_SYMBOL([ + #include + ], [ + PDE_DATA(NULL); + ], [PDE_DATA], [], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_PDE_DATA, 1, [yes]) + ],[ + AC_MSG_RESULT(no) + ]) ]) dnl # @@ -1315,7 +1416,7 @@ AC_DEFUN([SPL_AC_PGDAT_HELPERS], [ rc=$? if test $rc -eq 0; then AC_MSG_RESULT([yes]) - AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available]) + AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available]) else AC_MSG_RESULT([no]) fi @@ -1328,13 +1429,19 @@ 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])], - []) +AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], + [AC_MSG_CHECKING([whether first_online_pgdat() is available]) + SPL_LINUX_TRY_COMPILE_SYMBOL([ + #include + ], [ + first_online_pgdat(); + ], [first_online_pgdat], [], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1, + [first_online_pgdat() is available]) + ], [ + AC_MSG_RESULT(no) + ]) ]) dnl # @@ -1344,13 +1451,19 @@ 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])], - []) +AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], + [AC_MSG_CHECKING([whether next_online_pgdat() is available]) + SPL_LINUX_TRY_COMPILE_SYMBOL([ + #include + ], [ + next_online_pgdat(NULL); + ], [next_online_pgdat], [], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1, + [next_online_pgdat() is available]) + ], [ + AC_MSG_RESULT(no) + ]) ]) dnl # @@ -1360,26 +1473,35 @@ 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_DEFUN([SPL_AC_NEXT_ZONE], + [AC_MSG_CHECKING([whether next_zone() is available]) + SPL_LINUX_TRY_COMPILE_SYMBOL([ + #include + ], [ + next_zone(NULL); + ], [next_zone], [], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_NEXT_ZONE, 1, [next_zone() is available]) + ], [ + AC_MSG_RESULT(no) + ]) ]) dnl # dnl # 2.6.17 API change, dnl # See SPL_AC_PGDAT_HELPERS for details. 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_PGDAT_LIST], + [AC_MSG_CHECKING([whether pgdat_list is available]) + SPL_LINUX_TRY_COMPILE_SYMBOL([ + #include + pg_data_t *tmp = pgdat_list; + ], [], [pgdat_list], [], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_PGDAT_LIST, 1, [pgdat_list is available]) + ], [ + AC_MSG_RESULT(no) + ]) ]) dnl # @@ -1571,12 +1693,18 @@ AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [ 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_MSG_CHECKING([whether get_zone_counts() is available]) + SPL_LINUX_TRY_COMPILE_SYMBOL([ + #include + ], [ + get_zone_counts(NULL, NULL, NULL); + ], [get_zone_counts], [], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1, + [get_zone_counts() is available]) + ], [ + AC_MSG_RESULT(no) + ]) ]) ]) @@ -1584,45 +1712,77 @@ dnl # dnl # 2.6.27 API change, dnl # The user_path_dir() replaces __user_walk() dnl # -AC_DEFUN([SPL_AC_USER_PATH_DIR], [ - SPL_CHECK_SYMBOL_EXPORT( - [user_path_at], - [], - [AC_DEFINE(HAVE_USER_PATH_DIR, 1, - [user_path_dir() is available])], - []) +AC_DEFUN([SPL_AC_USER_PATH_DIR], + [AC_MSG_CHECKING([whether user_path_dir() is available]) + SPL_LINUX_TRY_COMPILE_SYMBOL([ + #include + #include + ], [ + user_path_dir(NULL, NULL); + ], [user_path_at], [], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_USER_PATH_DIR, 1, [user_path_dir() is available]) + ], [ + AC_MSG_RESULT(no) + ]) ]) dnl # dnl # Symbol available in RHEL kernels not in stock kernels. 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])], - []) +AC_DEFUN([SPL_AC_SET_FS_PWD], + [AC_MSG_CHECKING([whether set_fs_pwd() is available]) + SPL_LINUX_TRY_COMPILE_SYMBOL([ + #include + #include + ], [ + (void) set_fs_pwd; + ], [set_fs_pwd], [], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_SET_FS_PWD, 1, [set_fs_pwd() is available]) + ], [ + AC_MSG_RESULT(no) + ]) ]) dnl # -dnl # 2.6.25 API change, -dnl # Simplied API by replacing mnt+dentry args with a single path arg. +dnl # 3.9 API change +dnl # set_fs_pwd takes const struct path * dnl # -AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD], - [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args]) +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 + #include #include + #include + void (*const set_fs_pwd_func) + (struct fs_struct *, const struct path *) + = set_fs_pwd; ],[ - set_fs_pwd(NULL, NULL); + return 0; ],[ AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1, - [set_fs_pwd() wants 2 args]) - ],[ - AC_MSG_RESULT(no) + AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1, + [set_fs_pwd() needs const path *]) + ],[ + SPL_LINUX_TRY_COMPILE([ + #include + #include + #include + 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 # @@ -1707,29 +1867,77 @@ AC_DEFUN([SPL_AC_CRED_STRUCT], [ ]) ]) + +dnl # +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_KUIDGID_T], [ + AC_MSG_CHECKING([whether kuid_t/kgid_t is available]) + SPL_LINUX_TRY_COMPILE([ + #include + ], [ + kuid_t userid = KUIDT_INIT(0); + kgid_t groupid = KGIDT_INIT(0); + ],[ + SPL_LINUX_TRY_COMPILE([ + #include + ], [ + 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 # 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])], - []) +AC_DEFUN([SPL_AC_GROUPS_SEARCH], + [AC_MSG_CHECKING([whether groups_search() is available]) + SPL_LINUX_TRY_COMPILE_SYMBOL([ + #include + #ifdef HAVE_KUIDGID_T + #include + #endif + ], [ + #ifdef HAVE_KUIDGID_T + groups_search(NULL, KGIDT_INIT(0)); + #else + groups_search(NULL, 0); + #endif + ], [groups_search], [], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_GROUPS_SEARCH, 1, [groups_search() is available]) + ], [ + AC_MSG_RESULT(no) + ]) ]) 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])], - []) +AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], + [AC_MSG_CHECKING([whether __put_task_struct() is available]) + SPL_LINUX_TRY_COMPILE_SYMBOL([ + #include + ], [ + __put_task_struct(NULL); + ], [__put_task_struct], [], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1, + [__put_task_struct() is available]) + ], [ + AC_MSG_RESULT(no) + ]) ]) dnl # @@ -1755,25 +1963,36 @@ 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])], - []) +AC_DEFUN([SPL_AC_KVASPRINTF], + [AC_MSG_CHECKING([whether kvasprintf() is available]) + SPL_LINUX_TRY_COMPILE_SYMBOL([ + #include + ], [ + kvasprintf(0, NULL, *((va_list*)NULL)); + ], [kvasprintf], [], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_KVASPRINTF, 1, [kvasprintf() is available]) + ], [ + AC_MSG_RESULT(no) + ]) ]) dnl # dnl # 2.6.29 API change, dnl # vfs_fsync() funcation added, prior to this use file_fsync(). dnl # -AC_DEFUN([SPL_AC_VFS_FSYNC], [ - SPL_CHECK_SYMBOL_EXPORT( - [vfs_fsync], - [fs/sync.c], - [AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])], - []) +AC_DEFUN([SPL_AC_VFS_FSYNC], + [AC_MSG_CHECKING([whether vfs_fsync() is available]) + SPL_LINUX_TRY_COMPILE_SYMBOL([ + #include + ], [ + (void) vfs_fsync; + ], [vfs_fsync], [fs/sync.c], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available]) + ], [ + AC_MSG_RESULT(no) + ]) ]) dnl # @@ -1795,92 +2014,135 @@ AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [ ]) dnl # -dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5. -dnl # Earlier versions of rwsem_is_locked() were inline and had a race -dnl # condition. The fixed version is exported as a symbol. The race -dnl # condition is fixed by acquiring sem->wait_lock, so we must not -dnl # call that version while holding sem->wait_lock. +dnl # 3.5 API change, +dnl # inode_operations.truncate_range removed dnl # -AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED], [ - SPL_CHECK_SYMBOL_EXPORT( - [rwsem_is_locked], - [lib/rwsem-spinlock.c], - [AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1, - [rwsem_is_locked() acquires sem->wait_lock])], - []) +AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [ + AC_MSG_CHECKING([whether truncate_range() inode operation is available]) + SPL_LINUX_TRY_COMPILE([ + #include + ],[ + struct inode_operations ops; + ops.truncate_range = NULL; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1, + [truncate_range() inode operation is available]) + ],[ + AC_MSG_RESULT(no) + ]) ]) dnl # -dnl # 2.6.37 API compat, -dnl # The function invalidate_inodes() is no longer exported by the kernel. -dnl # The prototype however is still available which means it is safe -dnl # to acquire the symbol's address using spl_kallsyms_lookup_name(). +dnl # Linux 2.6.38 - 3.x API dnl # -dnl # The Proxmox VE kernel contains a patch which renames the function -dnl # invalidate_inodes() to invalidate_inodes_check(). In the process -dnl # it adds a 'check' argument and a '#define invalidate_inodes(x)' -dnl # compatibility wrapper for legacy callers. Therefore, if either -dnl # of these functions are exported invalidate_inodes() can be -dnl # safely used. +AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [ + AC_MSG_CHECKING([whether fops->fallocate() exists]) + SPL_LINUX_TRY_COMPILE([ + #include + ],[ + 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_FILE_FALLOCATE, 1, [fops->fallocate() exists]) + ],[ + AC_MSG_RESULT(no) + ]) +]) + dnl # -AC_DEFUN([SPL_AC_KERNEL_INVALIDATE_INODES], [ - SPL_CHECK_SYMBOL_EXPORT( - [invalidate_inodes], - [], - [AC_DEFINE(HAVE_INVALIDATE_INODES, 1, - [invalidate_inodes() is available])], - []) - SPL_CHECK_SYMBOL_EXPORT( - [invalidate_inodes_check], - [], - [AC_DEFINE(HAVE_INVALIDATE_INODES_CHECK, 1, - [invalidate_inodes_check() is available])], - []) +dnl # Linux 2.6.x - 2.6.37 API +dnl # +AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [ + AC_MSG_CHECKING([whether iops->fallocate() exists]) + SPL_LINUX_TRY_COMPILE([ + #include + ],[ + 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_INODE_FALLOCATE, 1, [fops->fallocate() exists]) + ],[ + AC_MSG_RESULT(no) + ]) ]) dnl # -dnl # 2.6.39 API compat, -dnl # The function invalidate_inodes() now take 2 arguments. The second -dnl # 'kill_dirty' argument describes how invalidate_inodes() should -dnl # handle dirty inodes. Only when set will dirty inodes be discarded, -dnl # otherwise they will be handled as busy. -dnl # -dnl # Unfortunately, we don't have access to the invalidate_inodes() -dnl # prototype so it's not easy to check how many arguments it takes. -dnl # However, this change was done for the benefit of invalidate_device() -dnl # which also added an argument. The invalidate_device() symbol does -dnl # exist in the development headers so if it takes two arguments we -dnl # can fairly safely infer that invalidate_inodes() takes two arguments -dnl # as well. See commit 93b270f76e7ef3b81001576860c2701931cdc78b. -dnl # -AC_DEFUN([SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES], - [AC_MSG_CHECKING([whether invalidate_inodes() wants 2 args]) +dnl # PaX Linux 2.6.38 - 3.x API +dnl # +AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [ + AC_MSG_CHECKING([whether fops->fallocate() exists]) SPL_LINUX_TRY_COMPILE([ #include ],[ - return __invalidate_device(NULL, 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_2ARGS_INVALIDATE_INODES, 1, - [invalidate_inodes() wants 2 args]) + AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists]) ],[ AC_MSG_RESULT(no) ]) ]) +dnl # +dnl # The fallocate callback was moved from the inode_operations +dnl # structure to the file_operations structure. +dnl # +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.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5. +dnl # Earlier versions of rwsem_is_locked() were inline and had a race +dnl # condition. The fixed version is exported as a symbol. The race +dnl # condition is fixed by acquiring sem->wait_lock, so we must not +dnl # call that version while holding sem->wait_lock. +dnl # +AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED], + [AC_MSG_CHECKING([whether rwsem_is_locked() acquires sem->wait_lock]) + SPL_LINUX_TRY_COMPILE_SYMBOL([ + #include + int rwsem_is_locked(struct rw_semaphore *sem) { return 0; } + ], [], [rwsem_is_locked], [lib/rwsem-spinlock.c], [ + AC_MSG_RESULT(yes) + AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1, + [rwsem_is_locked() acquires sem->wait_lock]) + ], [ + AC_MSG_RESULT(no) + ]) +]) + dnl # dnl # 2.6.xx API compat, dnl # There currently exists no exposed API to partially shrink the dcache. dnl # The expected mechanism to shrink the cache is a registered shrinker dnl # which is called during memory pressure. dnl # -AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY], [ - SPL_CHECK_SYMBOL_EXPORT( - [shrink_dcache_memory], - [fs/dcache.c], - [AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1, - [shrink_dcache_memory() is available])], - []) +AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY], + [AC_MSG_CHECKING([whether shrink_dcache_memory() is available]) + SPL_LINUX_TRY_COMPILE_SYMBOL([ + #include + ], [ + shrink_dcache_memory(0, 0); + ], [shrink_dcache_memory], [fs/dcache.c], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1, + [shrink_dcache_memory() is available]) + ], [ + AC_MSG_RESULT(no) + ]) ]) dnl # @@ -1889,13 +2151,19 @@ dnl # There currently exists no exposed API to partially shrink the icache. dnl # The expected mechanism to shrink the cache is a registered shrinker dnl # which is called during memory pressure. dnl # -AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY], [ - SPL_CHECK_SYMBOL_EXPORT( - [shrink_icache_memory], - [fs/inode.c], - [AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1, - [shrink_icache_memory() is available])], - []) +AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY], + [AC_MSG_CHECKING([whether shrink_icache_memory() is available]) + SPL_LINUX_TRY_COMPILE_SYMBOL([ + #include + ], [ + shrink_icache_memory(0, 0); + ], [shrink_icache_memory], [fs/inode.c], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1, + [shrink_icache_memory() is available]) + ], [ + AC_MSG_RESULT(no) + ]) ]) dnl # @@ -1921,15 +2189,98 @@ dnl # The kern_path_parent() symbol is no longer exported by the kernel. dnl # However, it remains the prefered interface and since we still have dnl # access to the prototype we dynamically lookup the required address. dnl # -AC_DEFUN([SPL_AC_KERN_PATH_PARENT_SYMBOL], [ - SPL_CHECK_SYMBOL_EXPORT( - [kern_path_parent], - [fs/namei.c], - [AC_DEFINE(HAVE_KERN_PATH_PARENT_SYMBOL, 1, - [kern_path_parent() is available])], +AC_DEFUN([SPL_AC_KERN_PATH_PARENT_SYMBOL], + [AC_MSG_CHECKING([whether kern_path_parent() is available]) + SPL_LINUX_TRY_COMPILE_SYMBOL([ + #include + ], [ + kern_path_parent(NULL, NULL); + ], [kern_path_parent], [fs/namei.c], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_KERN_PATH_PARENT_SYMBOL, 1, + [kern_path_parent() is available]) + ], [ + AC_MSG_RESULT(no) + ]) +]) + +dnl # +dnl # 3.6 API compat, +dnl # The kern_path_parent() function was replaced by the kern_path_locked() +dnl # function to eliminate all struct nameidata usage outside fs/namei.c. +dnl # +AC_DEFUN([SPL_AC_KERN_PATH_LOCKED], [ + SPL_CHECK_SYMBOL_HEADER( + [kern_path_locked], + [struct dentry \*kern_path_locked(const char \*, struct path \*)], + [include/linux/namei.h], + [AC_DEFINE(HAVE_KERN_PATH_LOCKED, 1, + [kern_path_locked() is available])], []) ]) +dnl # +dnl # /proc/kallsyms support, +dnl # Verify the kernel has CONFIG_KALLSYMS support enabled. +dnl # +AC_DEFUN([SPL_AC_CONFIG_KALLSYMS], [ + AC_MSG_CHECKING([whether CONFIG_KALLSYMS is defined]) + SPL_LINUX_TRY_COMPILE([ + #if !defined(CONFIG_KALLSYMS) + #error CONFIG_KALLSYMS not defined + #endif + ],[ ],[ + AC_MSG_RESULT([yes]) + ],[ + AC_MSG_RESULT([no]) + AC_MSG_ERROR([ + *** This kernel does not include the required kallsyms support. + *** Rebuild the kernel with CONFIG_KALLSYMS=y set.]) + ]) +]) + +dnl # +dnl # zlib inflate compat, +dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled. +dnl # +AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [ + AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined]) + SPL_LINUX_TRY_COMPILE([ + #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_ERROR([ + *** This kernel does not include the required zlib inflate support. + *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.]) + ]) +]) + +dnl # +dnl # zlib deflate compat, +dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled. +dnl # +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_MSG_RESULT([no]) + 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.39 API compat, dnl # The function zlib_deflate_workspacesize() now take 2 arguments. @@ -1973,3 +2324,79 @@ AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [ AC_MSG_RESULT(no) ]) ]) + +dnl # +dnl # 3.1 API Change +dnl # +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_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 + ],[ + 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(RWSEM_SPINLOCK_IS_RAW, 1, + [struct rw_semaphore member wait_lock is raw_spinlock_t]) + ],[ + AC_MSG_RESULT(no) + ]) + EXTRA_KCFLAGS="$tmp_flags" +]) + +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 + #include + ],[ + return 0; + ],[ + AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists]) + AC_MSG_RESULT(yes) + ],[ + AC_MSG_RESULT(no) + ]) +]) + +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 + ],[ + vfs_getattr((struct path *) NULL, + (struct kstat *)NULL); + ],[ + AC_MSG_RESULT(2 args) + AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1, + [vfs_getattr wants 2 args]) + ],[ + SPL_LINUX_TRY_COMPILE([ + #include + ],[ + vfs_getattr((struct vfsmount *)NULL, + (struct dentry *)NULL, + (struct kstat *)NULL); + ],[ + AC_MSG_RESULT(3 args) + ],[ + AC_MSG_ERROR(unknown) + ]) + ]) +])