[Ocfs2-test-devel] [PATCH 05/11] ocfs2-test: Added Run_corruption function.

Marcos Matsunaga Marcos.Matsunaga at oracle.com
Thu Jun 3 06:55:29 PDT 2010


- Added execution to the config.sh script.

Signed-off-by: Marcos Matsunaga <Marcos.Matsunaga at oracle.com>
---
 programs/fill_verify_holes/Makefile   |    2 +
 programs/fill_verify_holes/burn-in.sh |   59 ++++++++++++++++++++++++++++++++-
 2 files changed, 60 insertions(+), 1 deletions(-)

diff --git a/programs/fill_verify_holes/Makefile b/programs/fill_verify_holes/Makefile
index d0d53ae..9771542 100644
--- a/programs/fill_verify_holes/Makefile
+++ b/programs/fill_verify_holes/Makefile
@@ -8,6 +8,8 @@ CFLAGS = -O2 -Wall -g $(OCFS2_CFLAGS)
 
 SOURCES = fill_holes.c punch_holes.c verify_holes.c fill_holes.h reservations.h
 
+SUBDIR = fill_holes_data
+
 DIST_FILES = $(SOURCES)
 
 BIN_EXTRA = burn-in.sh old_burn-in.sh fill_verify_holes.sh
diff --git a/programs/fill_verify_holes/burn-in.sh b/programs/fill_verify_holes/burn-in.sh
index 1ee2b02..0ae25e7 100755
--- a/programs/fill_verify_holes/burn-in.sh
+++ b/programs/fill_verify_holes/burn-in.sh
@@ -9,15 +9,28 @@ SUDO="`which sudo` -u root"
 DEBUGFS_BIN="`which sudo` -u root `which debugfs.ocfs2`"
 MKFS_BIN="`which sudo` -u root `which mkfs.ocfs2`"
 TUNEFS_BIN="`which sudo` -u root `which tunefs.ocfs2`"
+MOUNTED_BIN="`which sudo` -u root `which mounted.ocfs2`"
 GREP=`which grep`
+CHOWN=`which chown`
 DF=`which df`
+WC=`which wc`
 ECHO="`which echo` -e"
 AWK=`which awk`
 
+USERID=`/usr/bin/whoami`
 BINPATH="."
 LOGPATH="."
 MMAPOPT=
-UNWOPT=
+if [ `dirname ${0}` == '.' ]; then
+	if [ -f config.sh ]; then
+		. ./config.sh;
+	fi;
+else
+	if [ -f `dirname ${0}`/config.sh ]; then
+		. `dirname ${0}`/config.sh
+	fi;
+fi;
+NWOPT=
 
 log_run() {
     echo "Run: $@"
@@ -66,6 +79,48 @@ run100() {
     done
 }
 
+Run_corruption() {
+	CORRUPTLOG=${O2TDIR}/workfiles/fill_holes_data/nosparsebug.dat
+	FILESIZE=$[11*1024*1024*1024];
+	FILENAME=${DIRECTORY}/fill_holes.txt;
+	FS_FEATURES='--fs-features=nosparse,nounwritten'
+	LOCAL_FEATURE=''
+	if [ ${LOCALFLAG} -eq 1 ]; then
+		LOCAL_FEATURE='-M local';
+	fi;
+	echo -e "Testing corruption";
+	mounted=`mount|grep ${MOUNTPOINT}|${WC} -l`;
+	if [ ${mounted} -eq 1 ]; then
+		echo -e "umounting partition";
+		sudo umount ${MOUNTPOINT};
+	fi;
+	mounted=`mount|grep ${MOUNTPOINT}|${WC} -l`;
+	if [ ${mounted} -ne 0 ]; then
+		echo -e "Device ${DEVICE} is mounted by some other node.";
+		echo -e "Can't proceed with this test. Aborting.";
+		exit 1;
+	fi;
+	echo "Formatting partition with nosparse,nounwritten options.";
+	echo "y"|${MKFS_BIN} -b ${BLOCKSIZE} -C ${CLUSTERSIZE} -L ${LABEL} \
+	-N ${SLOTS} ${LOCAL_FEATURE} ${FS_FEATURES} ${DEVICE};
+	if [ $? -ne 0 ]; then
+		echo -e "mkfs.ocfs2 failed $?";
+	fi;
+	echo "mounting device with label ${LABEL} on ${MOUNTPOINT}";
+	sudo mount LABEL=${LABEL} ${MOUNTPOINT};
+	sudo mkdir -p ${DIRECTORY}
+	${SUDO} ${CHOWN} --recursive ${USERID} ${MOUNTPOINT}
+
+	mounted=`mount|grep ${MOUNTPOINT}|${WC} -l`;
+	if [ ${mounted} -eq 0 ]; then
+		echo -e "Device ${DEVICE} was not properly mounted.";
+		echo -e "Can't proceed with this test. Aborting.";
+		exit 1;
+	fi;
+	${BINDIR}/fill_holes  -r ${CORRUPTLOG} ${FILENAME} ${FILESIZE};
+	${BINDIR}/verify_holes ${CORRUPTLOG} ${FILENAME};
+}
+
 #
 # GetDevInfo
 #
@@ -88,6 +143,7 @@ LABEL=`${DEBUGFS_BIN} -R stats ${DEVICE} | grep Label:|\
 if [ "X${LABEL}" == "X" ]; then
 	LABEL="testlabel";
 fi;
+LOCALFLAG=`${DEBUGFS_BIN} -R stats ${DEVICE} | grep 'local' |${WC} -l`
 UUID=`${DEBUGFS_BIN} -R stats ${DEVICE} | grep UUID|\
 	${AWK} -F" " '{print $2}'`;
 SLOTS=`${DEBUGFS_BIN} -R stats ${DEVICE} | grep Slots:|\
@@ -122,3 +178,4 @@ fi
 
 GetDevInfo;
 run100 ${ITER} ${SIZE} 
+Run_corruption
-- 
1.5.6.5




More information about the Ocfs2-test-devel mailing list