de029c6324717ada1f6784bf77dea5a34b905608
[xfstests-dev.git] / tests / generic / 204
1 #! /bin/bash
2 # FS QA Test No. 204
3 #
4 # Test out ENOSPC flushing on small filesystems.
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2009 Christoph Hellwig.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #-----------------------------------------------------------------------
22 #
23
24 seq=`basename $0`
25 seqres=$RESULT_DIR/$seq
26 echo "QA output created by $seq"
27
28 here=`pwd`
29 tmp=/tmp/$$
30 status=1        # failure is the default!
31 trap "_cleanup; exit \$status" 0 1 2 3 15
32
33 _cleanup()
34 {
35         rm -f $tmp.*
36 }
37
38 # get standard environment, filters and checks
39 . ./common/rc
40 . ./common/filter
41
42 # real QA test starts here
43 _supported_fs generic
44 _supported_os Linux
45
46 _require_scratch
47
48 rm -f $seqres.full
49
50 # get the block size first
51 _scratch_mkfs 2> /dev/null | _filter_mkfs 2> $tmp.mkfs > /dev/null
52 . $tmp.mkfs
53
54 # For xfs, we need to handle the different default log sizes that different
55 # versions of mkfs create. All should be valid with a 5MB log, so use that.
56 [ $FSTYP = "xfs" ] && MKFS_OPTIONS="$MKFS_OPTIONS -l size=7m"
57
58 SIZE=`expr 106 \* 1024 \* 1024`
59 _scratch_mkfs_sized $SIZE $dbsize 2> /dev/null \
60                 | _filter_mkfs 2> $tmp.mkfs > /dev/null
61 _scratch_mount
62
63 . $tmp.mkfs
64
65 # fix the reserve block pool to a known size so that the enospc calculations
66 # work out correctly. Space usages is based 22500 files and 1024 reserved blocks
67 # on a 4k block size 256 byte inode size filesystem.
68 resv_blks=1024
69 space=97920000
70
71 # decrease files for inode size.
72 #       22500 * (256 + 4k) = ~97MB
73 #       files * (isize + bsize) = 97MB
74 #       files = (97920000 / (isize + bsize))
75
76 files=$((space / (isize + dbsize)))
77
78 echo files $files, resvblks $resv_blks >> $seqres.full
79 _scratch_resvblks $resv_blks >> $seqres.full 2>&1
80
81 for i in `seq 1 $files`; do
82     echo -n > $SCRATCH_MNT/$i
83     echo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > $SCRATCH_MNT/$i
84 done
85
86 _check_scratch_fs
87
88 # success, all done
89 echo "*** done"
90 status=0