1#!/bin/bash 2 3IMG=../test.img 4TMP=/tmp/res 5XFSTESTS=~/xfstests 6TESTS="4 5 8 11 16 25 32 55 64" 7 8TARGET=./testdir 9MNT=/mnt/resize 10 11mkdir $TARGET 2>/dev/null 12mkdir $MNT 2>/dev/null 13 14umount $TARGET 15umount $MNT 16 17_check_out() 18{ 19 if [ $1 -ne 0 ]; then 20 grep ASSERT $TMP 21 echo FAIL RETURN $1 22 exit 23 fi 24} 25 26_get_sec() 27{ 28 echo $(($1*1024*1024*1024/512)) 29} 30 31_mkfs() 32{ 33 echo "========== Initialize $1 GB ============" 34 mkfs.f2fs $IMG `_get_sec $1` | grep sectors 35} 36 37_mount() 38{ 39 echo "========== mount to $1 =================" 40 mount -t f2fs -o loop,discard,inline_data,inline_xattr $IMG $1 2>&1 41 _check_out $? 42} 43 44_fsck() 45{ 46 echo "========== fsck.f2fs ===================" 47 fsck.f2fs $IMG -t 2>&1 >$TMP 48 _check_out $? 49 grep FSCK $TMP 50} 51 52_fsstress() 53{ 54 echo "========== fsstress $1 =================" 55 $XFSTESTS/ltp/fsstress -x "echo 3 > /proc/sys/vm/drop_caches && sleep 1" -X 1 -r -f fsync=8 -f sync=0 -f write=8 -f dwrite=2 -f truncate=6 -f allocsp=0 -f bulkstat=0 -f bulkstat1=0 -f freesp=0 -f zero=1 -f collapse=1 -f insert=1 -f resvsp=0 -f unresvsp=0 -S t -p 10 -n $2 -d $1 >/dev/null 56} 57 58_resize() 59{ 60 echo "========== resize.f2fs $1 GB ===========" 61 resize.f2fs -t `_get_sec $1` $IMG 2>&1 >$TMP 62 _check_out $? 63 _fsck 64} 65 66_resize_tests() 67{ 68 for i in $TESTS 69 do 70 if [ $i -ge $1 ]; then 71 _resize $i 72 fi 73 done 74} 75 76_sload() 77{ 78 echo "========== sload $1 ====================" 79 sload.f2fs -f $1 $IMG 2>&1 80 _check_out $? 81} 82 83from_mount() 84{ 85 echo "" 86 echo " **** $1 GB to $2 GB with $3 *** " 87 _mkfs $1 88 _mount $3 89 _fsstress $3 10000 90 umount $3 91 _fsck 92 _resize_tests $2 93} 94 95from_sload() 96{ 97 echo "" 98 echo " **** $1 GB to $2 GB with $3 *** " 99 100 _mkfs $1 101 _sload $3 102 _fsck 103 104 _mount $MNT 105 _fsstress $MNT 10000 106 umount $MNT 107 _fsck 108 109 _resize_tests $2 110 111 _mount $MNT 112 _fsstress $MNT 10000 113 umount $MNT 114 _fsck 115} 116 117test_all() 118{ 119 for i in $TESTS 120 do 121 for j in $TESTS 122 do 123 if [ $i -lt $j ]; then 124 $1 $i $j $2 125 fi 126 done 127 done 128} 129 130test_all from_sload ~/grub 131 132rm -rf $TARGET/* 133_fsstress $TARGET 5000 134test_all from_sload $TARGET 135rm -rf $TARGET 2>/dev/null 136 137test_all from_mount $MNT 138