common: rework _require_ext4_mkfs_feature
[xfstests-dev.git] / tests / ext4 / 306
1 #! /bin/bash
2 # FS QA Test No. ext4/306
3 #
4 # Test that blocks are available to non-extent files after a resize2fs
5 # Regression test for commit:
6 # c5c72d8 ext4: fix online resizing for ext3-compat file systems
7 #
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2013 Red Hat, Inc.  All Rights Reserved.
10 #
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
14 #
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
23 #-----------------------------------------------------------------------
24
25 seq=`basename $0`
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
28
29 PIDS=""
30 status=1        # failure is the default!
31 trap "_cleanup; exit \$status" 0 1 2 3 15
32
33 _cleanup()
34 {
35     _scratch_unmount
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 ext4
44 _supported_os Linux
45
46 _require_scratch
47
48 rm -f $seqres.full
49
50 # Make a small ext4 fs with extents disabled & mount it
51 features="^extents"
52 if grep -q 64bit /etc/mke2fs.conf ; then
53     features="^extents,^64bit"
54 fi
55 $MKFS_EXT4_PROG -F -O "$features" $SCRATCH_DEV 512m >> $seqres.full 2>&1
56 _scratch_mount || _fail "couldn't mount fs"
57
58 # Create a small non-extent-based file
59 echo "Create 1m testfile1"
60 $XFS_IO_PROG -f $SCRATCH_MNT/testfile1 -c "pwrite 0 1m" | _filter_xfs_io
61
62 # Create a large non-extent-based file filling the fs; this will run out & fail
63 echo "Create testfile2 to fill the fs"
64 $XFS_IO_PROG -f $SCRATCH_MNT/testfile2 -c "pwrite 0 512m" 2>&1 | \
65         _filter_xfs_io_error
66 df -h $SCRATCH_MNT >> $seqres.full
67
68 # Grow fs by 512m
69 echo "Resize to 1g"
70 resize2fs $SCRATCH_DEV 1g >> $seqres.full 2>&1 || _fail "Could not resize to 1g"
71 df -h $SCRATCH_MNT >> $seqres.full
72
73 # See if we can add more blocks to the files
74 echo "append 2m to testfile1"
75 $XFS_IO_PROG -f $SCRATCH_MNT/testfile1 -c "pwrite 1m 2m" | _filter_xfs_io
76 echo "append 2m to testfile2"
77 $XFS_IO_PROG -f $SCRATCH_MNT/testfile1 -c "pwrite 512m 2m" | _filter_xfs_io
78
79 status=0
80 exit