2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2003,2006 Silicon Graphics, Inc. All Rights Reserved.
7 # Check several growfs corner cases
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
17 trap "_cleanup; rm -f $tmp.*; exit \$status" 0 1 2 3 15
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
30 # get standard environment, filters and checks
34 # loop devices are available in Linux only
38 # Must have loop device
40 _require_xfs_io_command "truncate"
42 LOOP_IMG=$TEST_DIR/$seq.fs
43 LOOP_MNT=$TEST_DIR/$seq.mnt
50 # real QA test starts here
54 echo "*** create loop mount point"
55 rmdir $LOOP_MNT 2>/dev/null
56 mkdir -p $LOOP_MNT || _fail "cannot create loopback mount point"
66 $XFS_IO_PROG -f -c "truncate $original" $LOOP_IMG
67 LOOP_DEV=`_create_loop_device $LOOP_IMG`
70 if [ -n "$agsize" ]; then
71 dparam="-d agsize=$agsize"
75 echo "=== GROWFS (from $original to $new_size, $bsize blocksize)"
78 echo "*** mkfs loop file (size=$original)"
80 if [ $bsize -lt 1024 -a -z "$XFS_MKFS_HAS_NO_META_SUPPORT" ]; then
81 mkfs_crc_opts="-m crc=0"
83 $MKFS_XFS_PROG $mkfs_crc_opts -b size=$bsize $dparam $LOOP_DEV \
84 | _filter_mkfs 2>/dev/null
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
93 echo "*** grow loop filesystem"
94 $XFS_GROWFS_PROG $LOOP_MNT 2>&1 | _filter_growfs 2>&1
97 $UMOUNT_PROG -d $LOOP_MNT && LOOP_DEV=
99 # Large grows takes forever to check..
100 if [ "$check" -gt "0" ]
103 _check_xfs_filesystem $LOOP_IMG none none
109 # Wes' problem sizes...
110 _grow_loop $((168024*4096)) 1376452608 4096 1
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
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
122 # - grow 1TB by 2.5TB (grow by > 2TB)
123 _grow_loop 1t 3500g 4096 0
125 # - grow 1TB by 3.5TB (grow past 4TB)
126 _grow_loop 1t 4500g 4096 0
128 # - grow 1TB by 4.5TB (grow by > 4TB)
129 _grow_loop 1t 5500g 4096 0
131 # - grow 1TB by 7.5TB (grow past 8TB)
132 _grow_loop 1t 8500g 4096 0
134 # - grow 1TB by 8.5TB (grow by > 8TB)
135 _grow_loop 1t 9500g 4096 0
137 # - grow 1TB by 14.5TB (grow by > 8TB)
138 _grow_loop 1t 15500g 4096 0
140 # - grow 1TB by 15TB (grow to 16TB)
141 _grow_loop 1t 16000g 4096 0
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.