xfstests: randholes: encapsulate direct I/O setup code
[xfstests-dev.git] / 206
1 #! /bin/bash
2 # FS QA Test No. 206
3 #
4 # Test trim of last small AG for large filesystem resizes
5 #
6 # As reported at
7 # http://article.gmane.org/gmane.comp.file-systems.xfs.general/29187
8 # this trimming may cause an overflow in the new size calculation.
9 # Patch and testcase at
10 # http://article.gmane.org/gmane.comp.file-systems.xfs.general/29193
11 #
12 #-----------------------------------------------------------------------
13 # Copyright (c) 2009 Eric Sandeen.
14 #
15 # This program is free software; you can redistribute it and/or
16 # modify it under the terms of the GNU General Public License as
17 # published by the Free Software Foundation.
18 #
19 # This program is distributed in the hope that it would be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 # GNU General Public License for more details.
23 #
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write the Free Software Foundation,
26 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
27 #-----------------------------------------------------------------------
28 #
29 # creator
30 owner=sandeen@sandeen.net
31
32 seq=`basename $0`
33 echo "QA output created by $seq"
34
35 here=`pwd`
36 tmp=/tmp/$$
37 status=1        # failure is the default!
38 trap "_cleanup; exit \$status" 0 1 2 3 15
39
40 _cleanup()
41 {
42     umount $tmpdir
43     rmdir $tmpdir
44     rm -f $tmp
45     rm -f $tmpfile
46 }
47
48 # get standard environment, filters and checks
49 . ./common.rc
50 . ./common.filter
51
52 # real QA test starts here
53
54 # Modify as appropriate.
55 _supported_fs xfs
56 _supported_os IRIX Linux
57
58 bitsperlong=`src/feature -w`
59 if [ "$bitsperlong" -ne 64 ]; then
60         _notrun "This test is only valid on 64 bit machines"
61 fi
62
63 rm -f $seq.full
64
65 tmpfile=$TEST_DIR/fsfile.$$
66 tmpdir=$TEST_DIR/tmpdir.$$
67
68 mkdir -p $tmpdir || _fail "!!! failed to create temp mount dir"
69
70 # Create a file w/ the offset we wish to resize to
71 echo "=== truncate file ==="
72 dd if=/dev/zero of=$tmpfile bs=1 seek=19998630180864 count=1 >/dev/null 2>&1 \
73         || _fail "!!! failed to truncate loopback file to correct size"
74
75 # mkfs slightly smaller than that
76 echo "=== mkfs.xfs ==="
77 mkfs.xfs -f -bsize=4096 -dagsize=76288719b,size=3905982455b -llazy-count=0 $tmpfile \
78         | sed -e "s,^meta-data=.*isize,meta-data=FILE                   isize,g" \
79                 -e "s/\(^log.*blocks=\)\([0-9]*,\)/\1XXXXX,/" \
80                 -e "s/, projid32bit=[0-9]//"
81
82 mount -o loop $tmpfile $tmpdir || _fail "!!! failed to loopback mount"
83
84 # see what happens when we growfs it
85 echo "=== xfs_growfs ==="
86 xfs_growfs $tmpdir \
87         | sed -e "s,^meta-data=.*isize,meta-data=FILE                   isize,g" \
88                 -e "s/\(^log.*blocks=\)\([0-9]*,\)/\1XXXXX,/"
89
90 # and double-check the new geometry
91 echo "=== xfs_info ==="
92 xfs_info $tmpdir \
93         | sed -e "s,^meta-data=.*isize,meta-data=FILE                   isize,g" \
94                 -e "s/\(^log.*blocks=\)\([0-9]*,\)/\1XXXXX,/"
95
96 # _cleanup cleans up for us
97
98 # success, all done
99 status=0
100 exit
101