01782b7b93a92c16e1c7330340aec8926012a78b
[xfstests-dev.git] / tests / xfs / 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
30 seq=`basename $0`
31 seqres=$RESULT_DIR/$seq
32 echo "QA output created by $seq"
33
34 here=`pwd`
35 tmp=/tmp/$$
36 status=1        # failure is the default!
37 trap "_cleanup; exit \$status" 0 1 2 3 15
38
39 _cleanup()
40 {
41     umount $tmpdir
42     rmdir $tmpdir
43     rm -f $tmp
44     rm -f $tmpfile
45 }
46
47 # get standard environment, filters and checks
48 . ./common/rc
49 . ./common/filter
50
51 # real QA test starts here
52
53 # Modify as appropriate.
54 _supported_fs xfs
55 _supported_os Linux
56 _require_test
57 _require_loop
58
59 bitsperlong=`src/feature -w`
60 if [ "$bitsperlong" -ne 64 ]; then
61         _notrun "This test is only valid on 64 bit machines"
62 fi
63
64 rm -f $seqres.full
65
66 tmpfile=$TEST_DIR/fsfile.$$
67 tmpdir=$TEST_DIR/tmpdir.$$
68
69 mkdir -p $tmpdir || _fail "!!! failed to create temp mount dir"
70
71 # Create a file w/ the offset we wish to resize to
72 echo "=== truncate file ==="
73 dd if=/dev/zero of=$tmpfile bs=1 seek=19998630180864 count=1 >/dev/null 2>&1 \
74         || _fail "!!! failed to truncate loopback file to correct size"
75
76 mkfs_filter()
77 {
78         sed -e 's/meta-data=[^ ]*/meta-data=FILE/' \
79             -e 's/ *isize=[0-9]* / isize=N /' \
80             -e "s/\(^log.*blocks=\)\([0-9]*,\)/\1XXXXX,/" \
81             -e "s/, projid32bit=[0-9]//" \
82             -e "s/ ftype=[0-9]//" \
83             -e "/.*reflink=/d" \
84             -e "s/\(sectsz\)\(=[0-9]* *\)/\1=512   /" \
85             -e "s/\(sunit=\)\([0-9]* blks,\)/\10 blks,/" \
86             -e "s/, lazy-count=[0-9]//" \
87             -e "/.*crc=/d" \
88             -e "/^Default configuration/d"
89 }
90
91 # mkfs slightly smaller than that, small log for speed.
92 echo "=== mkfs.xfs ==="
93 mkfs.xfs -f -bsize=4096 -l size=32m -dagsize=76288719b,size=3905982455b \
94          $tmpfile  | mkfs_filter
95
96 mount -o loop $tmpfile $tmpdir || _fail "!!! failed to loopback mount"
97
98 # see what happens when we growfs it
99 echo "=== xfs_growfs ==="
100 xfs_growfs $tmpdir  | mkfs_filter
101
102 # and double-check the new geometry
103 echo "=== xfs_info ==="
104 xfs_info $tmpdir | mkfs_filter
105
106 # _cleanup cleans up for us
107
108 # success, all done
109 status=0
110 exit
111