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