diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | autoconf/spl-build.m4 | 541 | ||||
-rwxr-xr-x | autogen.sh | 4 | ||||
-rw-r--r-- | configure.ac | 194 | ||||
-rw-r--r-- | include/sys/kmem.h | 13 | ||||
-rw-r--r-- | include/sys/proc.h | 9 | ||||
-rw-r--r-- | include/sys/sysmacros.h | 12 | ||||
-rw-r--r-- | include/sys/types.h | 10 | ||||
-rw-r--r-- | include/sys/vnode.h | 9 | ||||
-rw-r--r-- | lib/list.c | 2 | ||||
-rw-r--r-- | modules/Makefile.in | 4 | ||||
-rw-r--r-- | modules/spl/Makefile.in | 2 | ||||
-rw-r--r-- | modules/spl/spl-debug.c | 14 | ||||
-rw-r--r-- | modules/spl/spl-err.c | 1 | ||||
-rw-r--r-- | modules/spl/spl-generic.c | 3 | ||||
-rw-r--r-- | modules/spl/spl-kmem.c | 93 | ||||
-rw-r--r-- | modules/spl/spl-kobj.c | 1 | ||||
-rw-r--r-- | modules/spl/spl-module.c | 1 | ||||
-rw-r--r-- | modules/spl/spl-mutex.c | 5 | ||||
-rw-r--r-- | modules/spl/spl-proc.c | 72 | ||||
-rw-r--r-- | modules/spl/spl-time.c | 1 | ||||
-rw-r--r-- | modules/spl/spl-vnode.c | 40 | ||||
-rw-r--r-- | modules/splat/Makefile.in | 3 | ||||
-rw-r--r-- | modules/splat/splat-ctl.c | 1 | ||||
-rw-r--r-- | modules/splat/splat-mutex.c | 16 |
25 files changed, 809 insertions, 247 deletions
@@ -1,3 +1,8 @@ +2008-05-25 Brian Behlendorf <[email protected]> + + * configure.ac, autoconf/* : Initial pass at resolving + API changes introduced by kernels newer than 2.6.18. + 2008-05-21 Brian Behlendorf <[email protected]> * : Tag spl-0.3.1 diff --git a/autoconf/spl-build.m4 b/autoconf/spl-build.m4 new file mode 100644 index 000000000..d2d476d4f --- /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 <linux/version.h>"; + echo "kernsrcver=UTS_RELEASE") | + cpp -I $kernelbuild/include | + grep "^kernsrcver=" | cut -d \" -f 2` + + elif test -r $kernelbuild/include/linux/utsrelease.h && + fgrep -q UTS_RELEASE $kernelbuild/include/linux/utsrelease.h; then + + kernsrcver=`(echo "#include <linux/utsrelease.h>"; + 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 <linux/config.h> + #endif + ],[ + #ifndef CONFIG_$1 + #error CONFIG_$1 not #defined + #endif + ],[ + AC_MSG_RESULT([yes]) + $2 + ],[ + AC_MSG_RESULT([no]) + $3 + ]) +]) + +dnl # +dnl # SPL_CHECK_SYMBOL_EXPORT +dnl # check symbol exported or not +dnl # +AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], + [AC_MSG_CHECKING([whether symbol $1 is exported]) + 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 <linux/types.h> + ],[ + 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 <linux/slab.h> + ],[ + 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 <linux/slab.h> + ],[ + 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 <linux/notifier.h> + #include <linux/kernel.h> + ],[ + 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 <linux/workqueue.h> + ],[ + 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 <linux/sysctl.h> + ],[ + 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 <linux/slab.h> + ],[ + 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 <linux/slab.h> + ],[ + 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 <linux/slab.h> + ],[ + 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 <linux/mm.h> + ],[ + 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 <linux/namei.h> + ],[ + 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 <linux/sysctl.h> + ],[ + #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 bf452fdca..abd43903a 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 587620158..df210ee52 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 <linux/version.h>"; - echo "kernsrcver=UTS_RELEASE") | - cpp -I $kernelbuild/include | - grep "^kernsrcver=" | cut -d \" -f 2` - - elif test -r $kernelbuild/include/linux/utsrelease.h && - fgrep -q UTS_RELEASE $kernelbuild/include/linux/utsrelease.h; then - - kernsrcver=`(echo "#include <linux/utsrelease.h>"; - 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 f61ace213..0b1b53687 100644 --- a/include/sys/kmem.h +++ b/include/sys/kmem.h @@ -41,6 +41,7 @@ extern "C" { #include <linux/rwsem.h> #include <linux/hash.h> #include <linux/ctype.h> +#include <sys/types.h> #include <sys/debug.h> /* * 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 9944c74f9..0316a45fd 100644 --- a/include/sys/proc.h +++ b/include/sys/proc.h @@ -39,6 +39,15 @@ #include <sys/kstat.h> #include <sys/debug.h> +#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 c55b070ac..95f7f8a3b 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 dc660a761..c2ad9837d 100644 --- a/include/sys/types.h +++ b/include/sys/types.h @@ -7,9 +7,17 @@ extern "C" { #include <linux/types.h> #include <sys/sysmacros.h> +#include "spl_config.h" -typedef enum { B_FALSE=0, B_TRUE=1 } boolean_t; +#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 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 9123d7a13..eca33f4b1 100644 --- a/include/sys/vnode.h +++ b/include/sys/vnode.h @@ -40,6 +40,7 @@ extern "C" { #include <linux/namei.h> #include <linux/file.h> #include <linux/fs.h> +#include <linux/mount.h> #include <sys/kmem.h> #include <sys/mutex.h> #include <sys/types.h> @@ -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 88af47c40..ee6b33a83 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 cbc84403c..86f8951ae 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 1bb979c45..f92945b00 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 656df9614..1fd38e30a 100644 --- a/modules/spl/spl-debug.c +++ b/modules/spl/spl-debug.c @@ -44,7 +44,6 @@ #include <sys/proc.h> #include <sys/debug.h> #include <spl-ctl.h> -#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 67aea5f0d..c4508dfa2 100644 --- a/modules/spl/spl-err.c +++ b/modules/spl/spl-err.c @@ -26,7 +26,6 @@ #include <sys/sysmacros.h> #include <sys/cmn_err.h> -#include "config.h" #ifdef DEBUG_SUBSYSTEM #undef DEBUG_SUBSYSTEM diff --git a/modules/spl/spl-generic.c b/modules/spl/spl-generic.c index ac6cbf719..721772762 100644 --- a/modules/spl/spl-generic.c +++ b/modules/spl/spl-generic.c @@ -33,7 +33,6 @@ #include <sys/proc.h> #include <sys/kstat.h> #include <linux/kmod.h> -#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 284258803..6de620303 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,23 +451,46 @@ 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) { ENTRY; diff --git a/modules/spl/spl-kobj.c b/modules/spl/spl-kobj.c index 5a08c15dd..28ff74e7c 100644 --- a/modules/spl/spl-kobj.c +++ b/modules/spl/spl-kobj.c @@ -25,7 +25,6 @@ */ #include <sys/kobj.h> -#include "config.h" #ifdef DEBUG_SUBSYSTEM #undef DEBUG_SUBSYSTEM diff --git a/modules/spl/spl-module.c b/modules/spl/spl-module.c index f58616cf9..a1c31e182 100644 --- a/modules/spl/spl-module.c +++ b/modules/spl/spl-module.c @@ -26,7 +26,6 @@ #include <sys/sysmacros.h> #include <sys/sunddi.h> -#include "config.h" #ifdef DEBUG_SUBSYSTEM #undef DEBUG_SUBSYSTEM diff --git a/modules/spl/spl-mutex.c b/modules/spl/spl-mutex.c index 8fb561471..82aff155f 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 00ec5cf42..dd87bf007 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 966e9a5a1..a2cfd6e46 100644 --- a/modules/spl/spl-time.c +++ b/modules/spl/spl-time.c @@ -26,7 +26,6 @@ #include <sys/sysmacros.h> #include <sys/time.h> -#include "config.h" #ifdef DEBUG_SUBSYSTEM #undef DEBUG_SUBSYSTEM diff --git a/modules/spl/spl-vnode.c b/modules/spl/spl-vnode.c index 4492e7797..7ff35a8f6 100644 --- a/modules/spl/spl-vnode.c +++ b/modules/spl/spl-vnode.c @@ -26,7 +26,6 @@ #include <sys/sysmacros.h> #include <sys/vnode.h> -#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 1a48a788e..eaab508a9 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 ea234a296..f29a98dfa 100644 --- a/modules/splat/splat-ctl.c +++ b/modules/splat/splat-ctl.c @@ -41,7 +41,6 @@ */ #include "splat-internal.h" -#include <config.h> #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) #include <linux/devfs_fs_kernel.h> diff --git a/modules/splat/splat-mutex.c b/modules/splat/splat-mutex.c index d15903e58..640f8f407 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; } |