Whamcloud - gitweb
572cd65030f082a678c344de85e3fa219ac4ca40
[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 [ "$1" = "--force" ]; then
21   force="--force"
22 fi
23
24 if [ "$LDAPURL" ]; then
25     conf_opt="--ldapurl $LDAPURL --config $NAME"
26 else
27     if [ ! -f $config -o $mkconfig -nt $config ]; then
28         sh $mkconfig $config || exit 1
29     fi
30     conf_opt="$config"
31 fi    
32
33 [ "$NODE" ] && node_opt="--node $NODE"
34
35 sync; sleep 2; sync
36 ${LCONF} $portals_opt $lustre_opt $node_opt --cleanup $force \
37     --dump $TMP/debug $conf_opt
38 rc=$?
39 BUSY=`dmesg | grep -i destruct`
40 if [ "$BUSY" ]; then
41         echo "$BUSY" 1>&2
42         mv $TMP/debug $TMP/debug-busy.`date +%s`
43         exit 255
44 fi
45 LEAK_LUSTRE=`dmesg | grep "obd mem.*leaked" | tail -1 | grep -v "leaked: 0"`
46 LEAK_PORTALS=`dmesg | tail -20 | grep "Portals memory leaked"`
47 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
48         echo "$LEAK_LUSTRE" 1>&2
49         echo "$LEAK_PORTALS" 1>&2
50         mv $TMP/debug $TMP/debug-leak.`date +%s`
51         exit 254
52 fi
53
54 exit $rc