xfs: fix old fuzz test invocations of xfs_repair
[xfstests-dev.git] / tests / xfs / 078
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2003,2006 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 078
6 #
7 # Check several growfs corner cases
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1
16
17 trap "_cleanup; rm -f $tmp.*; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         rm -f $tmp.*
23         $UMOUNT_PROG $LOOP_MNT 2>/dev/null
24         [ -n "$LOOP_DEV" ] && _destroy_loop_device $LOOP_DEV 2>/dev/null
25         # try to keep the image file if test fails
26         [ $status -eq 0 ] && rm -f $LOOP_IMG
27         rmdir $LOOP_MNT
28 }
29
30 # get standard environment, filters and checks
31 . ./common/rc
32 . ./common/filter
33
34 # loop devices are available in Linux only
35 _supported_fs xfs
36
37 _require_test
38 # Must have loop device
39 _require_loop
40 _require_xfs_io_command "truncate"
41
42 LOOP_IMG=$TEST_DIR/$seq.fs
43 LOOP_MNT=$TEST_DIR/$seq.mnt
44
45 _filter_io()
46 {
47         sed -e '/.* ops; /d'
48 }
49
50 # real QA test starts here
51
52 rm -f $seqres.full
53
54 echo "*** create loop mount point"
55 rmdir $LOOP_MNT 2>/dev/null
56 mkdir -p $LOOP_MNT || _fail "cannot create loopback mount point"
57
58 _grow_loop()
59 {
60         original=$1
61         new_size=$2
62         bsize=$3
63         check=$4
64         agsize=$5
65
66         $XFS_IO_PROG -f -c "truncate $original" $LOOP_IMG
67         LOOP_DEV=`_create_loop_device $LOOP_IMG`
68
69         dparam=""
70         if [ -n "$agsize" ]; then
71                 dparam="-d agsize=$agsize"
72         fi
73
74         echo
75         echo "=== GROWFS (from $original to $new_size, $bsize blocksize)"
76         echo
77
78         echo "*** mkfs loop file (size=$original)"
79         mkfs_crc_opts=""
80         if [ $bsize -lt 1024 -a -z "$XFS_MKFS_HAS_NO_META_SUPPORT" ]; then
81                 mkfs_crc_opts="-m crc=0"
82         fi
83         $MKFS_XFS_PROG $mkfs_crc_opts -b size=$bsize $dparam $LOOP_DEV \
84                 | _filter_mkfs 2>/dev/null
85
86         echo "*** extend loop file"
87         _destroy_loop_device $LOOP_DEV
88         $XFS_IO_PROG -c "pwrite $new_size $bsize" $LOOP_IMG | _filter_io
89         LOOP_DEV=`_create_loop_device $LOOP_IMG`
90         echo "*** mount loop filesystem"
91         $MOUNT_PROG -t xfs $LOOP_DEV $LOOP_MNT
92
93         echo "*** grow loop filesystem"
94         $XFS_GROWFS_PROG $LOOP_MNT 2>&1 |  _filter_growfs 2>&1
95
96         echo "*** unmount"
97         $UMOUNT_PROG -d $LOOP_MNT && LOOP_DEV=
98
99         # Large grows takes forever to check..
100         if [ "$check" -gt "0" ]
101         then
102                 echo "*** check"
103                 _check_xfs_filesystem $LOOP_IMG none none
104         fi
105
106         rm -f $LOOP_IMG
107 }
108
109 # Wes' problem sizes...
110 _grow_loop $((168024*4096)) 1376452608 4096 1
111
112 # Some other blocksize cases...
113 _grow_loop $((168024*2048)) 1376452608 2048 1
114 _grow_loop $((168024*512)) 1376452608 512 1 16m
115 _grow_loop $((168024*1024)) 688230400 1024 1
116
117 # Other corner cases suggested by dgc
118 # also the following doesn't check if the filesystem is consistent.
119 #  - grow 1TB by 1.5TB (control)
120 _grow_loop 1t 2500g 4096 0
121
122 #  - grow 1TB by 2.5TB (grow by > 2TB)
123 _grow_loop 1t 3500g 4096 0
124
125 #  - grow 1TB by 3.5TB (grow past 4TB)
126 _grow_loop 1t 4500g 4096 0
127
128 #  - grow 1TB by 4.5TB (grow by > 4TB)
129 _grow_loop 1t 5500g 4096 0
130
131 #  - grow 1TB by 7.5TB (grow past 8TB)
132 _grow_loop 1t 8500g 4096 0
133
134 #  - grow 1TB by 8.5TB (grow by > 8TB)
135 _grow_loop 1t 9500g 4096 0
136
137 #  - grow 1TB by 14.5TB (grow by > 8TB)
138 _grow_loop 1t 15500g 4096 0
139
140 #  - grow 1TB by 15TB (grow to 16TB)
141 _grow_loop 1t 16000g 4096 0
142
143 # It would be nice to go on, but this would require a totally new test in order
144 # to take care of 64-bit machines.
145
146 echo "*** all done"
147 status=0
148 exit