#!/bin/sh
-SRCDIR="`dirname $0`/"
-. $SRCDIR/common.sh
+export PATH=`dirname $0`/../utils:$PATH
-TIME=`date +'%s'`
+LCONF=${LCONF:-lconf}
+NAME=${NAME:-local}
+TMP=${TMP:-/tmp}
-$DBGCTL debug_kernel /tmp/debug.1.$TIME 1
+config=$NAME.xml
+mkconfig=$NAME.sh
-if mount | grep '/mnt/lustre'; then
- umount /mnt/lustre || fail "cannot unmount"
+if [ "$PORTALS" ]; then
+ portals_opt="--portals=$PORTALS"
fi
-killall acceptor
-rmmod llite
-
-$OBDCTL <<EOF
-name2dev MDCDEV
-cleanup
-detach
-name2dev OSCDEV
-cleanup
-detach
-name2dev OSTDEV
-cleanup
-detach
-name2dev OBDDEV
-cleanup
-detach
-name2dev MDSDEV
-cleanup
-detach
-name2dev LDLMDEV
-cleanup
-detach
-name2dev RPCDEV
-cleanup
-detach
-quit
-EOF
-
-rmmod lov
-rmmod obdecho
-rmmod mds_extN
-rmmod mds_ext3
-rmmod mds_ext2
-rmmod mds
-rmmod mdc
-rmmod osc
-rmmod ost
-rmmod obdfilter
-rmmod obdext2
-rmmod ldlm
-rmmod ptlrpc
-rmmod obdclass
-rmmod extN
-
-$DBGCTL debug_kernel /tmp/debug.2.$TIME 1
-
-$PTLCTL <<EOF
-setup tcp
-disconnect
-del_uuid self
-del_uuid localhost
-del_uuid localhost
-del_uuid localhost
-quit
-EOF
-
-rmmod kqswnal
-rmmod ksocknal
+if [ "$LUSTRE" ]; then
+ lustre_opt="--lustre=$LUSTRE"
+fi
-$DBGCTL debug_kernel /tmp/debug.3.$TIME 1
+if [ "$1" = "--force" ]; then
+ force="--force"
+fi
-rmmod portals
+if [ "$LDAPURL" ]; then
+ conf_opt="--ldapurl $LDAPURL --config $NAME"
+else
+ if [ ! -f $config -o $mkconfig -nt $config ]; then
+ sh $mkconfig $config || exit 1
+ fi
+ conf_opt="$config"
+fi
+
+[ "$NODE" ] && node_opt="--node $NODE"
+
+sync; sleep 2; sync
+${LCONF} $portals_opt $lustre_opt $node_opt --cleanup $force \
+ --dump $TMP/debug $conf_opt
+rc=$?
+BUSY=`dmesg | grep -i destruct`
+if [ "$BUSY" ]; then
+ echo "$BUSY" 1>&2
+ mv $TMP/debug $TMP/debug-busy.`date +%s`
+ exit 255
+fi
+LEAK_LUSTRE=`dmesg | grep "obd mem.*leaked" | tail -1 | grep -v "leaked: 0"`
+LEAK_PORTALS=`dmesg | tail -20 | grep "Portals memory leaked"`
+if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
+ echo "$LEAK_LUSTRE" 1>&2
+ echo "$LEAK_PORTALS" 1>&2
+ mv $TMP/debug $TMP/debug-leak.`date +%s`
+ exit 254
+fi
-losetup -d ${LOOP}0
-losetup -d ${LOOP}1
-losetup -d ${LOOP}2
-exit 0
+exit $rc