X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fscripts%2Flustre_rmmod;h=8c07f783a8216114b0c4bc176909d4596b8ee5a6;hb=7dd6c394161a62b229ba65f50044a1d8f2da2d03;hp=6663ec6d6d622542b45a6ffb17803800a1ed306a;hpb=073e67f1647008c721d452ee3862c3f643f6c248;p=fs%2Flustre-release.git diff --git a/lustre/scripts/lustre_rmmod b/lustre/scripts/lustre_rmmod index 6663ec6..8c07f78 100755 --- a/lustre/scripts/lustre_rmmod +++ b/lustre/scripts/lustre_rmmod @@ -4,15 +4,40 @@ # manually did a 'lctl network up'. ############################################################################### -SRCDIR=`dirname $0` -PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH +FSTYPE=${1:-ldiskfs} -case `uname -r` in -2.4.*) RMMOD="modprobe -r";; -*) RMMOD="rmmod";; -esac +TMP=${TMP:-/tmp} +LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)} +LCTL=${LCTL:-"$LUSTRE/utils/lctl"} +[ ! -f "$LCTL" ] && export LCTL=$(which lctl 2> /dev/null) -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 +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 >/dev/null || true + $RMMOD $MODULE 2>/dev/null || true + return 0 +} + +lsmod | grep obdclass > /dev/null && $LCTL dl +lsmod | grep $FSTYPE > /dev/null && unload_dep_module $FSTYPE +lsmod | grep ptlrpc > /dev/null && unload_dep_module ptlrpc +lsmod | grep libcfs > /dev/null && 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