From 69cf4a311196f841c3016c526f1e79a9812b6912 Mon Sep 17 00:00:00 2001 From: grev Date: Fri, 4 Sep 2009 18:34:47 +0000 Subject: [PATCH] b=16403 i=Adilger t-f use lustre_rmmod to unload modules --- lustre/scripts/lustre_rmmod | 39 +++++++++++++++++++++++---- lustre/tests/test-framework.sh | 61 +++--------------------------------------- 2 files changed, 37 insertions(+), 63 deletions(-) diff --git a/lustre/scripts/lustre_rmmod b/lustre/scripts/lustre_rmmod index 2f6b6c2..b1020f4 100755 --- a/lustre/scripts/lustre_rmmod +++ b/lustre/scripts/lustre_rmmod @@ -4,9 +4,38 @@ # manually did a 'lctl network up'. ############################################################################### -SRCDIR=`dirname $0` -PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH +FSTYPE=${1:-ldiskfs} + +TMP=${TMP:-/tmp} +LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)} +LCTL=${LCTL:-"$LUSTRE/utils/lctl"} +[ ! -f "$LCTL" ] && export LCTL=$(which lctl 2> /dev/null) + +RMMOD=rmmod +if [ `uname -r | cut -c 3` -eq 4 ]; then + RMMOD="modprobe -r" +fi + +unload_dep_module() { + # libcfs 107852 17 llite_lloop,lustre,obdfilter,ost,... + local MODULE=$1 + local DEPS=$(lsmod | awk '($1 == "'$MODULE'") { print $4 }' | tr ',' ' ') + for SUBMOD in $DEPS; do + unload_dep_module $SUBMOD + done + [ "$MODULE" = "libcfs" ] && $LCTL dk $TMP/debug || true + $RMMOD $MODULE || true +} + +lsmod | grep libcfs > /dev/null && $LCTL dl +lsmod | grep $FSTYPE && unload_dep_module $FSTYPE +unload_dep_module libcfs + +MODULES=$($LCTL modules | awk '{ print $2 }') +if [ -n "$MODULES" ]; then + echo "Modules still loaded: " + echo $MODULES + exit 1 +fi +exit 0 -lctl modules | awk '{ print $2 }' | xargs rmmod >/dev/null 2>&1 -# do it again, in case we tried to unload the lnd's too early -lsmod | grep lnet > /dev/null && lctl modules | awk '{ print $2 }' | xargs rmmod diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 40b8b16..31158df 100644 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -133,6 +133,8 @@ init_test_env() { export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"} [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre) export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} " + export LUSTRE_RMMOD=${LUSTRE_RMMOD:-$LUSTRE/scripts/lustre_rmmod} + [ ! -f "$LUSTRE_RMMOD" ] && export LUSTRE_RMMOD=$(which lustre_rmmod 2> /dev/null) export FSTYPE=${FSTYPE:-"ldiskfs"} export NAME=${NAME:-local} export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"} @@ -280,46 +282,6 @@ load_modules() { [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true } -RMMOD=rmmod -if [ `uname -r | cut -c 3` -eq 4 ]; then - RMMOD="modprobe -r" -fi - -wait_for_lnet() { - local UNLOADED=0 - local WAIT=0 - local MAX=60 - MODULES=$($LCTL modules | awk '{ print $2 }') - while [ -n "$MODULES" ]; do - sleep 5 - $RMMOD $MODULES > /dev/null 2>&1 || true - MODULES=$($LCTL modules | awk '{ print $2 }') - if [ -z "$MODULES" ]; then - return 0 - else - WAIT=$((WAIT + 5)) - echo "waiting, $((MAX - WAIT)) secs left" - fi - if [ $WAIT -eq $MAX ]; then - echo "LNET modules $MODULES will not unload" - lsmod - return 3 - fi - done -} - -unload_dep_module() { - #lsmod output - #libcfs 107852 17 llite_lloop,lustre,obdfilter,ost,... - local MODULE=$1 - local DEPS=$(lsmod | awk '($1 == "'$MODULE'") { print $4 }' | tr ',' ' ') - for SUBMOD in $DEPS; do - unload_dep_module $SUBMOD - done - [ "$MODULE" = "libcfs" ] && $LCTL dk $TMP/debug || true - $RMMOD $MODULE || true -} - check_mem_leak () { LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true) LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true) @@ -336,25 +298,8 @@ check_mem_leak () { unload_modules() { wait_exit_ST client # bug 12845 - lsmod | grep libcfs > /dev/null && $LCTL dl - unload_dep_module $FSTYPE - unload_dep_module libcfs - - local MODULES=$($LCTL modules | awk '{ print $2 }') - if [ -n "$MODULES" ]; then - echo "Modules still loaded: " - echo $MODULES - if [ "$(lctl dl)" ]; then - echo "Lustre still loaded" - lctl dl || true - lsmod - return 2 - else - echo "Lustre stopped but LNET is still loaded, waiting..." - wait_for_lnet || return 3 - fi + $LUSTRE_RMMOD $FSTYPE || return 2 - fi HAVE_MODULES=false check_mem_leak || return 254 -- 1.8.3.1