Home | History | Annotate | Download | only in d_fallocate_bigalloc
      1 if ! test -x $DEBUGFS_EXE; then
      2 	echo "$test_name: $test_description: skipped (no debugfs)"
      3 	return 0
      4 fi
      5 
      6 FSCK_OPT=-fy
      7 OUT=$test_name.log
      8 if [ -f $test_dir/expect.gz ]; then
      9 	EXP=$test_name.tmp
     10 	gunzip < $test_dir/expect.gz > $EXP
     11 else
     12 	EXP=$test_dir/expect
     13 fi
     14 
     15 cat > $TMPFILE.conf << ENDL
     16 [fs_types]
     17 ext4 = {
     18 	cluster_size = 8192
     19         base_features = sparse_super,filetype,resize_inode,dir_index,ext_attr,^has_journal,extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize,64bit
     20         blocksize = 1024
     21         inode_size = 256
     22         inode_ratio = 16384
     23 }
     24 ENDL
     25 MKE2FS_CONFIG=$TMPFILE.conf $MKE2FS -F -o Linux -b 1024 -O bigalloc -T ext4 $TMPFILE 65536 > $OUT.new 2>&1
     26 rm -f $TMPFILE.conf
     27 
     28 $FSCK -fy -N test_filesys $TMPFILE >> $OUT.new 2>&1
     29 status=$?
     30 echo Exit status is $status >> $OUT.new
     31 
     32 echo "debugfs write files" >> $OUT.new
     33 make_file() {
     34 	name="$1"
     35 	start="$2"
     36 	flag="$3"
     37 
     38 	cat << ENDL
     39 write /dev/null $name
     40 sif /$name size 40960
     41 eo /$name
     42 set_bmap $flag 10 $((start + 10))
     43 set_bmap $flag 13 $((start + 13))
     44 set_bmap $flag 26 $((start + 26))
     45 set_bmap $flag 29 $((start + 29))
     46 ec
     47 sif /$name blocks 32
     48 setb $((start + 10))
     49 setb $((start + 13))
     50 setb $((start + 26))
     51 setb $((start + 29))
     52 ENDL
     53 }
     54 
     55 #Files we create:
     56 # a: fallocate a 40k file
     57 # b*: falloc sparse file starting at b*
     58 # c*: falloc spare file ending at c*
     59 # d: midcluster to midcluster, surrounding sparse
     60 # e: partial middle cluster alloc
     61 # f: one big file
     62 # g*: falloc sparse init file starting at g*
     63 # h*: falloc sparse init file ending at h*
     64 # i: midcluster to midcluster, surrounding sparse init
     65 # j: partial middle cluster alloc
     66 # k: one big init file
     67 base=5000
     68 cat > $TMPFILE.cmd << ENDL
     69 write /dev/null a
     70 sif /a size 40960
     71 fallocate /a 0 39
     72 ENDL
     73 echo "ex /a" >> $TMPFILE.cmd2
     74 
     75 make_file sample $base --uninit >> $TMPFILE.cmd
     76 echo "ex /sample" >> $TMPFILE.cmd2
     77 base=10000
     78 
     79 for i in 8 9 10 11 12 13 14 15; do
     80 	make_file b$i $(($base + (40 * ($i - 8)))) --uninit >> $TMPFILE.cmd
     81 	echo "fallocate /b$i $i 39" >> $TMPFILE.cmd
     82 	echo "ex /b$i" >> $TMPFILE.cmd2
     83 done
     84 
     85 for i in 24 25 26 27 28 29 30 31; do
     86 	make_file c$i $(($base + 320 + (40 * ($i - 24)))) --uninit >> $TMPFILE.cmd
     87 	echo "fallocate /c$i 0 $i" >> $TMPFILE.cmd
     88 	echo "ex /c$i" >> $TMPFILE.cmd2
     89 done
     90 
     91 make_file d $(($base + 640)) --uninit >> $TMPFILE.cmd
     92 echo "fallocate /d 4 35" >> $TMPFILE.cmd
     93 echo "ex /d" >> $TMPFILE.cmd2
     94 
     95 make_file e $(($base + 680)) --uninit >> $TMPFILE.cmd
     96 echo "fallocate /e 19 20" >> $TMPFILE.cmd
     97 echo "ex /e" >> $TMPFILE.cmd2
     98 
     99 cat >> $TMPFILE.cmd << ENDL
    100 write /dev/null f
    101 sif /f size 1024
    102 eo /f
    103 set_bmap --uninit 0 9000
    104 ec
    105 sif /f blocks 16
    106 setb 9000
    107 fallocate /f 0 8999
    108 ENDL
    109 echo "ex /f" >> $TMPFILE.cmd2
    110 
    111 # Now do it again, but with initialized blocks
    112 base=20000
    113 for i in 8 9 10 11 12 13 14 15; do
    114 	make_file g$i $(($base + (40 * ($i - 8)))) >> $TMPFILE.cmd
    115 	echo "fallocate /g$i $i 39" >> $TMPFILE.cmd
    116 	echo "ex /g$i" >> $TMPFILE.cmd2
    117 done
    118 
    119 for i in 24 25 26 27 28 29 30 31; do
    120 	make_file h$i $(($base + 320 + (40 * ($i - 24)))) >> $TMPFILE.cmd
    121 	echo "fallocate /h$i 0 $i" >> $TMPFILE.cmd
    122 	echo "ex /h$i" >> $TMPFILE.cmd2
    123 done
    124 
    125 make_file i $(($base + 640)) >> $TMPFILE.cmd
    126 echo "fallocate /i 4 35" >> $TMPFILE.cmd
    127 echo "ex /i" >> $TMPFILE.cmd2
    128 
    129 make_file j $(($base + 680)) >> $TMPFILE.cmd
    130 echo "fallocate /j 19 20" >> $TMPFILE.cmd
    131 echo "ex /j" >> $TMPFILE.cmd2
    132 
    133 cat >> $TMPFILE.cmd << ENDL
    134 write /dev/null k
    135 sif /k size 1024
    136 eo /k
    137 set_bmap 0 19000
    138 ec
    139 sif /k blocks 16
    140 setb 19000
    141 fallocate /k 0 8999
    142 sif /k size 9216000
    143 ENDL
    144 echo "ex /k" >> $TMPFILE.cmd2
    145 
    146 $DEBUGFS -w -f $TMPFILE.cmd $TMPFILE > /dev/null 2>&1
    147 $DEBUGFS -f $TMPFILE.cmd2 $TMPFILE >> $OUT.new 2>&1
    148 
    149 $FSCK -fy -N test_filesys $TMPFILE >> $OUT.new 2>&1
    150 status=$?
    151 echo Exit status is $status >> $OUT.new
    152 
    153 sed -f $cmd_dir/filter.sed $OUT.new > $OUT
    154 rm -f $TMPFILE $TMPFILE.cmd $TMPFILE.cmd2 $OUT.new
    155 
    156 cmp -s $OUT $EXP
    157 status=$?
    158 
    159 if [ "$status" = 0 ] ; then
    160 	echo "$test_name: $test_description: ok"
    161 	touch $test_name.ok
    162 else
    163 	echo "$test_name: $test_description: failed"
    164 	diff $DIFF_OPTS $EXP $OUT > $test_name.failed
    165 fi
    166 rm -f $EXP
    167 
    168 unset IMAGE FSCK_OPT OUT EXP
    169