common/rc: factor out _scratch_xfs_[get|set]_sb_field
[xfstests-dev.git] / tests / xfs / 074
1 #! /bin/bash
2 # FS QA Test 074-extsz-hints-vs-maxextlen
3 #
4 # Check some extent size hint boundary conditions that can result in
5 # MAXEXTLEN overflows.
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2015 Red Hat, Inc. All Rights Reserved.
9 #
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
13 #
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22 #
23 #-----------------------------------------------------------------------
24 #
25
26 seq=`basename $0`
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
29
30 _cleanup()
31 {
32         cd /
33         _destroy_loop_device $LOOP_DEV
34         rm -f $tmp.* $LOOP_FILE
35 }
36
37 here=`pwd`
38 tmp=/tmp/$$
39 status=1        # failure is the default!
40 trap "_cleanup; exit \$status" 0 1 2 3 15
41
42 # get standard environment, filters and checks
43 . ./common/rc
44 . ./common/filter
45
46 # real QA test starts here
47 _supported_fs xfs
48 _supported_os Linux
49
50 rm -f $seqres.full
51
52 _require_test
53 _require_xfs_io_command "falloc"
54
55 # we use loop devices for this so that we can create large files for prealloc
56 # without having to care about the underlying device size.
57 _require_loop
58
59 LOOP_FILE=$TEST_DIR/$seq.img
60 LOOP_MNT=$TEST_DIR/$seq.mnt
61 mkdir -p $LOOP_MNT
62 $XFS_IO_PROG -ft -c "truncate 1t" $LOOP_FILE >> $seqres.full
63 LOOP_DEV=`_create_loop_device $LOOP_FILE`
64
65 _mkfs_dev -d size=156452m,agcount=4 -l size=32m $LOOP_DEV
66 _mount $LOOP_DEV $LOOP_MNT
67
68 # Corrupt the BMBT by creating extents larger than MAXEXTLEN
69 $XFS_IO_PROG -ft \
70         -c "extsize 16m" \
71         -c "falloc 0 30g" \
72         $LOOP_MNT/foo >> $seqres.full
73
74 umount $LOOP_MNT
75 _check_xfs_filesystem $LOOP_DEV none none
76
77 _mkfs_dev -f -l size=32m $LOOP_DEV
78 _mount $LOOP_DEV $LOOP_MNT
79
80 # check we trim both ends of the extent approproiately; this will fail
81 # on 1k block size filesystems without the correct fixes in place.
82 $XFS_IO_PROG -ft \
83         -c "extsize 1g" \
84         -c "falloc 1023m 2g" \
85         $LOOP_MNT/foo >> $seqres.full
86
87 umount $LOOP_MNT
88 _check_xfs_filesystem $LOOP_DEV none none
89
90 # success, all done
91 echo "Silence is golden"
92 status=0
93 exit