xfstests: use a common _filter_scratch function
[xfstests-dev.git] / 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 # creator
25 owner=nathans@sgi.com
26
27 seq=`basename $0`
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=1        # failure is the default!
33 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
34
35 # get standard environment, filters and checks
36 . ./common.rc
37 . ./common.filter
38
39 _create_scratch()
40 {
41         echo "*** mkfs"
42         _scratch_mkfs_xfs $@ | tee -a $seq.full | _filter_mkfs 2>$tmp.mkfs
43         . $tmp.mkfs
44
45         echo "*** mount"
46         if ! _scratch_mount 2>/dev/null
47         then
48                 echo "failed to mount $SCRATCH_DEV"
49                 exit 1
50         fi
51
52         # fix the reserve block pool to a known size so that the enospc
53         # calculations work out correctly.
54         _scratch_resvblks 1024 >  /dev/null 2>&1
55 }
56
57 _fill_scratch()
58 {
59         $XFS_IO_PROG -f -c "resvsp 0 ${1}" $SCRATCH_MNT/resvfile
60 }
61
62 _stress_scratch()
63 {
64         procs=3
65         nops=1000
66         # -w ensures that the only ops are ones which cause write I/O
67         $FSSTRESS_PROG -d $SCRATCH_MNT -w -p $procs -n $nops $FSSTRESS_AVOID > /dev/null &
68 }
69
70 # real QA test starts here
71 _supported_fs xfs
72 _require_scratch
73 _scratch_mkfs_xfs | tee -a $seq.full | _filter_mkfs 2>$tmp.mkfs
74 . $tmp.mkfs     # extract blocksize and data size for scratch device
75
76 endsize=`expr 550 \* 1048576`   # stop after growing this big
77 incsize=`expr  42 \* 1048576`   # grow in chunks of this size
78 modsize=`expr   4 \* $incsize`  # pause after this many increments
79
80 [ `expr $endsize / $dbsize` -lt $dblocks ] || _notrun "Scratch device too small"
81
82 nags=4
83 size=`expr 120 \* 1048576`      # 120 megabytes initially
84 sizeb=`expr $size / $dbsize`    # in data blocks
85 echo "*** creating scratch filesystem"
86 _create_scratch -dsize=${size} -dagcount=${nags}
87
88 fillsize=`expr 110 \* 1048576`  # 110 megabytes of filling
89 echo "*** using some initial space on scratch filesystem"
90 _fill_scratch $fillsize
91
92 #
93 # Grow the filesystem while actively stressing it...
94 # Kick off more stress threads on each iteration, grow; repeat.
95 #
96 while [ $size -le $endsize ]; do
97         echo "*** stressing a ${size} byte filesystem"
98         echo "*** stressing a ${sizeb} block filesystem" >> $seq.full
99         _stress_scratch
100         sleep 1
101         size=`expr $size + $incsize`
102         sizeb=`expr $size / $dbsize`    # in data blocks
103         echo "*** growing to a ${size} byte filesystem"
104         echo "*** growing to a ${sizeb} block filesystem" >> $seq.full
105         xfs_growfs -D ${sizeb} $SCRATCH_MNT \
106                 | tee -a $seq.full | _filter_mkfs 2>$tmp.growfs
107         . $tmp.growfs
108         [ `expr $size % $modsize` -eq 0 ] && wait       # every 4th iteration
109         echo AGCOUNT=$agcount | tee -a $seq.full
110         echo && echo >> $seq.full
111 done
112 wait    # stop for any remaining stress processes
113
114 umount $SCRATCH_DEV
115 _check_scratch_fs
116
117 status=0
118 exit