populate: add _require_populate_commands to check for tools
[xfstests-dev.git] / tests / xfs / 104
1 #! /bin/bash
2 # FS QA Test No. 104
3 #
4 # XFS online growfs-while-allocating tests (data subvol variant)
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #
22 #-----------------------------------------------------------------------
23 #
24
25 seq=`basename $0`
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
28
29 here=`pwd`
30 tmp=/tmp/$$
31 status=1        # failure is the default!
32 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
33
34 # get standard environment, filters and checks
35 . ./common/rc
36 . ./common/filter
37
38 _create_scratch()
39 {
40         echo "*** mkfs"
41         _scratch_mkfs_xfs $@ | tee -a $seqres.full | _filter_mkfs 2>$tmp.mkfs
42         . $tmp.mkfs
43
44         echo "*** mount"
45         if ! _scratch_mount 2>/dev/null
46         then
47                 echo "failed to mount $SCRATCH_DEV"
48                 exit 1
49         fi
50
51         # fix the reserve block pool to a known size so that the enospc
52         # calculations work out correctly.
53         _scratch_resvblks 1024 >  /dev/null 2>&1
54 }
55
56 _fill_scratch()
57 {
58         $XFS_IO_PROG -f -c "resvsp 0 ${1}" $SCRATCH_MNT/resvfile
59 }
60
61 _stress_scratch()
62 {
63         procs=3
64         nops=1000
65         # -w ensures that the only ops are ones which cause write I/O
66         FSSTRESS_ARGS=`_scale_fsstress_args -d $SCRATCH_MNT -w -p $procs \
67             -n $nops $FSSTRESS_AVOID`
68         $FSSTRESS_PROG $FSSTRESS_ARGS >> $seqres.full &
69 }
70
71 # real QA test starts here
72 _supported_fs xfs
73 _require_scratch
74
75 rm -f $seqres.full
76 _scratch_mkfs_xfs | tee -a $seqres.full | _filter_mkfs 2>$tmp.mkfs
77 . $tmp.mkfs     # extract blocksize and data size for scratch device
78
79 endsize=`expr 550 \* 1048576`   # stop after growing this big
80 incsize=`expr  42 \* 1048576`   # grow in chunks of this size
81 modsize=`expr   4 \* $incsize`  # pause after this many increments
82
83 [ `expr $endsize / $dbsize` -lt $dblocks ] || _notrun "Scratch device too small"
84
85 nags=4
86 size=`expr 125 \* 1048576`      # 120 megabytes initially
87 sizeb=`expr $size / $dbsize`    # in data blocks
88 echo "*** creating scratch filesystem"
89 _create_scratch -lsize=10m -dsize=${size} -dagcount=${nags}
90
91 echo "*** using some initial space on scratch filesystem"
92 for i in `seq 125 -1 90`; do
93         fillsize=`expr $i \* 1048576`
94         out="$(_fill_scratch $fillsize 2>&1)"
95         echo "$out" | grep -q 'No space left on device' && continue
96         test -n "${out}" && echo "$out"
97         break
98 done
99
100 #
101 # Grow the filesystem while actively stressing it...
102 # Kick off more stress threads on each iteration, grow; repeat.
103 #
104 while [ $size -le $endsize ]; do
105         echo "*** stressing filesystem"
106         echo "*** stressing a ${sizeb} block filesystem" >> $seqres.full
107         _stress_scratch
108         sleep 1
109         size=`expr $size + $incsize`
110         sizeb=`expr $size / $dbsize`    # in data blocks
111         echo "*** growing filesystem"
112         echo "*** growing to a ${sizeb} block filesystem" >> $seqres.full
113         xfs_growfs -D ${sizeb} $SCRATCH_MNT \
114                 | tee -a $seqres.full | _filter_mkfs 2>$tmp.growfs
115         . $tmp.growfs
116         [ `expr $size % $modsize` -eq 0 ] && wait       # every 4th iteration
117         echo AGCOUNT=$agcount | tee -a $seqres.full
118         echo && echo >> $seqres.full
119 done
120 wait    # stop for any remaining stress processes
121
122 _scratch_unmount
123
124 status=0
125 exit