Home | History | Annotate | Line # | Download | only in resize_ffs
t_shrink.sh revision 1.1
      1  1.1  riz # $NetBSD: t_shrink.sh,v 1.1 2010/12/09 05:19:02 riz Exp $
      2  1.1  riz #
      3  1.1  riz # Copyright (c) 2010 The NetBSD Foundation, Inc.
      4  1.1  riz # All rights reserved.
      5  1.1  riz #
      6  1.1  riz # This code is derived from software contributed to The NetBSD Foundation
      7  1.1  riz # by Jeffrey C. Rizzo.
      8  1.1  riz #
      9  1.1  riz # Redistribution and use in source and binary forms, with or without
     10  1.1  riz # modification, are permitted provided that the following conditions
     11  1.1  riz # are met:
     12  1.1  riz # 1. Redistributions of source code must retain the above copyright
     13  1.1  riz #    notice, this list of conditions and the following disclaimer.
     14  1.1  riz # 2. Redistributions in binary form must reproduce the above copyright
     15  1.1  riz #    notice, this list of conditions and the following disclaimer in the
     16  1.1  riz #    documentation and/or other materials provided with the distribution.
     17  1.1  riz #
     18  1.1  riz # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     19  1.1  riz # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     20  1.1  riz # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     21  1.1  riz # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     22  1.1  riz # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     23  1.1  riz # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     24  1.1  riz # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     25  1.1  riz # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     26  1.1  riz # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     27  1.1  riz # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     28  1.1  riz # POSSIBILITY OF SUCH DAMAGE.
     29  1.1  riz #
     30  1.1  riz 
     31  1.1  riz shrink_ffs()
     32  1.1  riz {
     33  1.1  riz 	echo "in shrink_ffs:" ${@}
     34  1.1  riz 	local bs=$1
     35  1.1  riz 	local fragsz=$2
     36  1.1  riz 	local osize=$3
     37  1.1  riz 	local nsize=$4
     38  1.1  riz 	local fslevel=$5
     39  1.1  riz 	local numdata=$6
     40  1.1  riz 	local swap=$7
     41  1.1  riz 	mkdir -p ${MNTPT}
     42  1.1  riz 	echo "bs is ${bs} numdata is ${numdata}"
     43  1.1  riz 	echo "****shrinking fs with blocksize ${bs}"
     44  1.1  riz 
     45  1.1  riz 	# we want no more than 16K/inode to allow test files to copy.
     46  1.1  riz 	local fpi=$((fragsz * 4))
     47  1.1  riz 	local i
     48  1.1  riz 	if [ $fpi -gt 16384 ]; then
     49  1.1  riz 		i="-i 16384"
     50  1.1  riz 	fi
     51  1.1  riz 	if [ x$swap != x ]; then
     52  1.1  riz 		newfs -B ${BYTESWAP} -O${fslevel} -b ${bs} -f ${fragsz} \
     53  1.1  riz 			-s ${osize} ${i} -F ${IMG}
     54  1.1  riz 	else
     55  1.1  riz 		newfs -O${fslevel} -b ${bs} -f ${fragsz} -s ${osize} ${i} \
     56  1.1  riz 			-F ${IMG}
     57  1.1  riz 	fi
     58  1.1  riz 
     59  1.1  riz 	# we're specifying relative paths, so rump_ffs warns - ignore.
     60  1.1  riz 	atf_check -s exit:0 -e ignore rump_ffs ${IMG} ${MNTPT}
     61  1.1  riz 	copy_multiple ${numdata}
     62  1.1  riz 
     63  1.1  riz 	# how much data to remove so fs can be shrunk
     64  1.1  riz 	local remove=$((numdata-numdata*nsize/osize))
     65  1.1  riz 	local dataleft=$((numdata-remove))
     66  1.1  riz 	echo remove is $remove dataleft is $dataleft
     67  1.1  riz 	remove_multiple ${remove}
     68  1.1  riz 	umount ${MNTPT}
     69  1.1  riz 	atf_check -s exit:0 resize_ffs -y -s ${nsize} ${IMG}
     70  1.1  riz 	atf_check -s exit:0 -o ignore fsck_ffs -f -n -F ${IMG}
     71  1.1  riz 	atf_check -s exit:0 -e ignore rump_ffs ${IMG} ${MNTPT}
     72  1.1  riz 	# checking everything because we don't delete on grow
     73  1.1  riz 	check_data_range $((remove + 1)) ${numdata}
     74  1.1  riz 	umount ${MNTPT}
     75  1.1  riz 	rm -f ${IMG}	# probably unnecessary
     76  1.1  riz }
     77  1.1  riz 
     78  1.1  riz # shrink_ffs params as follows:
     79  1.1  riz # shrink_ffs blocksize fragsize fssize newfssize level numdata swap
     80  1.1  riz # where 'numdata' is the number of data directories to copy - this is
     81  1.1  riz # determined manually based on the maximum number that will fit in the
     82  1.1  riz # created fs.  'level' is the fs-level (-O 0,1,2) passed to newfs.
     83  1.1  riz # If 'swap' is included, byteswap the fs
     84  1.1  riz test_case shrink_24M_16M_v1_4096 shrink_ffs 4096 512 49152 32768 1 41
     85  1.1  riz test_case shrink_24M_16M_v1_8192 shrink_ffs 8192 1024 49152 32768 1 42
     86  1.1  riz test_case shrink_24M_16M_v1_16384 shrink_ffs 16384 2048 49152 32768 1 43
     87  1.1  riz test_case shrink_24M_16M_v1_32768 shrink_ffs 32768 4096 49152 32768 1 42
     88  1.1  riz test_case shrink_24M_16M_v1_65536 shrink_ffs 65536 8192 49152 32768 1 38
     89  1.1  riz test_case shrink_32M_24M_v1_4096 shrink_ffs 4096 512 65536 49152 1 55
     90  1.1  riz test_case shrink_32M_24M_v1_8192 shrink_ffs 8192 1024 65536 49152 1 56
     91  1.1  riz test_case shrink_32M_24M_v1_16384 shrink_ffs 16384 2048 65536 49152 1 58
     92  1.1  riz test_case shrink_32M_24M_v1_32768 shrink_ffs 32768 4096 65536 49152 1 56
     93  1.1  riz test_case_xfail shrink_32M_24M_v1_65536 "PR bin/44204" shrink_ffs 65536 8192 65536 49152 1 51
     94  1.1  riz # 48M -> 16M is a bigger shrink, relatively
     95  1.1  riz test_case shrink_48M_16M_v1_4096 shrink_ffs 4096 512 98304 32768 1 82
     96  1.1  riz test_case shrink_48M_16M_v1_8192 shrink_ffs 8192 1024 98304 32768 1 84
     97  1.1  riz test_case shrink_48M_16M_v1_16384 shrink_ffs 16384 2048 98304 32768 1 87
     98  1.1  riz test_case_xfail shrink_48M_16M_v1_32768 "PR bin/44209" shrink_ffs 32768 4096 98304 32768 1 83
     99  1.1  riz test_case shrink_48M_16M_v1_65536 shrink_ffs 65536 8192 98304 32768 1 76
    100  1.1  riz test_case shrink_64M_48M_v1_4096 shrink_ffs 4096 512 131072 98304 1 109
    101  1.1  riz test_case shrink_64M_48M_v1_8192 shrink_ffs 8192 1024 131072 98304 1 111
    102  1.1  riz test_case shrink_64M_48M_v1_16384 shrink_ffs 16384 2048 131072 98304 1 115
    103  1.1  riz test_case_xfail shrink_64M_48M_v1_32768 "PR bin/44209" shrink_ffs 32768 4096 131072 98304 1 111
    104  1.1  riz test_case shrink_64M_48M_v1_65536 shrink_ffs 65536 8192 131072 98304 1 101
    105  1.1  riz test_case_xfail shrink_64M_48M_v1_65536_swapped "PR bin/44203" shrink_ffs 65536 8192 131072 98304 1 101 swap
    106  1.1  riz test_case_xfail shrink_64M_48M_v2_65536 "PR bin/44205" shrink_ffs 65536 8192 131072 98304 2 101
    107  1.1  riz test_case_xfail shrink_64M_48M_v2_65536_swapped "PR bin/44203; PR bin/44205" shrink_ffs 65536 8192 131072 98304 2 101 swap
    108  1.1  riz 
    109  1.1  riz atf_test_case shrink_ffsv1_partial_cg
    110  1.1  riz shrink_ffsv1_partial_cg_head()
    111  1.1  riz {
    112  1.1  riz 	atf_set "descr" "Checks successful shrinkage of ffsv1 by" \
    113  1.1  riz 			"less than a cylinder group"
    114  1.1  riz }
    115  1.1  riz shrink_ffsv1_partial_cg_body()
    116  1.1  riz {
    117  1.1  riz 	echo "*** resize_ffs shrinkage partial cg test"
    118  1.1  riz 
    119  1.1  riz 	atf_check -o ignore -e ignore newfs -V1 -F -s 5760 ${IMG}
    120  1.1  riz 
    121  1.1  riz 	# shrink so there's a partial cg at the end
    122  1.1  riz 	atf_check -s exit:0 resize_ffs -s 4000 -y ${IMG}
    123  1.1  riz 	atf_check -s exit:0 -o ignore fsck_ffs -f -n -F ${IMG}
    124  1.1  riz }
    125  1.1  riz 
    126  1.1  riz atf_init_test_cases()
    127  1.1  riz {
    128  1.1  riz 	setupvars
    129  1.1  riz 	atf_add_test_case shrink_24M_16M_v1_4096
    130  1.1  riz 	atf_add_test_case shrink_24M_16M_v1_8192
    131  1.1  riz 	atf_add_test_case shrink_24M_16M_v1_16384
    132  1.1  riz 	atf_add_test_case shrink_24M_16M_v1_32768
    133  1.1  riz 	atf_add_test_case shrink_24M_16M_v1_65536
    134  1.1  riz 	atf_add_test_case shrink_32M_24M_v1_4096
    135  1.1  riz 	atf_add_test_case shrink_32M_24M_v1_8192
    136  1.1  riz 	atf_add_test_case shrink_32M_24M_v1_16384
    137  1.1  riz 	atf_add_test_case shrink_32M_24M_v1_32768
    138  1.1  riz 	atf_add_test_case shrink_32M_24M_v1_65536
    139  1.1  riz 	atf_add_test_case shrink_48M_16M_v1_4096
    140  1.1  riz 	atf_add_test_case shrink_48M_16M_v1_8192
    141  1.1  riz 	atf_add_test_case shrink_48M_16M_v1_16384
    142  1.1  riz 	atf_add_test_case shrink_48M_16M_v1_32768
    143  1.1  riz 	atf_add_test_case shrink_48M_16M_v1_65536
    144  1.1  riz 	atf_add_test_case shrink_64M_48M_v1_4096
    145  1.1  riz 	atf_add_test_case shrink_64M_48M_v1_8192
    146  1.1  riz 	atf_add_test_case shrink_64M_48M_v1_16384
    147  1.1  riz 	atf_add_test_case shrink_64M_48M_v1_32768
    148  1.1  riz 	atf_add_test_case shrink_64M_48M_v1_65536
    149  1.1  riz 	atf_add_test_case shrink_64M_48M_v1_65536_swapped
    150  1.1  riz 	atf_add_test_case shrink_64M_48M_v2_65536
    151  1.1  riz 	atf_add_test_case shrink_64M_48M_v2_65536_swapped
    152  1.1  riz 	atf_add_test_case shrink_ffsv1_partial_cg
    153  1.1  riz }
    154