2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2009 Eric Sandeen.
7 # Test trim of last small AG for large filesystem resizes
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
16 seqres=$RESULT_DIR/$seq
17 echo "QA output created by $seq"
21 status=1 # failure is the default!
22 trap "_cleanup; exit \$status" 0 1 2 3 15
32 # get standard environment, filters and checks
36 # real QA test starts here
38 # Modify as appropriate.
43 bitsperlong=`$here/src/feature -w`
44 if [ "$bitsperlong" -ne 64 ]; then
45 _notrun "This test is only valid on 64 bit machines"
50 tmpfile=$TEST_DIR/fsfile.$$
51 tmpdir=$TEST_DIR/tmpdir.$$
53 mkdir -p $tmpdir || _fail "!!! failed to create temp mount dir"
55 # Create a file w/ the offset we wish to resize to
56 echo "=== truncate file ==="
57 dd if=/dev/zero of=$tmpfile bs=1 seek=19998630180864 count=1 >/dev/null 2>&1 \
58 || _fail "!!! failed to truncate loopback file to correct size"
60 # mkfs/growfs output has changed slightly over the years, this distills
61 # it down to a common set of output parameters we care about
64 sed -e 's/meta-data=[^ ]*/meta-data=FILE/' \
65 -e 's/ *isize=[0-9]* / isize=N /' \
66 -e "s/\(^log.*blocks=\)\([0-9]*,\)/\1XXXXX,/" \
67 -e "s/internal log/internal /" \
68 -e "s/, projid32bit=[0-9]//" \
69 -e "s/,\? ftype=[0-9]//" \
71 -e "s/\(sectsz\)\(=[0-9]* *\)/\1=512 /" \
72 -e "s/\(sunit=\)\([0-9]* blks,\)/\10 blks,/" \
73 -e "s/, lazy-count=[0-9]//" \
75 -e "/^Default configuration/d"
78 # mkfs slightly smaller than that, small log for speed.
79 echo "=== mkfs.xfs ==="
80 mkfs.xfs -f -bsize=4096 -l size=32m -dagsize=76288719b,size=3905982455b \
81 $tmpfile | mkfs_filter
83 mount -o loop $tmpfile $tmpdir || _fail "!!! failed to loopback mount"
85 # see what happens when we growfs it
86 echo "=== xfs_growfs ==="
87 xfs_growfs $tmpdir | mkfs_filter
89 # and double-check the new geometry
90 echo "=== xfs_info ==="
91 $XFS_INFO_PROG $tmpdir | mkfs_filter
93 # _cleanup cleans up for us