Whamcloud - gitweb
Land b1_2_smallfix onto b1_2 (20040723_1622)
[fs/lustre-release.git] / lustre / tests / llmountcleanup.sh
1 #!/bin/sh
2
3 export PATH=`dirname $0`/../utils:$PATH
4
5 LCONF=${LCONF:-lconf}
6 NAME=${NAME:-local}
7 TMP=${TMP:-/tmp}
8
9 config=$NAME.xml
10 mkconfig=$NAME.sh
11
12 if [ "$PORTALS" ]; then
13   portals_opt="--portals=$PORTALS"
14 fi
15
16 if [ "$LUSTRE" ]; then
17   lustre_opt="--lustre=$LUSTRE"
18 fi
19
20 if [ "$LDAPURL" ]; then
21     conf_opt="--ldapurl $LDAPURL --config $NAME"
22 else
23     if [ ! -f $config ]; then
24         sh $mkconfig $config || exit 1
25     fi
26     conf_opt="$config"
27 fi    
28
29 [ "$NODE" ] && node_opt="--node $NODE"
30
31 sync; sleep 2; sync
32 [ "$MOUNT2" ] && umount $MOUNT2
33
34 ${LCONF} $NOMOD $portals_opt $lustre_opt $node_opt --cleanup $@ \
35     --dump $TMP/debug $conf_opt
36 rc=$?
37 echo "lconf DONE"
38 BUSY=`dmesg | grep -i destruct`
39 if [ "$BUSY" ]; then
40         echo "$BUSY" 1>&2
41         mv $TMP/debug $TMP/debug-busy.`date +%s`
42         exit 255
43 fi
44 LEAK_LUSTRE=`dmesg | tail -n 30 | grep "obd mem.*leaked"`
45 LEAK_PORTALS=`dmesg | tail -n 20 | grep "Portals memory leaked"`
46 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
47         echo "$LEAK_LUSTRE" 1>&2
48         echo "$LEAK_PORTALS" 1>&2
49         mv $TMP/debug $TMP/debug-leak.`date +%s`
50         exit 254
51 fi
52 lsmod | grep portals && echo "modules still loaded" && exit 1
53
54 exit $rc