generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / xfs / 041
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 041
6 #
7 # growfs QA tests - repeatedly fill/grow the filesystem
8 # check the filesystem contents after each operation
9 #
10 set +x
11
12 . ./common/preamble
13 _begin_fstest growfs ioctl auto
14
15 # Override the default cleanup function.
16 _cleanup()
17 {
18     cd /
19     _scratch_unmount
20     rm -f $tmp.*
21 }
22
23 # Import common functions.
24 . ./common/filter
25
26 # real QA test starts here
27 _supported_fs xfs
28
29 _require_scratch
30 _require_no_large_scratch_dev
31 _scratch_unmount 2>/dev/null
32
33 _fill()
34 {
35     if [ $# -ne 1 ]; then echo "Usage: _fill \"path\"" 1>&2 ; exit 1; fi
36     _do "Fill filesystem" \
37         "$here/src/fill2fs --verbose --dir=$1 --seed=0 --filesize=65536 --stddev=32768 --list=- >>$tmp.manifest"
38 }
39
40 _do_die_on_error=message_only
41 agsize=32
42 echo -n "Make $agsize megabyte filesystem on SCRATCH_DEV and mount... "
43 _scratch_mkfs_xfs -dsize=${agsize}m,agcount=1 2>&1 >/dev/null || _fail "mkfs failed"
44 bsize=`_scratch_mkfs_xfs -dsize=${agsize}m,agcount=1 2>&1 | _filter_mkfs 2>&1 \
45                 | perl -ne 'if (/dbsize=(\d+)/) {print $1;}'`
46 onemeginblocks=`expr 1048576 / $bsize`
47 _scratch_mount
48
49 echo "done"
50
51 # full allocation group -> partial; partial -> expand partial + new partial;
52 # partial -> expand partial; partial -> full
53 # cycle through 33m -> 67m -> 75m -> 96m
54 for size in 33 67 75 96
55 do
56     grow_size=`expr $size \* $onemeginblocks`
57     _fill $SCRATCH_MNT/fill_$size
58     _do "Grow filesystem to ${size}m" "xfs_growfs -D $grow_size $SCRATCH_MNT"
59     echo -n "Flush filesystem... "
60     _do "_scratch_unmount"
61     _do "_try_scratch_mount"
62     echo "done"
63     echo -n "Check files... "
64     if ! _do "$here/src/fill2fs_check $tmp.manifest"; then
65       echo "fail (see $seqres.full)"
66       _do "cat $tmp.manifest"
67       _do "ls -altrR $SCRATCH_MNT"
68       _do "dd if=$SCRATCH_DEV bs=4096 count=$grow_size | gzip -9 > $seq.fsimage.gz"
69       status=1 ; exit
70     fi
71     echo "done"
72 done
73
74 # success, all done
75 echo "Growfs tests passed."
76 status=0 ; exit