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