Whamcloud - gitweb
Landing b_bug974 onto HEAD (20040213_1538).
[fs/lustre-release.git] / lustre / tests / oos2.sh
1 #!/bin/bash
2
3 set -e
4 set -vx
5
6 export PATH=`dirname $0`/../utils:$PATH
7 LFS=${LFS:-lfs}
8 MOUNT=${MOUNT:-$1}
9 MOUNT=${MOUNT:-/mnt/lustre}
10 MOUNT2=${MOUNT2:-$2}
11 MOUNT2=${MOUNT2:-${MOUNT}2}
12 OOS=$MOUNT/oosfile
13 OOS2=$MOUNT2/oosfile2
14 TMP=${TMP:-/tmp}
15 LOG=$TMP/oosfile
16 LOG2=${LOG}2
17
18 SUCCESS=1
19
20 rm -f $OOS $OOS2 $LOG $LOG2
21
22 sleep 1 # to ensure we get up-to-date statfs info
23
24 STRIPECOUNT=`cat /proc/fs/lustre/lov/*/activeobd | head -1`
25 ORIGFREE=`cat /proc/fs/lustre/llite/*/kbytesavail | head -1`
26 MAXFREE=${MAXFREE:-$((200000 * $STRIPECOUNT))}
27 if [ $ORIGFREE -gt $MAXFREE ]; then
28         echo "skipping out-of-space test on $OSC"
29         echo "reports ${ORIGFREE}kB free, more tham MAXFREE ${MAXFREE}kB"
30         echo "increase $MAXFREE (or reduce test fs size) to proceed"
31         exit 0
32 fi
33
34 export LANG=C LC_LANG=C # for "No space left on device" message
35
36 # make sure we stripe over all OSTs to avoid OOS on only a subset of OSTs
37 $LFS setstripe $OOS 65536 -1 $STRIPECOUNT
38 $LFS setstripe $OOS2 65536 -1 $STRIPECOUNT
39 dd if=/dev/zero of=$OOS count=$((3 * $ORIGFREE / 4 + 100)) bs=1k 2>> $LOG &
40 DDPID=$!
41 if dd if=/dev/zero of=$OOS2 count=$((3*$ORIGFREE/4 + 100)) bs=1k 2>> $LOG2; then
42         echo "ERROR: dd2 did not fail"
43         SUCCESS=0
44 fi
45 if wait $DDPID; then
46         echo "ERROR: dd did not fail"
47         SUCCESS=0
48 fi
49
50 if [ "`cat $LOG $LOG2 | grep -c 'No space left on device'`" -ne 2 ]; then
51         echo "ERROR: dd not return ENOSPC"
52         SUCCESS=0
53 fi
54
55 # flush cache to OST(s) so avail numbers are correct
56 sync; sleep 1 ; sync
57
58 for AVAIL in /proc/fs/lustre/osc/OSC*MNT*/kbytesavail; do
59         [ `cat $AVAIL` -lt 400 ] && OSCFULL=full
60 done
61 if [ -z "$OSCFULL" ]; then
62         echo "no OSTs are close to full"
63         grep "[0-9]" /proc/fs/lustre/osc/OSC*MNT*/{kbytesavail,cur*} |tee -a $LOG
64         SUCCESS=0
65 fi
66
67 RECORDSOUT=$((`grep "records out" $LOG | cut -d+ -f 1` + \
68               `grep "records out" $LOG2 | cut -d+ -f 1`))
69
70 FILESIZE=$((`ls -l $OOS | awk '{print $5}'` + `ls -l $OOS2 | awk '{print $5}'`))
71 if [ $RECORDSOUT -ne $(($FILESIZE / 1024)) ]; then
72         echo "ERROR: blocks written by dd not equal to the size of file"
73         SUCCESS=0
74 fi
75
76 rm -f $OOS $OOS2
77
78 if [ $SUCCESS -eq 1 ]; then
79         echo "Success!"
80 else
81         exit 1
82 fi