From 57d862349b074974825e1228b7b51ac72e4ba2b3 Mon Sep 17 00:00:00 2001 From: behlendo Date: Mon, 2 Jun 2008 17:28:49 +0000 Subject: [PATCH] Breaking the world for a little bit. If anyone is going to continue working on this branch for the next few days I suggested you work off of the 0.3.1 tag. The following changes are fairly extensive and are designed to make the SPL compatible with all kernels in the range of 2.6.18-2.6.25. There were 13 relevant API changes between these releases and I have added the needed autoconf tests to check for them. However, this has not all been tested extensively. I'll sort of the breakage on Fedora Core 9 and RHEL5 this week. SPL_AC_TYPE_UINTPTR_T SPL_AC_TYPE_KMEM_CACHE_T SPL_AC_KMEM_CACHE_DESTROY_INT SPL_AC_ATOMIC_PANIC_NOTIFIER SPL_AC_3ARGS_INIT_WORK SPL_AC_2ARGS_REGISTER_SYSCTL SPL_AC_KMEM_CACHE_T SPL_AC_KMEM_CACHE_CREATE_DTOR SPL_AC_3ARG_KMEM_CACHE_CREATE_CTOR SPL_AC_SET_SHRINKER SPL_AC_PATH_IN_NAMEIDATA SPL_AC_TASK_CURR SPL_AC_CTL_UNNUMBERED git-svn-id: https://outreach.scidac.gov/svn/spl/trunk@119 7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c --- ChangeLog | 5 + autoconf/spl-build.m4 | 541 ++++++++++++++++++++++++++++++++++++ autogen.sh | 4 +- configure.ac | 194 ++----------- include/sys/kmem.h | 13 +- include/sys/proc.h | 9 + include/sys/sysmacros.h | 12 + include/sys/types.h | 10 +- include/sys/vnode.h | 9 + lib/list.c | 2 +- modules/Makefile.in | 4 +- modules/spl/Makefile.in | 2 +- modules/spl/spl-debug.c | 14 +- modules/spl/spl-err.c | 1 - modules/spl/spl-generic.c | 3 +- modules/spl/spl-kmem.c | 93 ++++++- modules/spl/spl-kobj.c | 1 - modules/spl/spl-module.c | 1 - modules/spl/spl-mutex.c | 5 + modules/spl/spl-proc.c | 72 ++++- modules/spl/spl-time.c | 1 - modules/spl/spl-vnode.c | 40 +-- modules/splat/Makefile.in | 3 +- modules/splat/splat-ctl.c | 1 - modules/splat/splat-mutex.c | 16 +- 25 files changed, 809 insertions(+), 247 deletions(-) create mode 100644 autoconf/spl-build.m4 diff --git a/ChangeLog b/ChangeLog index 7d45205530..6ce192e2cd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-05-25 Brian Behlendorf + + * configure.ac, autoconf/* : Initial pass at resolving + API changes introduced by kernels newer than 2.6.18. + 2008-05-21 Brian Behlendorf * : Tag spl-0.3.1 diff --git a/autoconf/spl-build.m4 b/autoconf/spl-build.m4 new file mode 100644 index 0000000000..d2d476d4f2 --- /dev/null +++ b/autoconf/spl-build.m4 @@ -0,0 +1,541 @@ +AC_DEFUN([SPL_AC_KERNEL], [ + ver=`uname -r` + + AC_ARG_WITH([linux], + AS_HELP_STRING([--with-linux=PATH], + [Path to kernel source]), + [kernelsrc="$withval"; kernelbuild="$withval"]) + + AC_ARG_WITH([linux-obj], + AS_HELP_STRING([--with-linux-obj=PATH], + [Path to kernel build objects]), + [kernelbuild="$withval"]) + + AC_MSG_CHECKING([kernel source directory]) + if test -z "$kernelsrc"; then + kernelbuild= + sourcelink=/lib/modules/${ver}/source + buildlink=/lib/modules/${ver}/build + + if test -e $sourcelink; then + kernelsrc=`(cd $sourcelink; /bin/pwd)` + fi + if test -e $buildlink; then + kernelbuild=`(cd $buildlink; /bin/pwd)` + fi + if test -z "$kernelsrc"; then + kernelsrc=$kernelbuild + fi + if test -z "$kernelsrc" -o -z "$kernelbuild"; then + AC_MSG_RESULT([Not found]) + AC_MSG_ERROR([ + *** Please specify the location of the kernel source + *** with the '--with-kernel=PATH' option]) + fi + fi + + AC_MSG_RESULT([$kernelsrc]) + AC_MSG_CHECKING([kernel build directory]) + 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 "; + 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 + + kernsrcver=`(echo "#include "; + echo "kernsrcver=UTS_RELEASE") | + cpp -I $kernelbuild/include | + grep "^kernsrcver=" | cut -d \" -f 2` + fi + + if test -z "$kernsrcver"; then + 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]) + fi + + AC_MSG_RESULT([$kernsrcver]) + + kmoduledir=${INSTALL_MOD_PATH}/lib/modules/$kernsrcver + LINUX=${kernelsrc} + LINUX_OBJ=${kernelbuild} + + AC_SUBST(LINUX) + AC_SUBST(LINUX_OBJ) + AC_SUBST(kmoduledir) +]) + +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 off)]), + [ case "$enableval" in + yes) spl_ac_debug=yes ;; + no) spl_ac_debug=no ;; + *) AC_MSG_RESULT([Error!]) + AC_MSG_ERROR([Bad value "$enableval" for --enable-debug]) ;; + esac ] + ) + if test "$spl_ac_debug" = yes; then + KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG" + else + KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG" + AC_DEFINE([NDEBUG], [1], + [Define to 1 to disable debug tracing]) + fi + AC_MSG_RESULT([${spl_ac_debug=no}]) +]) + +AC_DEFUN([SPL_AC_DEBUG_KMEM], [ + AC_MSG_CHECKING([whether kmem debugging is enabled]) + AC_ARG_ENABLE( [debug-kmem], + AS_HELP_STRING([--enable-debug-kmem], + [Enable kmem debug support (default off)]), + [ case "$enableval" in + yes) spl_ac_debug=yes ;; + no) spl_ac_debug=no ;; + *) AC_MSG_RESULT([Error!]) + AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kmem]) ;; + esac ] + ) + if test "$spl_ac_debug" = yes; then + KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM" + AC_DEFINE([DEBUG_KMEM], [1], + [Define to 1 to enable kmem debugging]) + fi + AC_MSG_RESULT([${spl_ac_debug=no}]) +]) + +AC_DEFUN([SPL_AC_DEBUG_MUTEX], [ + AC_MSG_CHECKING([whether mutex debugging is enabled]) + AC_ARG_ENABLE( [debug-mutex], + AS_HELP_STRING([--enable-debug-mutex], + [Enable mutex debug support (default off)]), + [ case "$enableval" in + yes) spl_ac_debug=yes ;; + no) spl_ac_debug=no ;; + *) AC_MSG_RESULT([Error!]) + AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-mutex]) ;; + esac ] + ) + if test "$spl_ac_debug" = yes; then + KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_MUTEX" + AC_DEFINE([DEBUG_MUTEX], [1], + [Define to 1 to enable mutex debugging]) + fi + AC_MSG_RESULT([${spl_ac_debug=no}]) +]) + +AC_DEFUN([SPL_AC_DEBUG_KSTAT], [ + AC_MSG_CHECKING([whether kstat debugging is enabled]) + AC_ARG_ENABLE( [debug-kstat], + AS_HELP_STRING([--enable-debug-kstat], + [Enable kstat debug support (default off)]), + [ case "$enableval" in + yes) spl_ac_debug=yes ;; + no) spl_ac_debug=no ;; + *) AC_MSG_RESULT([Error!]) + AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kstat]) ;; + esac ] + ) + if test "$spl_ac_debug" = yes; then + KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KSTAT" + AC_DEFINE([DEBUG_KSTAT], [1], + [Define to 1 to enable kstat debugging]) + fi + AC_MSG_RESULT([${spl_ac_debug=no}]) +]) + +AC_DEFUN([SPL_AC_DEBUG_CALLB], [ + AC_MSG_CHECKING([whether callb debugging is enabled]) + AC_ARG_ENABLE( [debug-callb], + AS_HELP_STRING([--enable-debug-callb], + [Enable callb debug support (default off)]), + [ case "$enableval" in + yes) spl_ac_debug=yes ;; + no) spl_ac_debug=no ;; + *) AC_MSG_RESULT([Error!]) + AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-callb]) ;; + esac ] + ) + if test "$spl_ac_debug" = yes; then + KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_CALLB" + AC_DEFINE([DEBUG_CALLB], [1], + [Define to 1 to enable callb debugging]) + fi + AC_MSG_RESULT([${spl_ac_debug=no}]) +]) + +dnl # +dnl # SPL_LINUX_CONFTEST +dnl # +AC_DEFUN([SPL_LINUX_CONFTEST], [ +cat >conftest.c <<_ACEOF +$1 +_ACEOF +]) + +dnl # +dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY]) +dnl # +m4_define([SPL_LANG_PROGRAM], [ +$1 +int +main (void) +{ +dnl Do *not* indent the following line: there may be CPP directives. +dnl Don't move the `;' right after for the same reason. +$2 + ; + return 0; +} +]) + +dnl # +dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE +dnl # +AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [ +m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])dnl +rm -f build/conftest.o build/conftest.mod.c build/conftest.ko build/Makefile +echo "obj-m := conftest.o" >build/Makefile +dnl AS_IF([AC_TRY_COMMAND(cp conftest.c build && make [$2] CC="$CC" -f $PWD/build/Makefile LINUXINCLUDE="-Iinclude -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM SUBDIRS=$PWD/build) >/dev/null && AC_TRY_COMMAND([$3])], +AS_IF([AC_TRY_COMMAND(cp conftest.c build && make [$2] CC="$CC" LINUXINCLUDE="-Iinclude -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -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])dnl])dnl +rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko m4_ifval([$1], [build/conftest.c conftest.c])[]dnl +]) + +dnl # +dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE +dnl # +AC_DEFUN([SPL_LINUX_TRY_COMPILE], + [SPL_LINUX_COMPILE_IFELSE( + [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])], + [modules], + [test -s build/conftest.o], + [$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 + #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]) + grep -q -E '[[[:space:]]]$1[[[:space:]]]' $LINUX/Module.symvers 2>/dev/null + rc=$? + if test $rc -ne 0; then + export=0 + for file in $2; do + grep -q -E "EXPORT_SYMBOL.*($1)" "$LINUX/$file" 2>/dev/null + rc=$? + if test $rc -eq 0; then + export=1 + break; + fi + done + if test $export -eq 0; then + AC_MSG_RESULT([no]) + $4 + else + AC_MSG_RESULT([yes]) + $3 + fi + else + AC_MSG_RESULT([yes]) + $3 + fi +]) + +dnl # +dnl # 2.6.x 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]) + SPL_LINUX_TRY_COMPILE([ + #include + ],[ + uintptr_t *ptr; + ],[ + AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_UINTPTR_T, 1, + [kernel defines uintptr_t]) + ],[ + AC_MSG_RESULT([no]) + ]) +]) + +dnl # +dnl # 2.6.x API change +dnl # check if kmem_cache_t typedef is defined +dnl # +AC_DEFUN([SPL_AC_TYPE_KMEM_CACHE_T], + [AC_MSG_CHECKING([whether kernel defines kmem_cache_t]) + SPL_LINUX_TRY_COMPILE([ + #include + ],[ + kmem_cache_t *cache; + ],[ + AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_KMEM_CACHE_T, 1, + [kernel defines kmem_cache_t]) + ],[ + AC_MSG_RESULT([no]) + ]) +]) + +dnl # +dnl # 2.6.19 API change +dnl # kmem_cache_destroy() return void instead of int +dnl # +AC_DEFUN([SPL_AC_KMEM_CACHE_DESTROY_INT], + [AC_MSG_CHECKING([whether kmem_cache_destroy() returns int]) + SPL_LINUX_TRY_COMPILE([ + #include + ],[ + int i = kmem_cache_destroy(NULL); + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_KMEM_CACHE_DESTROY_INT, 1, + [kmem_cache_destroy() returns int]) + ],[ + AC_MSG_RESULT(no) + ]) +]) + +dnl # +dnl # 2.6.19 API change +dnl # panic_notifier_list use atomic_notifier operations +dnl # + +AC_DEFUN([SPL_AC_ATOMIC_PANIC_NOTIFIER], + [AC_MSG_CHECKING([whether panic_notifier_list is atomic]) + SPL_LINUX_TRY_COMPILE([ + #include + #include + ],[ + struct atomic_notifier_head panic_notifier_list; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_ATOMIC_PANIC_NOTIFIER, 1, + [panic_notifier_list is atomic]) + ],[ + AC_MSG_RESULT(no) + ]) +]) + +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; + + 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 +dnl # +AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL], + [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args]) + SPL_LINUX_TRY_COMPILE([ + #include + ],[ + return register_sysctl_table(NULL,0); + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1, + [register_sysctl_table() wants 2 args]) + ],[ + AC_MSG_RESULT(no) + ]) +]) + +dnl # +dnl # 2.6.21 API change +dnl # Use struct kmem_cache for missing kmem_cache_t +dnl # +AC_DEFUN([SPL_AC_KMEM_CACHE_T], [ + AC_MSG_CHECKING([whether kernel has kmem_cache_t]) + tmp_flags="$EXTRA_KCFLAGS" + EXTRA_KCFLAGS="-Werror" + SPL_LINUX_TRY_COMPILE([ + #include + ],[ + kmem_cache_t *cachep = NULL; + kmem_cache_free(cachep, NULL); + + ],[ + AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_KMEM_CACHE_T, 1, + [kernel has struct kmem_cache_t]) + ],[ + AC_MSG_RESULT([no]) + ]) + EXTRA_KCFLAGS="$tmp_flags" +]) + +dnl # +dnl # 2.6.23 API change +dnl # Slab no longer accepts a dtor argument +dnl # +AC_DEFUN([SPL_AC_KMEM_CACHE_CREATE_DTOR], + [AC_MSG_CHECKING([whether kmem_cache_create() has dtor arg]) + SPL_LINUX_TRY_COMPILE([ + #include + ],[ + kmem_cache_create(NULL, 0, 0, 0, NULL, NULL); + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_KMEM_CACHE_CREATE_DTOR, 1, + [kmem_cache_create() has dtor arg]) + ],[ + AC_MSG_RESULT(no) + ]) +]) + +dnl # +dnl # 2.6.x API change +dnl # Slab ctor no longer takes 3 args +dnl # +AC_DEFUN([SPL_AC_3ARG_KMEM_CACHE_CREATE_CTOR], + [AC_MSG_CHECKING([whether slab ctor wants 3 args]) + tmp_flags="$EXTRA_KCFLAGS" + EXTRA_KCFLAGS="-Werror" + SPL_LINUX_TRY_COMPILE([ + #include + ],[ + void (*ctor)(void *,struct kmem_cache *,unsigned long) = NULL; + + #ifdef HAVE_KMEM_CACHE_CREATE_DTOR + kmem_cache_create(NULL, 0, 0, 0, ctor, NULL); + #else + kmem_cache_create(NULL, 0, 0, 0, ctor); + #endif + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_3ARG_KMEM_CACHE_CREATE_CTOR, 1, + [slab ctor wants 3 args]) + ],[ + AC_MSG_RESULT(no) + ]) + EXTRA_KCFLAGS="$tmp_flags" +]) + +dnl # +dnl # 2.6.x API change +dnl # Old set_shrinker API replaced with register_shrinker +dnl # +AC_DEFUN([SPL_AC_SET_SHRINKER], [ + AC_MSG_CHECKING([whether set_shrinker() available]) + SPL_LINUX_TRY_COMPILE([ + #include + ],[ + return set_shrinker(DEFAULT_SEEKS, NULL); + ],[ + AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_SET_SHRINKER, 1, + [set_shrinker() available]) + ],[ + AC_MSG_RESULT([no]) + ]) +]) + +dnl # +dnl # 2.6.x API change +dnl # struct path entry added to struct nameidata +dnl # +AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA], + [AC_MSG_CHECKING([whether struct path used in struct nameidata]) + SPL_LINUX_TRY_COMPILE([ + #include + ],[ + struct nameidata nd; + + nd.path.mnt = NULL; + nd.path.dentry = NULL; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1, + [struct path used in struct nameidata]) + ],[ + AC_MSG_RESULT(no) + ]) +]) + +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.x API change +dnl # Use CTL_UNNUMBERED when binary sysctl is not required +dnl # +AC_DEFUN([SPL_AC_CTL_UNNUMBERED], + [AC_MSG_CHECKING([whether unnumbered sysctl support exists]) + SPL_LINUX_TRY_COMPILE([ + #include + ],[ + #ifndef CTL_UNNUMBERED + #error CTL_UNNUMBERED undefined + #endif + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_CTL_UNNUMBERED, 1, + [unnumbered sysctl support exists]) + ],[ + AC_MSG_RESULT(no) + ]) +]) diff --git a/autogen.sh b/autogen.sh index bf452fdca5..abd43903a9 100755 --- a/autogen.sh +++ b/autogen.sh @@ -3,8 +3,8 @@ find . -type d -name .deps | xargs rm -rf rm -rf config.guess config.sub ltmain.sh libtoolize --automake -aclocal 2>/dev/null && +aclocal -I autoconf 2>/dev/null && autoheader && -automake --add-missing --include-deps # 2>/dev/null && +automake --add-missing --include-deps 2>/dev/null autoconf diff --git a/configure.ac b/configure.ac index 5876201583..df210ee529 100644 --- a/configure.ac +++ b/configure.ac @@ -28,187 +28,14 @@ AC_INIT AC_CANONICAL_SYSTEM AM_INIT_AUTOMAKE(spl, 0.3.1) -AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_HEADERS([spl_config.h]) AC_PROG_INSTALL AC_PROG_CC AC_PROG_LIBTOOL -kernelsrc= -kernelbuild= - -AC_DEFUN([SPL_AC_KERNEL], [ - ver=`uname -r` - - AC_ARG_WITH([linux], - AS_HELP_STRING([--with-linux=PATH], - [Path to kernel source]), - [kernelsrc="$withval"; kernelbuild="$withval"]) - - AC_ARG_WITH([linux-obj], - AS_HELP_STRING([--with-linux-obj=PATH], - [Path to kernel build objects]), - [kernelbuild="$withval"]) - - AC_MSG_CHECKING([kernel source directory]) - if test -z "$kernelsrc"; then - kernelbuild= - sourcelink=/lib/modules/${ver}/source - buildlink=/lib/modules/${ver}/build - - if test -e $sourcelink; then - kernelsrc=`(cd $sourcelink; /bin/pwd)` - fi - if test -e $buildlink; then - kernelbuild=`(cd $buildlink; /bin/pwd)` - fi - if test -z "$kernelsrc"; then - kernelsrc=$kernelbuild - fi - if test -z "$kernelsrc" -o -z "$kernelbuild"; then - AC_MSG_RESULT([Not found]) - AC_MSG_ERROR([ - *** Please specify the location of the kernel source - *** with the '--with-kernel=PATH' option]) - fi - fi - - AC_MSG_RESULT([$kernelsrc]) - AC_MSG_CHECKING([kernel build directory]) - 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 "; - 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 - - kernsrcver=`(echo "#include "; - echo "kernsrcver=UTS_RELEASE") | - cpp -I $kernelbuild/include | - grep "^kernsrcver=" | cut -d \" -f 2` - fi - - if test -z "$kernsrcver"; then - 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]) - fi - - AC_MSG_RESULT([$kernsrcver]) - kmoduledir=${INSTALL_MOD_PATH}/lib/modules/$kernsrcver - AC_SUBST(kernelsrc) - AC_SUBST(kmoduledir) -]) - -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 off)]), - [ case "$enableval" in - yes) spl_ac_debug=yes ;; - no) spl_ac_debug=no ;; - *) AC_MSG_RESULT([Error!]) - AC_MSG_ERROR([Bad value "$enableval" for --enable-debug]) ;; - esac ] - ) - if test "$spl_ac_debug" = yes; then - KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG" - else - KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG" - AC_DEFINE([NDEBUG], [1], - [Define to 1 to disable debug tracing]) - fi - AC_MSG_RESULT([${spl_ac_debug=no}]) -]) - -AC_DEFUN([SPL_AC_DEBUG_KMEM], [ - AC_MSG_CHECKING([whether kmem debugging is enabled]) - AC_ARG_ENABLE( [debug-kmem], - AS_HELP_STRING([--enable-debug-kmem], - [Enable kmem debug support (default off)]), - [ case "$enableval" in - yes) spl_ac_debug=yes ;; - no) spl_ac_debug=no ;; - *) AC_MSG_RESULT([Error!]) - AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kmem]) ;; - esac ] - ) - if test "$spl_ac_debug" = yes; then - KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM" - AC_DEFINE([DEBUG_KMEM], [1], - [Define to 1 to enable kmem debugging]) - fi - AC_MSG_RESULT([${spl_ac_debug=no}]) -]) - -AC_DEFUN([SPL_AC_DEBUG_MUTEX], [ - AC_MSG_CHECKING([whether mutex debugging is enabled]) - AC_ARG_ENABLE( [debug-mutex], - AS_HELP_STRING([--enable-debug-mutex], - [Enable mutex debug support (default off)]), - [ case "$enableval" in - yes) spl_ac_debug=yes ;; - no) spl_ac_debug=no ;; - *) AC_MSG_RESULT([Error!]) - AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-mutex]) ;; - esac ] - ) - if test "$spl_ac_debug" = yes; then - KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_MUTEX" - AC_DEFINE([DEBUG_MUTEX], [1], - [Define to 1 to enable mutex debugging]) - fi - AC_MSG_RESULT([${spl_ac_debug=no}]) -]) - -AC_DEFUN([SPL_AC_DEBUG_KSTAT], [ - AC_MSG_CHECKING([whether kstat debugging is enabled]) - AC_ARG_ENABLE( [debug-kstat], - AS_HELP_STRING([--enable-debug-kstat], - [Enable kstat debug support (default off)]), - [ case "$enableval" in - yes) spl_ac_debug=yes ;; - no) spl_ac_debug=no ;; - *) AC_MSG_RESULT([Error!]) - AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kstat]) ;; - esac ] - ) - if test "$spl_ac_debug" = yes; then - KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KSTAT" - AC_DEFINE([DEBUG_KSTAT], [1], - [Define to 1 to enable kstat debugging]) - fi - AC_MSG_RESULT([${spl_ac_debug=no}]) -]) - -AC_DEFUN([SPL_AC_DEBUG_CALLB], [ - AC_MSG_CHECKING([whether callb debugging is enabled]) - AC_ARG_ENABLE( [debug-callb], - AS_HELP_STRING([--enable-debug-callb], - [Enable callb debug support (default off)]), - [ case "$enableval" in - yes) spl_ac_debug=yes ;; - no) spl_ac_debug=no ;; - *) AC_MSG_RESULT([Error!]) - AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-callb]) ;; - esac ] - ) - if test "$spl_ac_debug" = yes; then - KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_CALLB" - AC_DEFINE([DEBUG_CALLB], [1], - [Define to 1 to enable callb debugging]) - fi - AC_MSG_RESULT([${spl_ac_debug=no}]) -]) +LINUX= +LINUX_OBJ= SPL_AC_KERNEL SPL_AC_DEBUG @@ -216,6 +43,19 @@ SPL_AC_DEBUG_KMEM SPL_AC_DEBUG_MUTEX SPL_AC_DEBUG_KSTAT SPL_AC_DEBUG_CALLB +SPL_AC_TYPE_UINTPTR_T +SPL_AC_TYPE_KMEM_CACHE_T +SPL_AC_KMEM_CACHE_DESTROY_INT +SPL_AC_ATOMIC_PANIC_NOTIFIER +SPL_AC_3ARGS_INIT_WORK +SPL_AC_2ARGS_REGISTER_SYSCTL +SPL_AC_KMEM_CACHE_T +SPL_AC_KMEM_CACHE_CREATE_DTOR +SPL_AC_3ARG_KMEM_CACHE_CREATE_CTOR +SPL_AC_SET_SHRINKER +SPL_AC_PATH_IN_NAMEIDATA +SPL_AC_TASK_CURR +SPL_AC_CTL_UNNUMBERED TOPDIR=`/bin/pwd` @@ -223,7 +63,7 @@ TOPDIR=`/bin/pwd` KERNELMAKE_PARAMS= KERNELCPPFLAGS="${KERNELCPPFLAGS} -I$TOPDIR -I$TOPDIR/include" -if test "$kernelbuild" != "$kernelsrc"; then +if test "${LINUX_OBJ}" != "${LINUX}"; then KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$kernelbuild" fi diff --git a/include/sys/kmem.h b/include/sys/kmem.h index f61ace2135..0b1b536874 100644 --- a/include/sys/kmem.h +++ b/include/sys/kmem.h @@ -41,6 +41,7 @@ extern "C" { #include #include #include +#include #include /* * Memory allocation interfaces @@ -316,15 +317,6 @@ kmem_alloc_tryhard(size_t size, size_t *alloc_size, int kmflags) #define KMC_REAP_CHUNK 256 #define KMC_DEFAULT_SEEKS DEFAULT_SEEKS -/* Defined by linux slab.h - * typedef struct kmem_cache_s kmem_cache_t; - */ - -/* No linux analog - * extern int kmem_ready; - * extern pgcnt_t kmem_reapahead; - */ - #ifdef DEBUG_KMEM_UNIMPLEMENTED static __inline__ void kmem_init(void) { #error "kmem_init() not implemented" @@ -380,6 +372,7 @@ __kmem_cache_create(char *name, size_t size, size_t align, extern int __kmem_cache_destroy(kmem_cache_t *cache); extern void *__kmem_cache_alloc(kmem_cache_t *cache, gfp_t flags); +extern void __kmem_cache_free(kmem_cache_t *cache, void *obj); extern void __kmem_reap(void); int kmem_init(void); @@ -389,7 +382,7 @@ void kmem_fini(void); __kmem_cache_create(name,size,align,ctor,dtor,rclm,priv,vmp,flags) #define kmem_cache_destroy(cache) __kmem_cache_destroy(cache) #define kmem_cache_alloc(cache, flags) __kmem_cache_alloc(cache, flags) -#define kmem_cache_free(cache, ptr) kmem_cache_free(cache, ptr) +#define kmem_cache_free(cache, obj) __kmem_cache_free(cache, obj) #define kmem_cache_reap_now(cache) kmem_cache_shrink(cache) #define kmem_reap() __kmem_reap() diff --git a/include/sys/proc.h b/include/sys/proc.h index 9944c74f9d..0316a45fd9 100644 --- a/include/sys/proc.h +++ b/include/sys/proc.h @@ -39,6 +39,15 @@ #include #include +#ifdef CONFIG_SYSCTL +#ifdef HAVE_2ARGS_REGISTER_SYSCTL +#define spl_register_sysctl_table(t, a) register_sysctl_table(t, a) +#else +#define spl_register_sysctl_table(t, a) register_sysctl_table(t) +#endif /* HAVE_2ARGS_REGISTER_SYSCTL */ +#define spl_unregister_sysctl_table(t) unregister_sysctl_table(t) +#endif /* CONFIG_SYSCTL */ + #ifdef DEBUG_KSTAT extern struct proc_dir_entry *proc_sys_spl_kstat; struct proc_dir_entry *proc_dir_entry_find(struct proc_dir_entry *root, diff --git a/include/sys/sysmacros.h b/include/sys/sysmacros.h index c55b070ac3..95f7f8a3b3 100644 --- a/include/sys/sysmacros.h +++ b/include/sys/sysmacros.h @@ -197,6 +197,18 @@ extern int ddi_strtoul(const char *str, char **nptr, #define offsetof(s, m) ((size_t)(&(((s *)0)->m))) #endif +#ifdef HAVE_3ARGS_INIT_WORK + +#define spl_init_work(wq,cb,d) INIT_WORK((wq), (void *)(cb), (void *)(d)) +#define spl_get_work_data(type,field,data) (data) + +#else + +#define spl_init_work(wq,cb,d) INIT_WORK((wq), (void *)(cb)); +#define spl_get_work_data(type,field,data) container_of(data,type,field) + +#endif + #ifdef __cplusplus } #endif diff --git a/include/sys/types.h b/include/sys/types.h index dc660a761d..c2ad9837dc 100644 --- a/include/sys/types.h +++ b/include/sys/types.h @@ -7,9 +7,17 @@ extern "C" { #include #include +#include "spl_config.h" + +#ifndef HAVE_UINTPTR_T +typedef unsigned long uintptr_t; +#endif + +#ifndef HAVE_KMEM_CACHE_T +typedef struct kmem_cache kmem_cache_t; +#endif typedef enum { B_FALSE=0, B_TRUE=1 } boolean_t; -typedef unsigned long uintptr_t; typedef unsigned long intptr_t; typedef unsigned long ulong_t; typedef unsigned int uint_t; diff --git a/include/sys/vnode.h b/include/sys/vnode.h index 9123d7a137..eca33f4b1c 100644 --- a/include/sys/vnode.h +++ b/include/sys/vnode.h @@ -40,6 +40,7 @@ extern "C" { #include #include #include +#include #include #include #include @@ -92,6 +93,14 @@ extern "C" { #define B_INVAL 0x01 #define B_TRUNC 0x02 +#ifdef HAVE_PATH_IN_NAMEIDATA +# define nd_dentry path.dentry +# define nd_mnt path.mnt +#else +# define nd_dentry dentry +# define nd_mnt mnt +#endif + typedef enum vtype { VNON = 0, VREG = 1, diff --git a/lib/list.c b/lib/list.c index 88af47c402..ee6b33a836 100644 --- a/lib/list.c +++ b/lib/list.c @@ -26,7 +26,7 @@ #ifdef HAVE_CONFIG_H -# include "config.h" +# include "spl_config.h" #endif /* HAVE_CONFIG_H */ #ifdef WITH_PTHREADS diff --git a/modules/Makefile.in b/modules/Makefile.in index cbc84403c3..86f8951ae5 100644 --- a/modules/Makefile.in +++ b/modules/Makefile.in @@ -2,9 +2,9 @@ subdir-m += spl subdir-m += splat all: - $(MAKE) -C @kernelsrc@ SUBDIRS=`pwd` @KERNELMAKE_PARAMS@ modules + $(MAKE) -C @LINUX@ SUBDIRS=`pwd` @KERNELMAKE_PARAMS@ modules install uninstall clean distclean maintainer-clean distdir: - $(MAKE) -C @kernelsrc@ SUBDIRS=`pwd` @KERNELMAKE_PARAMS@ $@ + $(MAKE) -C @LINUX@ SUBDIRS=`pwd` @KERNELMAKE_PARAMS@ $@ check: diff --git a/modules/spl/Makefile.in b/modules/spl/Makefile.in index 1bb979c45b..f92945b003 100644 --- a/modules/spl/Makefile.in +++ b/modules/spl/Makefile.in @@ -4,7 +4,7 @@ MODULES := spl DISTFILES = Makefile.in \ spl-kmem.c spl-rwlock.c spl-taskq.c \ spl-thread.c spl-generic.c -CPPFLAGS += @KERNELCPPFLAGS@ +EXTRA_CFLAGS = @KERNELCPPFLAGS@ # Solaris porting layer module obj-m := spl.o diff --git a/modules/spl/spl-debug.c b/modules/spl/spl-debug.c index 656df96149..1fd38e30a0 100644 --- a/modules/spl/spl-debug.c +++ b/modules/spl/spl-debug.c @@ -44,7 +44,6 @@ #include #include #include -#include "config.h" #ifdef DEBUG_SUBSYSTEM #undef DEBUG_SUBSYSTEM @@ -1118,7 +1117,7 @@ void spl_debug_dumpstack(struct task_struct *tsk) tsk = current; printk(KERN_ERR "SPL: Showing stack for process %d\n", tsk->pid); - show_task(tsk); + dump_stack(); } EXPORT_SYMBOL(spl_debug_dumpstack); @@ -1255,8 +1254,13 @@ debug_init(void) if (rc) return rc; +#ifdef HAVE_ATOMIC_PANIC_NOTIFIER atomic_notifier_chain_register(&panic_notifier_list, &spl_panic_notifier); +#else + notifier_chain_register(&panic_notifier_list, + &spl_panic_notifier); +#endif return rc; } @@ -1306,8 +1310,14 @@ trace_fini(void) void debug_fini(void) { +#ifdef HAVE_ATOMIC_PANIC_NOTIFIER atomic_notifier_chain_unregister(&panic_notifier_list, &spl_panic_notifier); +#else + notifier_chain_unregister(&panic_notifier_list, + &spl_panic_notifier); +#endif + trace_fini(); return; diff --git a/modules/spl/spl-err.c b/modules/spl/spl-err.c index 67aea5f0d7..c4508dfa22 100644 --- a/modules/spl/spl-err.c +++ b/modules/spl/spl-err.c @@ -26,7 +26,6 @@ #include #include -#include "config.h" #ifdef DEBUG_SUBSYSTEM #undef DEBUG_SUBSYSTEM diff --git a/modules/spl/spl-generic.c b/modules/spl/spl-generic.c index ac6cbf719b..721772762e 100644 --- a/modules/spl/spl-generic.c +++ b/modules/spl/spl-generic.c @@ -33,7 +33,6 @@ #include #include #include -#include "config.h" #ifdef DEBUG_SUBSYSTEM #undef DEBUG_SUBSYSTEM @@ -101,7 +100,7 @@ set_hostid(void) char sh_path[] = "/bin/sh"; char *argv[] = { sh_path, "-c", - "/usr/bin/hostid >/proc/sys/spl/hostid", + "/usr/bin/hostid >/proc/sys/kernel/spl/hostid", NULL }; char *envp[] = { "HOME=/", "TERM=linux", diff --git a/modules/spl/spl-kmem.c b/modules/spl/spl-kmem.c index 2842588037..6de6203035 100644 --- a/modules/spl/spl-kmem.c +++ b/modules/spl/spl-kmem.c @@ -104,7 +104,15 @@ typedef struct kmem_cache_cb { static struct rw_semaphore kmem_cache_cb_sem; static struct list_head kmem_cache_cb_list; +#ifdef HAVE_SET_SHRINKER static struct shrinker *kmem_cache_shrinker; +#else +static int kmem_cache_generic_shrinker(int nr_to_scan, unsigned int gfp_mask); +static struct shrinker kmem_cache_shrinker = { + .shrink = kmem_cache_generic_shrinker, + .seeks = KMC_DEFAULT_SEEKS, +}; +#endif /* Function must be called while holding the kmem_cache_cb_sem * Because kmem_cache_t is an opaque datatype we're forced to @@ -166,19 +174,21 @@ kmem_cache_remove_cache_cb(kmem_cache_cb_t *kcc) } } +#ifdef HAVE_3ARG_KMEM_CACHE_CREATE_CTOR static void -kmem_cache_generic_constructor(void *ptr, kmem_cache_t *cache, unsigned long flags) +kmem_cache_generic_constructor(void *ptr, kmem_cache_t *cache, + unsigned long flags) { kmem_cache_cb_t *kcc; kmem_constructor_t constructor; void *private; - ASSERT(flags & SLAB_CTOR_CONSTRUCTOR); - /* Ensure constructor verifies are not passed to the registered * constructors. This may not be safe due to the Solaris constructor * not being aware of how to handle the SLAB_CTOR_VERIFY flag */ + ASSERT(flags & SLAB_CTOR_CONSTRUCTOR); + if (flags & SLAB_CTOR_VERIFY) return; @@ -186,7 +196,15 @@ kmem_cache_generic_constructor(void *ptr, kmem_cache_t *cache, unsigned long fla flags = KM_NOSLEEP; else flags = KM_SLEEP; - +#else +static void +kmem_cache_generic_constructor(kmem_cache_t *cache, void *ptr) +{ + kmem_cache_cb_t *kcc; + kmem_constructor_t constructor; + void *private; + int flags = KM_NOSLEEP; +#endif /* We can be called with interrupts disabled so it is critical that * this function and the registered constructor never sleep. */ @@ -244,7 +262,7 @@ kmem_cache_generic_destructor(void *ptr, kmem_cache_t *cache, unsigned long flag atomic_dec(&kcc->kcc_ref); } -/* XXX - Arguments are ignored */ +/* Arguments are ignored */ static int kmem_cache_generic_shrinker(int nr_to_scan, unsigned int gfp_mask) { @@ -306,6 +324,7 @@ kmem_cache_generic_shrinker(int nr_to_scan, unsigned int gfp_mask) #undef kmem_cache_create #undef kmem_cache_destroy #undef kmem_cache_alloc +#undef kmem_cache_free kmem_cache_t * __kmem_cache_create(char *name, size_t size, size_t align, @@ -329,23 +348,32 @@ __kmem_cache_create(char *name, size_t size, size_t align, RETURN(NULL); strcpy(cache_name, name); + +#ifdef HAVE_KMEM_CACHE_CREATE_DTOR cache = kmem_cache_create(cache_name, size, align, flags, kmem_cache_generic_constructor, kmem_cache_generic_destructor); +#else + cache = kmem_cache_create(cache_name, size, align, flags, NULL); +#endif if (cache == NULL) RETURN(NULL); /* Register shared shrinker function on initial cache create */ down_read(&kmem_cache_cb_sem); if (list_empty(&kmem_cache_cb_list)) { - kmem_cache_shrinker = set_shrinker(KMC_DEFAULT_SEEKS, - kmem_cache_generic_shrinker); +#ifdef HAVE_SET_SHRINKER + kmem_cache_shrinker = + set_shrinker(KMC_DEFAULT_SEEKS, + kmem_cache_generic_shrinker); if (kmem_cache_shrinker == NULL) { kmem_cache_destroy(cache); up_read(&kmem_cache_cb_sem); RETURN(NULL); } - +#else + register_shrinker(&kmem_cache_shrinker); +#endif } up_read(&kmem_cache_cb_sem); @@ -353,7 +381,11 @@ __kmem_cache_create(char *name, size_t size, size_t align, reclaim, priv, vmp); if (kcc == NULL) { if (shrinker_flag) /* New shrinker registered must be removed */ +#ifdef HAVE_SET_SHRINKER remove_shrinker(kmem_cache_shrinker); +#else + unregister_shrinker(&kmem_cache_shrinker); +#endif kmem_cache_destroy(cache); RETURN(NULL); @@ -383,7 +415,13 @@ __kmem_cache_destroy(kmem_cache_t *cache) up_read(&kmem_cache_cb_sem); name = (char *)kmem_cache_name(cache); + +#ifdef HAVE_KMEM_CACHE_DESTROY_INT rc = kmem_cache_destroy(cache); +#else + kmem_cache_destroy(cache); + rc = 0; +#endif atomic_dec(&kcc->kcc_ref); kmem_cache_remove_cache_cb(kcc); @@ -392,7 +430,11 @@ __kmem_cache_destroy(kmem_cache_t *cache) /* Unregister generic shrinker on removal of all caches */ down_read(&kmem_cache_cb_sem); if (list_empty(&kmem_cache_cb_list)) - remove_shrinker(kmem_cache_shrinker); +#ifdef HAVE_SET_SHRINKER + remove_shrinker(kmem_cache_shrinker); +#else + unregister_shrinker(&kmem_cache_shrinker); +#endif up_read(&kmem_cache_cb_sem); RETURN(rc); @@ -409,22 +451,45 @@ EXPORT_SYMBOL(__kmem_cache_destroy); void * __kmem_cache_alloc(kmem_cache_t *cache, gfp_t flags) { - void *rc; + void *obj; ENTRY; restart: - rc = kmem_cache_alloc(cache, flags); - if ((rc == NULL) && (flags & KM_SLEEP)) { + obj = kmem_cache_alloc(cache, flags); + if ((obj == NULL) && (flags & KM_SLEEP)) { #ifdef DEBUG_KMEM atomic64_inc(&kmem_cache_alloc_failed); #endif /* DEBUG_KMEM */ - GOTO(restart, rc); + GOTO(restart, obj); } - RETURN(rc); +/* When destructor support is removed we must be careful not to + * use the provided constructor which will end up being called + * more often than the destructor which we only call on free. Thus + * we many call the proper constructor when there is no destructor. + */ +#ifndef HAVE_KMEM_CACHE_CREATE_DTOR +#ifdef HAVE_3ARG_KMEM_CACHE_CREATE_CTOR + kmem_cache_generic_constructor(obj, cache, flags); +#else + kmem_cache_generic_constructor(cache, obj); +#endif +#endif + + RETURN(obj); } EXPORT_SYMBOL(__kmem_cache_alloc); +void +__kmem_cache_free(kmem_cache_t *cache, void *obj) +{ +#ifndef HAVE_KMEM_CACHE_CREATE_DTOR + kmem_cache_generic_destructor(obj, cache, 0); +#endif + kmem_cache_free(cache, obj); +} +EXPORT_SYMBOL(__kmem_cache_free); + void __kmem_reap(void) { diff --git a/modules/spl/spl-kobj.c b/modules/spl/spl-kobj.c index 5a08c15ddc..28ff74e7cd 100644 --- a/modules/spl/spl-kobj.c +++ b/modules/spl/spl-kobj.c @@ -25,7 +25,6 @@ */ #include -#include "config.h" #ifdef DEBUG_SUBSYSTEM #undef DEBUG_SUBSYSTEM diff --git a/modules/spl/spl-module.c b/modules/spl/spl-module.c index f58616cf9d..a1c31e1821 100644 --- a/modules/spl/spl-module.c +++ b/modules/spl/spl-module.c @@ -26,7 +26,6 @@ #include #include -#include "config.h" #ifdef DEBUG_SUBSYSTEM #undef DEBUG_SUBSYSTEM diff --git a/modules/spl/spl-mutex.c b/modules/spl/spl-mutex.c index 8fb5614715..82aff155fd 100644 --- a/modules/spl/spl-mutex.c +++ b/modules/spl/spl-mutex.c @@ -171,6 +171,11 @@ __mutex_tryenter(kmutex_t *mp) } EXPORT_SYMBOL(__mutex_tryenter); +#ifndef HAVE_TASK_CURR +#define task_curr(owner) 0 +#endif + + static void mutex_enter_adaptive(kmutex_t *mp) { diff --git a/modules/spl/spl-proc.c b/modules/spl/spl-proc.c index 00ec5cf42a..dd87bf007c 100644 --- a/modules/spl/spl-proc.c +++ b/modules/spl/spl-proc.c @@ -39,8 +39,10 @@ static unsigned long table_max = ~0; #ifdef CONFIG_SYSCTL static struct ctl_table_header *spl_header = NULL; +#if defined(DEBUG_MUTEX) || defined(DEBUG_KMEM) || defined(DEBUG_KSTAT) static struct proc_dir_entry *proc_sys = NULL; static struct proc_dir_entry *proc_sys_spl = NULL; +#endif #ifdef DEBUG_MUTEX static struct proc_dir_entry *proc_sys_spl_mutex = NULL; static struct proc_dir_entry *proc_sys_spl_mutex_stats = NULL; @@ -53,6 +55,49 @@ struct proc_dir_entry *proc_sys_spl_kstat = NULL; #endif #endif +#ifdef HAVE_CTL_UNNUMBERED + +#define CTL_SPL CTL_UNNUMBERED +#define CTL_SPL_DEBUG CTL_UNNUMBERED +#define CTL_SPL_MUTEX CTL_UNNUMBERED +#define CTL_SPL_KMEM CTL_UNNUMBERED +#define CTL_SPL_KSTAT CTL_UNNUMBERED + +#define CTL_VERSION CTL_UNNUMBERED /* Version */ +#define CTL_HOSTID CTL_UNNUMBERED /* Host id by /usr/bin/hostid */ +#define CTL_HW_SERIAL CTL_UNNUMBERED /* HW serial number by hostid */ + +#define CTL_DEBUG_SUBSYS CTL_UNNUMBERED /* Debug subsystem */ +#define CTL_DEBUG_MASK CTL_UNNUMBERED /* Debug mask */ +#define CTL_DEBUG_PRINTK CTL_UNNUMBERED /* All messages to console */ +#define CTL_DEBUG_MB CTL_UNNUMBERED /* Debug buffer size */ +#define CTL_DEBUG_BINARY CTL_UNNUMBERED /* Binary data in buffer */ +#define CTL_DEBUG_CATASTROPHE CTL_UNNUMBERED /* Set if BUG'd or panic'd */ +#define CTL_DEBUG_PANIC_ON_BUG CTL_UNNUMBERED /* Should panic on BUG */ +#define CTL_DEBUG_PATH CTL_UNNUMBERED /* Dump log location */ +#define CTL_DEBUG_DUMP CTL_UNNUMBERED /* Dump debug buffer to file */ +#define CTL_DEBUG_FORCE_BUG CTL_UNNUMBERED /* Hook to force a BUG */ +#define CTL_DEBUG_STACK_SIZE CTL_UNNUMBERED /* Max observed stack size */ + +#define CTL_CONSOLE_RATELIMIT CTL_UNNUMBERED /* Ratelimit console messages */ +#define CTL_CONSOLE_MAX_DELAY_CS CTL_UNNUMBERED /* Max delay skip messages */ +#define CTL_CONSOLE_MIN_DELAY_CS CTL_UNNUMBERED /* Init delay skip messages */ +#define CTL_CONSOLE_BACKOFF CTL_UNNUMBERED /* Delay increase factor */ + +#ifdef DEBUG_KMEM +#define CTL_KMEM_KMEMUSED CTL_UNNUMBERED /* Alloc'd kmem bytes */ +#define CTL_KMEM_KMEMMAX CTL_UNNUMBERED /* Max alloc'd by kmem bytes */ +#define CTL_KMEM_VMEMUSED CTL_UNNUMBERED /* Alloc'd vmem bytes */ +#define CTL_KMEM_VMEMMAX CTL_UNNUMBERED /* Max alloc'd by vmem bytes */ +#define CTL_KMEM_ALLOC_FAILED CTL_UNNUMBERED /* Cache allocations failed */ +#endif + +#define CTL_MUTEX_STATS CTL_UNNUMBERED /* Global mutex statistics */ +#define CTL_MUTEX_STATS_PER CTL_UNNUMBERED /* Per mutex statistics */ +#define CTL_MUTEX_SPIN_MAX CTL_UNNUMBERED /* Max mutex spin iterations */ + +#else /* HAVE_CTL_UNNUMBERED */ + #define CTL_SPL 0x87 #define CTL_SPL_DEBUG 0x88 #define CTL_SPL_MUTEX 0x89 @@ -82,9 +127,9 @@ enum { CTL_CONSOLE_BACKOFF, /* Delay increase factor */ #ifdef DEBUG_KMEM - CTL_KMEM_KMEMUSED, /* Crrently alloc'd kmem bytes */ + CTL_KMEM_KMEMUSED, /* Alloc'd kmem bytes */ CTL_KMEM_KMEMMAX, /* Max alloc'd by kmem bytes */ - CTL_KMEM_VMEMUSED, /* Currently alloc'd vmem bytes */ + CTL_KMEM_VMEMUSED, /* Alloc'd vmem bytes */ CTL_KMEM_VMEMMAX, /* Max alloc'd by vmem bytes */ CTL_KMEM_ALLOC_FAILED, /* Cache allocation failed */ #endif @@ -93,6 +138,7 @@ enum { CTL_MUTEX_STATS_PER, /* Per mutex statistics */ CTL_MUTEX_SPIN_MAX, /* Maximum mutex spin iterations */ }; +#endif /* HAVE_CTL_UNNUMBERED */ static int proc_copyin_string(char *kbuffer, int kbuffer_size, @@ -775,7 +821,17 @@ static struct ctl_table spl_dir[] = { .mode = 0555, .child = spl_table, }, - {0} + { 0 } +}; + +static struct ctl_table spl_root[] = { + { + .ctl_name = CTL_KERN, + .procname = "kernel", + .mode = 0555, + .child = spl_dir, + }, + { 0 } }; static int @@ -818,10 +874,11 @@ proc_init(void) ENTRY; #ifdef CONFIG_SYSCTL - spl_header = register_sysctl_table(spl_dir, 0); + spl_header = spl_register_sysctl_table(spl_root, 0); if (spl_header == NULL) RETURN(-EUNATCH); +#if defined(DEBUG_MUTEX) || defined(DEBUG_KMEM) || defined(DEBUG_KSTAT) proc_sys = proc_dir_entry_find(&proc_root, "sys"); if (proc_sys == NULL) GOTO(out, rc = -EUNATCH); @@ -829,6 +886,7 @@ proc_init(void) proc_sys_spl = proc_dir_entry_find(proc_sys, "spl"); if (proc_sys_spl == NULL) GOTO(out, rc = -EUNATCH); +#endif #ifdef DEBUG_MUTEX proc_sys_spl_mutex = proc_dir_entry_find(proc_sys_spl, "mutex"); @@ -862,8 +920,10 @@ out2: #ifdef DEBUG_MUTEX remove_proc_entry("stats_per", proc_sys_spl_mutex); #endif /* DEBUG_MUTEX */ +#if defined(DEBUG_MUTEX) || defined(DEBUG_KMEM) || defined(DEBUG_KSTAT) out: - unregister_sysctl_table(spl_header); +#endif + spl_unregister_sysctl_table(spl_header); #endif /* CONFIG_SYSCTL */ RETURN(rc); } @@ -878,7 +938,7 @@ proc_fini(void) #ifdef DEBUG_MUTEX remove_proc_entry("stats_per", proc_sys_spl_mutex); #endif /* DEBUG_MUTEX */ - unregister_sysctl_table(spl_header); + spl_unregister_sysctl_table(spl_header); #endif EXIT; } diff --git a/modules/spl/spl-time.c b/modules/spl/spl-time.c index 966e9a5a10..a2cfd6e462 100644 --- a/modules/spl/spl-time.c +++ b/modules/spl/spl-time.c @@ -26,7 +26,6 @@ #include #include -#include "config.h" #ifdef DEBUG_SUBSYSTEM #undef DEBUG_SUBSYSTEM diff --git a/modules/spl/spl-vnode.c b/modules/spl/spl-vnode.c index 4492e7797c..7ff35a8f69 100644 --- a/modules/spl/spl-vnode.c +++ b/modules/spl/spl-vnode.c @@ -26,7 +26,6 @@ #include #include -#include "config.h" #ifdef DEBUG_SUBSYSTEM @@ -105,7 +104,7 @@ vn_open(const char *path, uio_seg_t seg, int flags, int mode, { struct file *fp; struct kstat stat; - int rc, saved_umask; + int rc, saved_umask = 0; vnode_t *vp; ENTRY; @@ -243,11 +242,17 @@ vn_close(vnode_t *vp, int flags, int x1, int x2, void *x3, void *x4) } /* vn_close() */ EXPORT_SYMBOL(vn_close); -static struct dentry *lookup_hash(struct nameidata *nd) +static struct dentry *vn_lookup_hash(struct nameidata *nd) { - return __lookup_hash(&nd->last, nd->dentry, nd); + return lookup_one_len(nd->last.name, nd->nd_dentry, nd->last.len); } /* lookup_hash() */ +static void vn_path_release(struct nameidata *nd) +{ + dput(nd->nd_dentry); + mntput(nd->nd_mnt); +} + /* Modified do_unlinkat() from linux/fs/namei.c, only uses exported symbols */ int vn_remove(const char *path, uio_seg_t seg, int flags) @@ -269,8 +274,8 @@ vn_remove(const char *path, uio_seg_t seg, int flags) if (nd.last_type != LAST_NORM) GOTO(exit1, rc); - mutex_lock_nested(&nd.dentry->d_inode->i_mutex, I_MUTEX_PARENT); - dentry = lookup_hash(&nd); + mutex_lock_nested(&nd.nd_dentry->d_inode->i_mutex, I_MUTEX_PARENT); + dentry = vn_lookup_hash(&nd); rc = PTR_ERR(dentry); if (!IS_ERR(dentry)) { /* Why not before? Because we want correct rc value */ @@ -280,15 +285,15 @@ vn_remove(const char *path, uio_seg_t seg, int flags) inode = dentry->d_inode; if (inode) atomic_inc(&inode->i_count); - rc = vfs_unlink(nd.dentry->d_inode, dentry); + rc = vfs_unlink(nd.nd_dentry->d_inode, dentry); exit2: dput(dentry); } - mutex_unlock(&nd.dentry->d_inode->i_mutex); + mutex_unlock(&nd.nd_dentry->d_inode->i_mutex); if (inode) iput(inode); /* truncate the inode here */ exit1: - path_release(&nd); + vn_path_release(&nd); exit: RETURN(-rc); @@ -319,21 +324,21 @@ vn_rename(const char *oldname, const char *newname, int x1) GOTO(exit1, rc); rc = -EXDEV; - if (oldnd.mnt != newnd.mnt) + if (oldnd.nd_mnt != newnd.nd_mnt) GOTO(exit2, rc); - old_dir = oldnd.dentry; + old_dir = oldnd.nd_dentry; rc = -EBUSY; if (oldnd.last_type != LAST_NORM) GOTO(exit2, rc); - new_dir = newnd.dentry; + new_dir = newnd.nd_dentry; if (newnd.last_type != LAST_NORM) GOTO(exit2, rc); trap = lock_rename(new_dir, old_dir); - old_dentry = lookup_hash(&oldnd); + old_dentry = vn_lookup_hash(&oldnd); rc = PTR_ERR(old_dentry); if (IS_ERR(old_dentry)) @@ -358,7 +363,7 @@ vn_rename(const char *oldname, const char *newname, int x1) if (old_dentry == trap) GOTO(exit4, rc); - new_dentry = lookup_hash(&newnd); + new_dentry = vn_lookup_hash(&newnd); rc = PTR_ERR(new_dentry); if (IS_ERR(new_dentry)) GOTO(exit4, rc); @@ -377,9 +382,9 @@ exit4: exit3: unlock_rename(new_dir, old_dir); exit2: - path_release(&newnd); + vn_path_release(&newnd); exit1: - path_release(&oldnd); + vn_path_release(&oldnd); exit: RETURN(-rc); } @@ -610,7 +615,8 @@ int vn_init(void) { ENTRY; - vn_cache = kmem_cache_create("spl_vn_cache", sizeof(struct vnode), 64, + vn_cache = kmem_cache_create("spl_vn_cache", + sizeof(struct vnode), 64, vn_cache_constructor, vn_cache_destructor, NULL, NULL, NULL, 0); diff --git a/modules/splat/Makefile.in b/modules/splat/Makefile.in index 1a48a788e5..eaab508a97 100644 --- a/modules/splat/Makefile.in +++ b/modules/splat/Makefile.in @@ -6,8 +6,7 @@ DISTFILES = Makefile.in \ splat-time.c splat-condvar.c splat-mutex.c \ splat-rwlock.c splat-thread.c \ splat-ctl.c splat-internal.h - -CPPFLAGS += @KERNELCPPFLAGS@ +EXTRA_CFLAGS = @KERNELCPPFLAGS@ # Solaris Porting LAyer Tests obj-m := splat.o diff --git a/modules/splat/splat-ctl.c b/modules/splat/splat-ctl.c index ea234a2963..f29a98dfa4 100644 --- a/modules/splat/splat-ctl.c +++ b/modules/splat/splat-ctl.c @@ -41,7 +41,6 @@ */ #include "splat-internal.h" -#include #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) #include diff --git a/modules/splat/splat-mutex.c b/modules/splat/splat-mutex.c index d15903e583..640f8f4071 100644 --- a/modules/splat/splat-mutex.c +++ b/modules/splat/splat-mutex.c @@ -59,7 +59,7 @@ typedef struct mutex_priv { int mp_rc; } mutex_priv_t; - +#ifdef HAVE_3ARGS_INIT_WORK static void splat_mutex_test1_work(void *priv) { @@ -71,14 +71,16 @@ splat_mutex_test1_work(void *priv) if (!mutex_tryenter(&mp->mp_mtx)) mp->mp_rc = -EBUSY; } +#endif static int splat_mutex_test1(struct file *file, void *arg) { + int rc = 0; +#ifdef HAVE_3ARGS_INIT_WORK struct workqueue_struct *wq; struct work_struct work; mutex_priv_t *mp; - int rc = 0; mp = (mutex_priv_t *)kmalloc(sizeof(*mp), GFP_KERNEL); if (mp == NULL) @@ -141,10 +143,11 @@ out: destroy_workqueue(wq); out2: kfree(mp); - +#endif return rc; } +#ifdef HAVE_3ARGS_INIT_WORK static void splat_mutex_test2_work(void *priv) { @@ -162,13 +165,16 @@ splat_mutex_test2_work(void *priv) mp->mp_rc = rc + 1; mutex_exit(&mp->mp_mtx); } +#endif static int splat_mutex_test2(struct file *file, void *arg) { + int rc = 0; +#ifdef HAVE_3ARGS_INIT_WORK struct workqueue_struct *wq; mutex_priv_t *mp; - int i, rc = 0; + int i; mp = (mutex_priv_t *)kmalloc(sizeof(*mp), GFP_KERNEL); if (mp == NULL) @@ -220,7 +226,7 @@ splat_mutex_test2(struct file *file, void *arg) destroy_workqueue(wq); out: kfree(mp); - +#endif return rc; }