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