xfstests: move xfs specific tests out of top directory
[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 echo "QA output created by $seq"
27
28 here=`pwd`
29 tmp=/tmp/$$
30 status=1        # failure is the default!
31 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
32
33 # get standard environment, filters and checks
34 . ./common.rc
35 . ./common.filter
36
37 _create_scratch()
38 {
39         echo "*** mkfs"
40         _scratch_mkfs_xfs $@ | tee -a $seq.full | _filter_mkfs 2>$tmp.mkfs
41         . $tmp.mkfs
42
43         echo "*** mount"
44         if ! _scratch_mount 2>/dev/null
45         then
46                 echo "failed to mount $SCRATCH_DEV"
47                 exit 1
48         fi
49
50         # fix the reserve block pool to a known size so that the enospc
51         # calculations work out correctly.
52         _scratch_resvblks 1024 >  /dev/null 2>&1
53 }
54
55 _fill_scratch()
56 {
57         $XFS_IO_PROG -f -c "resvsp 0 ${1}" $SCRATCH_MNT/resvfile
58 }
59
60 _stress_scratch()
61 {
62         procs=3
63         nops=1000
64         # -w ensures that the only ops are ones which cause write I/O
65         FSSTRESS_ARGS=`_scale_fsstress_args -d $SCRATCH_MNT -w -p $procs \
66             -n $nops $FSSTRESS_AVOID`
67         $FSSTRESS_PROG $FSSTRESS_ARGS >> $seq.full &
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