xfs/007: fix regressions on V4 filesystems
[xfstests-dev.git] / tests / xfs / 104
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 104
6 #
7 # XFS online growfs-while-allocating tests (data subvol variant)
8 #
9 . ./common/preamble
10 _begin_fstest growfs ioctl prealloc auto stress
11
12 # Import common functions.
13 . ./common/filter
14
15 _create_scratch()
16 {
17         echo "*** mkfs"
18         _scratch_mkfs_xfs $@ | tee -a $seqres.full | _filter_mkfs 2>$tmp.mkfs
19         . $tmp.mkfs
20
21         echo "*** mount"
22         if ! _try_scratch_mount 2>/dev/null
23         then
24                 echo "failed to mount $SCRATCH_DEV"
25                 exit 1
26         fi
27
28         # fix the reserve block pool to a known size so that the enospc
29         # calculations work out correctly.
30         _scratch_resvblks 1024 >  /dev/null 2>&1
31 }
32
33 _fill_scratch()
34 {
35         $XFS_IO_PROG -f -c "resvsp 0 ${1}" $SCRATCH_MNT/resvfile
36 }
37
38 _stress_scratch()
39 {
40         procs=3
41         nops=1000
42         # -w ensures that the only ops are ones which cause write I/O
43         FSSTRESS_ARGS=`_scale_fsstress_args -d $SCRATCH_MNT -w -p $procs \
44             -n $nops $FSSTRESS_AVOID`
45         $FSSTRESS_PROG $FSSTRESS_ARGS >> $seqres.full 2>&1 &
46 }
47
48 # real QA test starts here
49 _supported_fs xfs
50 _require_scratch
51 _require_xfs_io_command "falloc"
52
53 _scratch_mkfs_xfs | tee -a $seqres.full | _filter_mkfs 2>$tmp.mkfs
54 . $tmp.mkfs     # extract blocksize and data size for scratch device
55
56 endsize=`expr 550 \* 1048576`   # stop after growing this big
57 incsize=`expr  42 \* 1048576`   # grow in chunks of this size
58 modsize=`expr   4 \* $incsize`  # pause after this many increments
59
60 [ `expr $endsize / $dbsize` -lt $dblocks ] || _notrun "Scratch device too small"
61
62 nags=4
63 size=`expr 125 \* 1048576`      # 120 megabytes initially
64 sizeb=`expr $size / $dbsize`    # in data blocks
65 echo "*** creating scratch filesystem"
66 logblks=$(_scratch_find_xfs_min_logblocks -dsize=${size} -dagcount=${nags})
67 _create_scratch -lsize=${logblks}b -dsize=${size} -dagcount=${nags}
68
69 echo "*** using some initial space on scratch filesystem"
70 for i in `seq 125 -1 90`; do
71         fillsize=`expr $i \* 1048576`
72         out="$(_fill_scratch $fillsize 2>&1)"
73         echo "$out" | grep -q 'No space left on device' && continue
74         test -n "${out}" && echo "$out"
75         break
76 done
77
78 #
79 # Grow the filesystem while actively stressing it...
80 # Kick off more stress threads on each iteration, grow; repeat.
81 #
82 while [ $size -le $endsize ]; do
83         echo "*** stressing filesystem"
84         echo "*** stressing a ${sizeb} block filesystem" >> $seqres.full
85         _stress_scratch
86         sleep 1
87         size=`expr $size + $incsize`
88         sizeb=`expr $size / $dbsize`    # in data blocks
89         echo "*** growing filesystem"
90         echo "*** growing to a ${sizeb} block filesystem" >> $seqres.full
91         xfs_growfs -D ${sizeb} $SCRATCH_MNT \
92                 | tee -a $seqres.full | _filter_mkfs 2>$tmp.growfs
93         . $tmp.growfs
94         [ `expr $size % $modsize` -eq 0 ] && wait       # every 4th iteration
95         echo AGCOUNT=$agcount | tee -a $seqres.full
96         echo && echo >> $seqres.full
97 done
98 wait    # stop for any remaining stress processes
99
100 _scratch_unmount
101
102 status=0
103 exit