Home | History | Annotate | Download | only in ext4-delalloc-mballoc
      1 #!/bin/bash
      2 
      3 ################################################################################
      4 #                                                                              #
      5 # Copyright (c) 2009 FUJITSU LIMITED                                           #
      6 #                                                                              #
      7 # This program is free software;  you can redistribute it and#or modify        #
      8 # it under the terms of the GNU General Public License as published by         #
      9 # the Free Software Foundation; either version 2 of the License, or            #
     10 # (at your option) any later version.                                          #
     11 #                                                                              #
     12 # This program is distributed in the hope that it will be useful, but          #
     13 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY   #
     14 # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License     #
     15 # for more details.                                                            #
     16 #                                                                              #
     17 # You should have received a copy of the GNU General Public License            #
     18 # along with this program;  if not, write to the Free Software                 #
     19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA      #
     20 #                                                                              #
     21 ################################################################################
     22 
     23 export TCID="ext4-delalloc-mballoc"
     24 export TST_TOTAL=17
     25 
     26 . ext4_funcs.sh
     27 
     28 # Case 17: mount ext4 partition to ext3
     29 ext4_test_remount()
     30 {
     31 	mkfs.ext3 -I 256 -b 1024 $EXT4_DEV >/dev/null 2>&1
     32 	if [ $? -ne 0 ]; then
     33 		tst_resm TFAIL "failed to create ext4 filesystem"
     34 		return
     35 	fi
     36 
     37 	mount -t ext4 -o delalloc,auto_da_alloc $EXT4_DEV mnt_point
     38 	if [ $? -ne 0 ]; then
     39 		tst_resm TFAIL "failed to mount ext4 filesystem"
     40 		return
     41 	fi
     42 
     43 	ffsb $LTPROOT/testcases/data/ext4-ffsb/ffsb-config0 > /dev/null
     44 	if [ $? -ne 0 ]; then
     45 		tst_resm TFAIL "ffsb returned failure"
     46 		umount mnt_point
     47 		return
     48 	fi
     49 
     50 	umount mnt_point
     51 	if [ $? -ne 0 ]; then
     52 		tst_resm TFAIL "failed to umount ext4 filesystem"
     53 		return
     54 	fi
     55 
     56 	mount -t ext3 $EXT4_DEV mnt_point
     57 	if [ $? -ne 0 ]; then
     58 		tst_resm TFAIL "failed to mount to ext3"
     59 		return
     60 	fi
     61 	umount mnt_point
     62 
     63 	fsck -p $EXT4_DEV >/dev/null 2>&1
     64 	if [ $? -ne 0 ]; then
     65 		tst_resm TFAIL "fsck returned failure"
     66 		return
     67 	fi
     68 
     69 	tst_resm TPASS "remount test pass"
     70 }
     71 
     72 # Case 1-16: Use ffsb to test mballoc and delalloc
     73 # $1: delalloc or nodelalloc
     74 # $2: 0 - indirect-io, 1 - direct-io
     75 # $3: block size
     76 # $4: auto_da_alloc
     77 ext4_test_delalloc_mballoc()
     78 {
     79 	tst_resm TINFO "isDelalloc: $1, isDirectIO: $2, Blocksize: $3, isAuto_da_alloc: $4"
     80 
     81 	mkfs.ext4 -I 256 -b $3 /$EXT4_DEV >/dev/null 2>&1
     82 	if [ $? -ne 0 ]; then
     83 		tst_resm TFAIL "failed to create ext4 filesystem"
     84 		return
     85 	fi
     86 
     87 	tune2fs -O extents $EXT4_DEV >/dev/null 2>&1
     88 
     89 	mount -t ext4 -o $1,$4 $EXT4_DEV mnt_point
     90 	if [ $? -ne 0 ]; then
     91 		tst_resm TFAIL "failed to mount ext4 filesystem"
     92 		return
     93 	fi
     94 
     95 	ffsb $LTPROOT/testcases/data/ext4-ffsb/ffsb-config$2 > /dev/null
     96 	if [ $? -ne 0 ]; then
     97 		tst_resm TFAIL "ffsb returned failure"
     98 		umount mnt_point
     99 		return
    100 	fi
    101 
    102 	umount mnt_point
    103 	if [ $? -ne 0 ]; then
    104 		tst_resm TFAIL "failed to umount ext4 filesystem"
    105 		return
    106 	fi
    107 
    108 	fsck -p $EXT4_DEV >/dev/null 2>&1
    109 	if [ $? -ne 0 ]; then
    110 		tst_resm TFAIL "fsck returned failure"
    111 		return
    112 	fi
    113 
    114 	tst_resm TPASS "delalloc/mballoc test pass"
    115 }
    116 
    117 # main
    118 ext4_setup
    119 
    120 tst_check_cmds ffsb
    121 
    122 DELALLOC=( "delalloc" "nodelalloc" )
    123 DIRECT_IO=( 0 1 )
    124 BLOCK_SIZE=( 1024 4096 )
    125 BLOCK_AUTO_DA_ALLOC=( "auto_da_alloc=1" "noauto_da_alloc" )
    126 
    127 for ((i = 0; i < 2; i++))
    128 {
    129 	for ((j = 0; j < 2; j++))
    130 	{
    131 		for ((k = 0; k < 2; k++))
    132 		{
    133 			for ((l = 0; l < 2; l++))
    134 			{
    135 				ext4_test_delalloc_mballoc ${DELALLOC[$k]} \
    136 						${DIRECT_IO[$j]} \
    137 						${BLOCK_SIZE[$i]} \
    138 						${BLOCK_AUTO_DA_ALLOC[$l]}
    139 			}
    140 		}
    141 	}
    142 }
    143 
    144 ext4_test_remount
    145 
    146 tst_exit
    147