xfstests: Automatic build dependency calculations
[xfstests-dev.git] / 078
1 #! /bin/bash
2 # FS QA Test No. 078
3 #
4 # Check several growfs corner cases
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2003,2006 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
33
34 trap "_cleanup; rm -f $tmp.*; exit \$status" 0 1 2 3 15
35
36 _cleanup()
37 {
38     cd /
39     rm -f $tmp.*
40     umount $LOOP_MNT 2>/dev/null
41     rmdir $LOOP_MNT
42     _cleanup_testdir
43 }
44
45 # get standard environment, filters and checks
46 . ./common.rc
47 . ./common.filter
48
49 # loop devices are available in Linux only
50 _supported_fs xfs
51 _supported_os Linux
52
53 # Must have loop device
54 _require_loop
55
56 LOOP_DEV=$TEST_DIR/$seq.fs
57 LOOP_MNT=$TEST_DIR/$seq.mnt
58
59 _filter_io()
60 {
61         sed -e '/.* ops; /d'
62 }
63
64 # real QA test starts here
65
66 echo "*** create loop mount point"
67 rmdir $LOOP_MNT 2>/dev/null
68 mkdir -p $LOOP_MNT || _fail "cannot create loopback mount point"
69
70 _grow_loop()
71 {
72         original=$1
73         new_size=$2
74         bsize=$3
75         check=$4
76         agsize=$5
77
78         dparam="file,name=$LOOP_DEV,size=$original"
79         if [ -n "$agsize" ]; then
80                 dparam="$dparam,agsize=$agsize"
81         fi
82
83         echo
84         echo "=== GROWFS (from $original to $new_size, $bsize blocksize)"
85         echo
86
87         echo "*** mkfs loop file (size=$original)"
88         $MKFS_XFS_PROG -b size=$bsize -d $dparam \
89                 | _filter_mkfs 2>/dev/null
90
91         echo "*** extend loop file"
92         $XFS_IO_PROG -c "pwrite $new_size $bsize" $LOOP_DEV | _filter_io
93         echo "*** mount loop filesystem"
94         mount -t xfs -o loop $LOOP_DEV $LOOP_MNT
95
96         echo "*** grow loop filesystem"
97         #xfs_growfs $LOOP_MNT 2>&1 | grep -e "^data" #| _filter_growfs 2>/dev/null
98         $XFS_GROWFS_PROG $LOOP_MNT 2>&1 |  _filter_growfs 2>&1
99
100         echo "*** unmount"
101         umount $LOOP_MNT
102
103         # Large grows takes forever to check..
104         if [ "$check" -gt "0" ]
105         then
106                 echo "*** check"
107                  _check_xfs_filesystem $LOOP_DEV none none
108         fi
109
110         rm -f $LOOP_DEV
111 }
112
113 # Wes' problem sizes...
114 _grow_loop 168024b 1376452608 4096 1
115
116 # Some other blocksize cases...
117 _grow_loop 168024b 1376452608 2048 1
118 _grow_loop 168024b 1376452608 512 1 16m
119 _grow_loop 168024b 688230400 1024 1
120
121
122 # Other corner cases suggested by dgc
123 # also the following doesn't check if the filesystem is consistent.
124 #  - grow 1TB by 1.5TB (control)
125 _grow_loop 1t 2500g 4096 0
126
127 #  - grow 1TB by 2.5TB (grow by > 2TB)
128 _grow_loop 1t 3500g 4096 0
129
130 #  - grow 1TB by 3.5TB (grow past 4TB)
131 _grow_loop 1t 4500g 4096 0
132
133 #  - grow 1TB by 4.5TB (grow by > 4TB)
134 _grow_loop 1t 5500g 4096 0
135
136 #  - grow 1TB by 7.5TB (grow past 8TB)
137 _grow_loop 1t 8500g 4096 0
138
139 #  - grow 1TB by 8.5TB (grow by > 8TB)
140 _grow_loop 1t 9500g 4096 0
141
142 #  - grow 1TB by 14.5TB (grow by > 8TB)
143 _grow_loop 1t 15500g 4096 0
144
145 #  - grow 1TB by 15TB (grow to 16TB)
146 _grow_loop 1t 16000g 4096 0
147
148 # It would be nice to go on, but this would require a totally new test in order
149 # to take care of 64-bit machines.
150
151 echo "*** all done"
152 status=0
153 exit