misc: move exit status into trap handler
[xfstests-dev.git] / tests / ext4 / 306
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. ext4/306
6 #
7 # Test that blocks are available to non-extent files after a resize2fs
8 # Regression test for commit:
9 # c5c72d8 ext4: fix online resizing for ext3-compat file systems
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 PIDS=""
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21     _scratch_unmount
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27
28 # real QA test starts here
29 _supported_fs ext4
30
31 _require_scratch
32 _require_command "$RESIZE2FS_PROG" resize2fs
33
34 rm -f $seqres.full
35
36 # Make a small ext4 fs with extents disabled & mount it
37 features="^extents"
38 if grep -q 64bit /etc/mke2fs.conf ; then
39     features="^extents,^64bit"
40 fi
41 $MKFS_EXT4_PROG -F -O "$features" $SCRATCH_DEV 512m >> $seqres.full 2>&1
42 _scratch_mount
43
44 # Create a small non-extent-based file
45 echo "Create 1m testfile1"
46 $XFS_IO_PROG -f $SCRATCH_MNT/testfile1 -c "pwrite 0 1m" | _filter_xfs_io
47
48 # Create a large non-extent-based file filling the fs; this will run out & fail
49 echo "Create testfile2 to fill the fs"
50 $XFS_IO_PROG -f $SCRATCH_MNT/testfile2 -c "pwrite 0 512m" 2>&1 | \
51         _filter_xfs_io_error
52 df -h $SCRATCH_MNT >> $seqres.full
53
54 # Grow fs by 512m
55 echo "Resize to 1g"
56 $RESIZE2FS_PROG $SCRATCH_DEV 1g >> $seqres.full 2>&1 || _fail "Could not resize to 1g"
57 df -h $SCRATCH_MNT >> $seqres.full
58
59 # See if we can add more blocks to the files
60 echo "append 2m to testfile1"
61 $XFS_IO_PROG -f $SCRATCH_MNT/testfile1 -c "pwrite 1m 2m" | _filter_xfs_io
62 echo "append 2m to testfile2"
63 $XFS_IO_PROG -f $SCRATCH_MNT/testfile1 -c "pwrite 512m 2m" | _filter_xfs_io
64
65 status=0
66 exit