Whamcloud - gitweb
LU-8726 osd-ldiskfs: bypass read for benchmarking
[fs/lustre-release.git] / lustre / tests / oos.sh
1 #!/bin/bash
2
3 set -e
4 #set -vx
5
6 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
7 . $LUSTRE/tests/test-framework.sh
8 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
9
10 export PATH=`dirname $0`/../utils:$PATH
11 LFS=${LFS:-lfs}
12 LCTL=${LCTL:-lctl}
13 MOUNT=${MOUNT:-$1}
14 MOUNT=${MOUNT:-/mnt/lustre}
15 OOS=$MOUNT/oosfile
16 TMP=${TMP:-/tmp}
17 LOG=$TMP/$(basename $0 .sh).log
18
19 SUCCESS=1
20
21 rm -f $OOS $LOG
22
23 sync; sleep 1; sync     # to ensure we get up-to-date statfs info
24
25 #$LCTL set_param -n debug=-1
26 #$LCTL set_param -n subsystem_debug=0x40a8
27
28 #$LCTL clear
29 #$LCTL debug_daemon start /r/tmp/debug 1024
30
31 STRIPECOUNT=`$LCTL get_param -n lov.*.activeobd | head -n 1`
32 ORIGFREE=`$LCTL get_param -n llite.*.kbytesavail | head -n 1`
33 MAXFREE=${MAXFREE:-$((400000 * $STRIPECOUNT))}
34 echo STRIPECOUNT=$STRIPECOUNT ORIGFREE=$ORIGFREE MAXFREE=$MAXFREE
35 if [ $ORIGFREE -gt $MAXFREE ]; then
36         skip "$0: ${ORIGFREE}kB free gt MAXFREE ${MAXFREE}kB, increase $MAXFREE (or reduce test fs size) to proceed"
37         exit 0
38 fi
39
40 export LANG=C LC_LANG=C # for "No space left on device" message
41
42 [ -f $LOG ] && error "log file wasn't removed?"
43
44 echo BEFORE dd started
45 oos_full || true
46
47 # make sure we stripe over all OSTs to avoid OOS on only a subset of OSTs
48 $LFS setstripe $OOS -c $STRIPECOUNT
49 # add 20% of margin since the metadata overhead estimated in bavail might be
50 # too aggressive and we might be able to write more than reported initially
51 # by statfs.
52 echo dd size $((ORIGFREE * 120 / 100))kB
53 if dd if=/dev/zero of=$OOS count=$((ORIGFREE * 120 / 100)) bs=1k 2> $LOG; then
54         echo "ERROR: dd did not fail"
55         SUCCESS=0
56 fi
57
58 [ ! -s "$LOG" ] && error "LOG file is empty!"
59
60 if [ "`grep -c 'No space left on device' $LOG`" -ne 1 ]; then
61         echo "ERROR: dd not return ENOSPC"
62         sed "s/^/LOG: /" $LOG
63         SUCCESS=0
64 fi
65
66 # flush cache to OST(s) so avail numbers are correct
67 sync; sleep 1 ; sync
68
69 echo AFTER dd
70 if ! oos_full; then
71         echo "no OSTs are close to full"
72         SUCCESS=0
73 fi
74
75 RECORDSOUT=`grep "records out" $LOG | cut -d + -f1`
76 FILESIZE=`ls -l $OOS | awk '{ print $5 }'`
77 if [ -z "$RECORDSOUT" ]; then
78         echo "ERROR: no blocks written by dd?"
79         sed "s/^/LOG: /" $LOG
80         SUCCESS=0
81 elif [ "$RECORDSOUT" -ne $((FILESIZE / 1024)) ]; then
82         echo "ERROR: blocks written by dd not equal to the size of file"
83         SUCCESS=0
84 fi
85
86 #$LCTL debug_daemon stop
87
88 [ $SUCCESS != 0 ] && echo LOG file && sed "s/^/LOG: /" $LOG
89 rm -f $OOS
90
91 sync; sleep 3; sync
92
93 wait_delete_completed 300
94
95 if [ $SUCCESS -eq 1 ]; then
96         echo "Success!"
97         rm -f $LOG
98 else
99         exit 1
100 fi