Add GPL license plate to SGI's test files.
[xfstests-dev.git] / 078
1 #! /bin/sh
2 #
3 #-----------------------------------------------------------------------
4 # Copyright (c) 2000-2003,2006 Silicon Graphics, Inc.  All Rights Reserved.
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as
8 # published by the Free Software Foundation.
9 #
10 # This program is distributed in the hope that it would be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write the Free Software Foundation,
17 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18 #
19 #-----------------------------------------------------------------------
20 #
21 # FS QA Test No. 078
22 #
23 # Check several growfs corner cases
24 #
25 # creator
26 owner=nathans@sgi.com
27
28 seq=`basename $0`
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1
34
35 trap "_cleanup; rm -f $tmp.*; exit \$status" 0 1 2 3 15
36
37 _cleanup()
38 {
39     cd /
40     rm -f $tmp.*
41     umount $LOOP_MNT 2>/dev/null
42     rmdir $LOOP_MNT
43     _cleanup_testdir
44 }
45
46 # get standard environment, filters and checks
47 . ./common.rc
48 . ./common.filter
49
50 # loop devices are available in Linux only
51 _supported_fs xfs
52 _supported_os Linux
53
54 # Must have loop device
55 _require_loop
56
57 LOOP_DEV=$TEST_DIR/$seq.fs
58 LOOP_MNT=$TEST_DIR/$seq.mnt
59
60 _filter_io()
61 {
62         sed -e '/.* ops; /d'
63 }
64
65 # real QA test starts here
66
67 echo "*** create loop mount point"
68 rmdir $LOOP_MNT 2>/dev/null
69 mkdir -p $LOOP_MNT || _fail "cannot create loopback mount point"
70
71 _grow_loop()
72 {
73         original=$1
74         new_size=$2
75         bsize=$3
76         check=$4
77         agsize=$5
78
79         dparam="file,name=$LOOP_DEV,size=$original"
80         if [ -n "$agsize" ]; then
81                 dparam="$dparam,agsize=$agsize"
82         fi
83
84         echo
85         echo "=== GROWFS (from $original to $new_size, $bsize blocksize)"
86         echo
87
88         echo "*** mkfs loop file (size=$original)"
89         $MKFS_XFS_PROG -b size=$bsize -d $dparam \
90                 | _filter_mkfs 2>/dev/null
91
92         echo "*** extend loop file"
93         $XFS_IO_PROG -c "pwrite $new_size $bsize" $LOOP_DEV | _filter_io
94         echo "*** mount loop filesystem"
95         mount -t xfs -o loop $LOOP_DEV $LOOP_MNT
96
97         echo "*** grow loop filesystem"
98         #xfs_growfs $LOOP_MNT 2>&1 | grep -e "^data" #| _filter_growfs 2>/dev/null
99         $XFS_GROWFS_PROG $LOOP_MNT 2>&1 |  _filter_growfs 2>&1
100
101         echo "*** unmount"
102         umount $LOOP_MNT
103
104         # Large grows takes forever to check..
105         if [ "$check" -gt "0" ]
106         then
107                 echo "*** check"
108                  _check_xfs_filesystem $LOOP_DEV none none
109         fi
110
111         rm -f $LOOP_DEV
112 }
113
114 # Wes' problem sizes...
115 _grow_loop 168024b 1376452608 4096 1
116
117 # Some other blocksize cases...
118 _grow_loop 168024b 1376452608 2048 1
119 _grow_loop 168024b 1376452608 512 1 16m
120 _grow_loop 168024b 688230400 1024 1
121
122
123 # Other corner cases suggested by dgc
124 # also the following doesn't check if the filesystem is consistent.
125 #  - grow 1TB by 1.5TB (control)
126 _grow_loop 1t 2500g 4096 0
127
128 #  - grow 1TB by 2.5TB (grow by > 2TB)
129 _grow_loop 1t 3500g 4096 0
130
131 #  - grow 1TB by 3.5TB (grow past 4TB)
132 _grow_loop 1t 4500g 4096 0
133
134 #  - grow 1TB by 4.5TB (grow by > 4TB)
135 _grow_loop 1t 5500g 4096 0
136
137 #  - grow 1TB by 7.5TB (grow past 8TB)
138 _grow_loop 1t 8500g 4096 0
139
140 #  - grow 1TB by 8.5TB (grow by > 8TB)
141 _grow_loop 1t 9500g 4096 0
142
143 #  - grow 1TB by 14.5TB (grow by > 8TB)
144 _grow_loop 1t 15500g 4096 0
145
146 #  - grow 1TB by 15TB (grow to 16TB)
147 _grow_loop 1t 16000g 4096 0
148
149 # It would be nice to go on, but this would require a totally new test in order
150 # to take care of 64-bit machines.
151
152 echo "*** all done"
153 status=0
154 exit