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