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 _begin_fstest growfs auto quick
18 # Override the default cleanup function.
27 # Import common functions.
30 # real QA test starts here
32 # Modify as appropriate.
37 bitsperlong=`$here/src/feature -w`
38 if [ "$bitsperlong" -ne 64 ]; then
39 _notrun "This test is only valid on 64 bit machines"
42 tmpfile=$TEST_DIR/fsfile.$$
43 tmpdir=$TEST_DIR/tmpdir.$$
45 mkdir -p $tmpdir || _fail "!!! failed to create temp mount dir"
47 # Create a file w/ the offset we wish to resize to
48 echo "=== truncate file ==="
49 dd if=/dev/zero of=$tmpfile bs=1 seek=19998630180864 count=1 >/dev/null 2>&1 \
50 || _fail "!!! failed to truncate loopback file to correct size"
52 # mkfs/growfs output has changed slightly over the years, this distills
53 # it down to a common set of output parameters we care about
56 sed -e 's/meta-data=[^ ]*/meta-data=FILE/' \
57 -e 's/ *isize=[0-9]* / isize=N /' \
58 -e "s/\(^log.*blocks=\)\([0-9]*,\)/\1XXXXX,/" \
59 -e "s/internal log/internal /" \
60 -e "s/, projid32bit=[0-9]//" \
61 -e "s/,\? ftype=[0-9]//" \
63 -e "s/\(sectsz\)\(=[0-9]* *\)/\1=512 /" \
64 -e "s/\(sunit=\)\([0-9]* blks,\)/\10 blks,/" \
65 -e "s/, lazy-count=[0-9]//" \
67 -e "/^Default configuration/d"
70 # mkfs slightly smaller than that, small log for speed.
71 echo "=== mkfs.xfs ==="
72 mkfs.xfs -f -bsize=4096 -l size=32m -dagsize=76288719b,size=3905982455b \
73 $tmpfile | mkfs_filter
75 mount -o loop $tmpfile $tmpdir || _fail "!!! failed to loopback mount"
77 # see what happens when we growfs it
78 echo "=== xfs_growfs ==="
79 xfs_growfs $tmpdir | mkfs_filter
81 # and double-check the new geometry
82 echo "=== xfs_info ==="
83 $XFS_INFO_PROG $tmpdir | mkfs_filter
85 # _cleanup cleans up for us