7f4e725ec75eab4dc34724eb742f14c0ff5e013a
[xfstests-dev.git] / tests / xfs / 206
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2009 Eric Sandeen.
4 #
5 # FS QA Test No. 206
6 #
7 # Test trim of last small AG for large filesystem resizes
8 #
9 # As reported at
10 # http://article.gmane.org/gmane.comp.file-systems.xfs.general/29187
11 # this trimming may cause an overflow in the new size calculation.
12 # Patch and testcase at
13 # http://article.gmane.org/gmane.comp.file-systems.xfs.general/29193
14 #
15 seq=`basename $0`
16 seqres=$RESULT_DIR/$seq
17 echo "QA output created by $seq"
18
19 here=`pwd`
20 tmp=/tmp/$$
21 status=1        # failure is the default!
22 trap "_cleanup; exit \$status" 0 1 2 3 15
23
24 _cleanup()
25 {
26     umount $tmpdir
27     rmdir $tmpdir
28     rm -f $tmp
29     rm -f $tmpfile
30 }
31
32 # get standard environment, filters and checks
33 . ./common/rc
34 . ./common/filter
35
36 # real QA test starts here
37
38 # Modify as appropriate.
39 _supported_fs xfs
40 _supported_os Linux
41 _require_test
42 _require_loop
43
44 bitsperlong=`src/feature -w`
45 if [ "$bitsperlong" -ne 64 ]; then
46         _notrun "This test is only valid on 64 bit machines"
47 fi
48
49 rm -f $seqres.full
50
51 tmpfile=$TEST_DIR/fsfile.$$
52 tmpdir=$TEST_DIR/tmpdir.$$
53
54 mkdir -p $tmpdir || _fail "!!! failed to create temp mount dir"
55
56 # Create a file w/ the offset we wish to resize to
57 echo "=== truncate file ==="
58 dd if=/dev/zero of=$tmpfile bs=1 seek=19998630180864 count=1 >/dev/null 2>&1 \
59         || _fail "!!! failed to truncate loopback file to correct size"
60
61 # mkfs/growfs output has changed slightly over the years, this distills
62 # it down to a common set of output parameters we care about
63 mkfs_filter()
64 {
65         sed -e 's/meta-data=[^ ]*/meta-data=FILE/' \
66             -e 's/ *isize=[0-9]* / isize=N /' \
67             -e "s/\(^log.*blocks=\)\([0-9]*,\)/\1XXXXX,/" \
68             -e "s/internal log/internal    /" \
69             -e "s/, projid32bit=[0-9]//" \
70             -e "s/,\? ftype=[0-9]//" \
71             -e "/.*reflink=/d" \
72             -e "s/\(sectsz\)\(=[0-9]* *\)/\1=512   /" \
73             -e "s/\(sunit=\)\([0-9]* blks,\)/\10 blks,/" \
74             -e "s/, lazy-count=[0-9]//" \
75             -e "/.*crc=/d" \
76             -e "/^Default configuration/d"
77 }
78
79 # mkfs slightly smaller than that, small log for speed.
80 echo "=== mkfs.xfs ==="
81 mkfs.xfs -f -bsize=4096 -l size=32m -dagsize=76288719b,size=3905982455b \
82          $tmpfile  | mkfs_filter
83
84 mount -o loop $tmpfile $tmpdir || _fail "!!! failed to loopback mount"
85
86 # see what happens when we growfs it
87 echo "=== xfs_growfs ==="
88 xfs_growfs $tmpdir  | mkfs_filter
89
90 # and double-check the new geometry
91 echo "=== xfs_info ==="
92 $XFS_INFO_PROG $tmpdir | mkfs_filter
93
94 # _cleanup cleans up for us
95
96 # success, all done
97 status=0
98 exit
99