generic: test MADV_POPULATE_READ with IO errors
[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 . ./common/preamble
16 _begin_fstest growfs auto quick
17
18 # Override the default cleanup function.
19 _cleanup()
20 {
21     umount $tmpdir
22     rmdir $tmpdir
23     rm -f $tmp
24     rm -f $tmpfile
25 }
26
27 # Import common functions.
28 . ./common/filter
29
30 # real QA test starts here
31
32 # Modify as appropriate.
33 _supported_fs xfs
34 _require_test
35 _require_loop
36
37 bitsperlong=`$here/src/feature -w`
38 if [ "$bitsperlong" -ne 64 ]; then
39         _notrun "This test is only valid on 64 bit machines"
40 fi
41
42 tmpfile=$TEST_DIR/fsfile.$$
43 tmpdir=$TEST_DIR/tmpdir.$$
44
45 mkdir -p $tmpdir || _fail "!!! failed to create temp mount dir"
46
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"
51
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
54 mkfs_filter()
55 {
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]//" \
62             -e "/.*reflink=/d" \
63             -e "s/\(sectsz\)\(=[0-9]* *\)/\1=512   /" \
64             -e "s/\(sunit=\)\([0-9]* blks,\)/\10 blks,/" \
65             -e "s/, lazy-count=[0-9]//" \
66             -e "/.*crc=/d" \
67             -e "/^Default configuration/d"
68 }
69
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
74
75 mount -o loop $tmpfile $tmpdir || _fail "!!! failed to loopback mount"
76
77 # see what happens when we growfs it
78 echo "=== xfs_growfs ==="
79 xfs_growfs $tmpdir  | mkfs_filter
80
81 # and double-check the new geometry
82 echo "=== xfs_info ==="
83 $XFS_INFO_PROG $tmpdir | mkfs_filter
84
85 # _cleanup cleans up for us
86
87 # success, all done
88 status=0
89 exit
90