xfstests: Do not allow step to be zero
[xfstests-dev.git] / 224
1 #! /bin/bash
2 # FS QA Test No. 224
3 #
4 # Delayed allocation at ENOSPC test
5 #
6 # Derived from a test case from Lachlan McIlroy and improved to
7 # reliably trigger a BUG in xfs_get_blocks(). Despite this XFS
8 # focus, the test can to run on any filesystem to exercise ENOSPC
9 # behaviour.
10 #
11 #-----------------------------------------------------------------------
12 # Copyright (c) 2010 Dave Chinner.  All Rights Reserved.
13 #
14 # This program is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License as
16 # published by the Free Software Foundation.
17 #
18 # This program is distributed in the hope that it would be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 # GNU General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write the Free Software Foundation,
25 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
26 #
27 #-----------------------------------------------------------------------
28 #
29 # creator
30 owner=david@fromorbit.com
31
32 seq=`basename $0`
33 echo "QA output created by $seq"
34
35 here=`pwd`
36 tmp=/tmp/$$
37 status=1        # failure is the default!
38
39 _cleanup()
40 {
41         rm -f $tmp.*
42         rm -f $SCRATCH_MNT/testfile.*
43 }
44
45 trap "_cleanup ; exit \$status" 0 1 2 3 15
46
47 # get standard environment, filters and checks
48 . ./common.rc
49 . ./common.filter
50
51 # real QA test starts here
52 _supported_fs generic
53 _supported_os Linux
54
55 _require_scratch
56
57 # make a 1GB filesystem
58 _scratch_mkfs_sized `expr 1024 \* 1024 \* 1024` > $seq.full 2>&1
59 _scratch_mount >> $seq.full 2>&1
60
61 # set the reserved block pool to almost empty for XFS
62 if [ "$FSTYP" = "xfs" ]; then
63         xfs_io -x -c "resblks 4" $SCRATCH_MNT >> $seq.full 2>&1
64 fi
65
66 FILES=1000
67 for i in `seq 0 1 $FILES`; do
68
69         # set the file size to be 10MB - that way the direct IO will always try
70         # to read at least 10MB even if only 4k was written. This allows
71         # discarded delalloc pages that would have been beyond EOF to be
72         # tripped over.
73         (
74                 sleep 5
75                 xfs_io -f -c "truncate 10485760" $SCRATCH_MNT/testfile.$i
76                 dd if=/dev/zero of=$SCRATCH_MNT/testfile.$i bs=4k conv=notrunc
77         ) > /dev/null 2>&1 &
78 done
79 wait
80
81 for i in `seq 0 1 $FILES`; do
82         dd of=/dev/null if=$SCRATCH_MNT/testfile.$i bs=512k iflag=direct > /dev/null 2>&1 &
83 done
84 wait
85 echo "*** Silence is golden ***"
86 status=0
87 exit