Whamcloud - gitweb
LU-6210 utils: Use C99 initializer in jt_obd_md_common()
[fs/lustre-release.git] / lustre / tests / run_tar.sh
1 #!/bin/bash
2
3 TMP=${TMP:-/tmp}
4
5 TESTLOG_PREFIX=${TESTLOG_PREFIX:-$TMP/recovery-mds-scale}
6 TESTNAME=${TESTNAME:-""}
7 [ -n "$TESTNAME" ] && TESTLOG_PREFIX=$TESTLOG_PREFIX.$TESTNAME
8
9 LOG=$TESTLOG_PREFIX.$(basename $0 .sh)_stdout.$(hostname -s).log
10 DEBUGLOG=$(echo $LOG | sed 's/\(.*\)stdout/\1debug/')
11
12 mkdir -p ${LOG%/*}
13
14 rm -f $LOG $DEBUGLOG
15 exec 2>$DEBUGLOG
16 set -x
17
18 . $(dirname $0)/functions.sh
19
20 assert_env MOUNT END_RUN_FILE LOAD_PID_FILE LFS CLIENT_COUNT LCTL
21
22 trap signaled TERM
23
24 # recovery-*-scale scripts use this to signal the client loads to die
25 echo $$ >$LOAD_PID_FILE
26
27 TESTDIR=$MOUNT/d0.tar-$(hostname)
28
29 do_tar() {
30     tar cf - /etc | tar xf - >$LOG 2>&1
31     return ${PIPESTATUS[1]}
32 }
33
34 CONTINUE=true
35 while [ ! -e "$END_RUN_FILE" ] && $CONTINUE; do
36         echoerr "$(date +'%F %H:%M:%S'): tar run starting"
37         mkdir -p $TESTDIR
38         cd $TESTDIR
39         sync
40
41         USAGE=$(du -s /etc | awk '{print $1}')
42         $LCTL set_param llite.*.lazystatfs=0
43         df $TESTDIR || true
44         sleep 2
45         FREE_SPACE=$(df $TESTDIR | awk '/:/ { print $4 }')
46         AVAIL=$((FREE_SPACE * 9 / 10 / CLIENT_COUNT))
47         if [ $AVAIL -lt $USAGE ]; then
48                 echoerr "no enough free disk space: need $USAGE, avail $AVAIL"
49                 echo $(hostname) >> $END_RUN_FILE
50                 break
51         fi
52
53         do_tar
54         RC=$?
55         PREV_ERRORS=$(grep "exit delayed from previous errors" $LOG) || true
56         if [ $RC -ne 0 -a "$ERRORS_OK" -a "$PREV_ERRORS" ]; then
57                 echoerr "$(date +'%F %H:%M:%S'): tar errors earlier, ignoring"
58                 RC=0
59         fi
60         if [ $RC -eq 0 ]; then
61                 echoerr "$(date +'%F %H:%M:%S'): tar succeeded"
62                 cd $TMP
63                 rm -rf $TESTDIR
64                 echoerr "$(date +'%F %H:%M:%S'): tar run finished"
65         else
66                 echoerr "$(date +'%F %H:%M:%S'): tar failed"
67                 if [ -z "$ERRORS_OK" ]; then
68                         echo $(hostname) >> $END_RUN_FILE
69                 fi
70                 if [ $BREAK_ON_ERROR ]; then
71                         # break
72                         CONTINUE=false
73                 fi
74         fi
75 done
76
77 echoerr "$(date +'%F %H:%M:%S'): tar run exiting"