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## Author: Li Zefan <lizf@cn.fujitsu.com> ## 22## Miao Xie <miaox@cn.fujitsu.com> ## 23## ## 24################################################################################ 25 26 27export TCID="ext4-journal-checksum" 28export TST_TOTAL=36 29 30. ext4_funcs.sh 31 32# Use ffsb to test journal checksumming 33# $1: journal mode: writeback, ordered, journal 34# $2: commit interval: 1 sec, 100 sec 35# $3: journal_checksum or not 36# $4: journal_async_commit or not 37# $5: barrier: 0, 1 38ext4_test_journal_checksum() 39{ 40 local checksum= 41 local async_commit= 42 43 if [ -z "$3" ]; then 44 checksum="No use" 45 else 46 checksum="Used" 47 fi 48 if [ -z "$4" ]; then 49 async_commit="No use" 50 else 51 async_commit="Used" 52 fi 53 54 tst_resm TINFO "journal mode: $1, commit interval: $2, " \ 55 "journal_checksum: $checksum, " \ 56 "journal_async_commit: $async_commit, barrier: $5" 57 58 mkfs.ext4 -I 256 $EXT4_DEV >/dev/null 2>&1 59 if [ $? -ne 0 ]; then 60 tst_resm TFAIL "failed to create ext4 filesystem" 61 return 62 fi 63 64 tune2fs -O extents $EXT4_DEV >/dev/null 2>&1 65 66 mount -t ext4 -o data=$1,commit=$2,$3,$4,barrier=$5 $EXT4_DEV mnt_point 67 if [ $? -ne 0 ]; then 68 tst_resm TFAIL "failed to mount ext4 filesystem" 69 return 70 fi 71 72 ffsb ffsb-config2 > /dev/null 73 if [ $? -ne 0 ]; then 74 tst_resm TFAIL "ffsb returned failure" 75 umount mnt_point 76 return 77 fi 78 79 umount mnt_point 80 if [ $? -ne 0 ]; then 81 tst_resm TFAIL "failed to umount ext4 filesystem" 82 return 83 fi 84 85 e2fsck -p $EXT4_DEV >/dev/null 2>&1 86 if [ $? -ne 0 ]; then 87 tst_resm TFAIL "fsck returned failure" 88 return 89 fi 90 91 tst_resm TPASS "ext4 journal checksum test pass" 92} 93 94# main 95ext4_setup 96 97tst_test_cmds ffsb 98 99DATA=( "writeback" "ordered" "journal" ) 100COMMIT=( 1 100 ) 101JOURNAL_CHECKSUM=( "journal_checksum" "" ) 102JOURNAL_ASYNC_COMMIT=( "journal_async_commit" "" ) 103BARRIER=( 0 1 ) 104 105for ((i = 0; i < 2; i++)) 106{ 107 for ((j = 0; j < 2; j++)) 108 { 109 for ((k = 0; k < 2; k++)) 110 { 111 for ((l = 0; l < 2; l++)) 112 { 113 for ((m = 0; m < 3; m++)) 114 { 115 116 # when journal_async_commit is used, 117 # journal_checksum is set automatically 118 if [ $j -eq 0 -a $k -eq 1 ]; then 119 continue 120 fi 121 122 ext4_test_journal_checksum ${DATA[$m]} \ 123 ${COMMIT[$l]} \ 124 "${JOURNAL_CHECKSUM[$k]}" \ 125 "${JOURNAL_ASYNC_COMMIT[$j]}" \ 126 ${BARRIER[$i]} 127 } 128 } 129 } 130 } 131} 132 133tst_exit 134