ef9704f00deee0e82841062a5c656920e9ed7e1f
[xfstests-dev.git] / tests / generic / 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
30 seq=`basename $0`
31 seqres=$RESULT_DIR/$seq
32 seqres=$RESULT_DIR/$seq
33 seqres=$RESULT_DIR/$seq
34 echo "QA output created by $seq"
35
36 here=`pwd`
37 tmp=/tmp/$$
38 status=1        # failure is the default!
39
40 _cleanup()
41 {
42         rm -f $tmp.*
43         rm -f $SCRATCH_MNT/testfile.*
44 }
45
46 trap "_cleanup ; exit \$status" 0 1 2 3 15
47
48 # get standard environment, filters and checks
49 . ./common/rc
50 . ./common/filter
51
52 # real QA test starts here
53 _supported_fs generic
54 _supported_os Linux
55
56 _require_scratch
57
58 # make a 1GB filesystem
59 _scratch_mkfs_sized `expr 1024 \* 1024 \* 1024` > $seqres.full 2>&1
60 _scratch_mount >> $seqres.full 2>&1
61
62 # set the reserved block pool to almost empty for XFS
63 if [ "$FSTYP" = "xfs" ]; then
64         xfs_io -x -c "resblks 4" $SCRATCH_MNT >> $seqres.full 2>&1
65 fi
66
67 FILES=1000
68 for i in `seq 0 1 $FILES`; do
69
70         # set the file size to be 10MB - that way the direct IO will always try
71         # to read at least 10MB even if only 4k was written. This allows
72         # discarded delalloc pages that would have been beyond EOF to be
73         # tripped over.
74         (
75                 sleep 5
76                 xfs_io -f -c "truncate 10485760" $SCRATCH_MNT/testfile.$i
77                 dd if=/dev/zero of=$SCRATCH_MNT/testfile.$i bs=4k conv=notrunc
78         ) > /dev/null 2>&1 &
79 done
80 wait
81
82 for i in `seq 0 1 $FILES`; do
83         dd of=/dev/null if=$SCRATCH_MNT/testfile.$i bs=512k iflag=direct > /dev/null 2>&1 &
84 done
85 wait
86 echo "*** Silence is golden ***"
87 status=0
88 exit