All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/3 v2] xfstests: add btrfs online defragments QA test
@ 2012-02-09  5:40 ` Liu Bo
  0 siblings, 0 replies; 6+ messages in thread
From: Liu Bo @ 2012-02-09  5:40 UTC (permalink / raw)
  To: xfs; +Cc: linux-btrfs, hch

As the title shows, we port btrfs online defragments QA test into xfstests.

v1->v2:
- place the real tests inside testcases.

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
---
 278      |  247 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 278.args |   18 +++++
 278.out  |   75 +++++++++++++++++++
 group    |    1 +
 4 files changed, 341 insertions(+), 0 deletions(-)
 create mode 100755 278
 create mode 100644 278.args
 create mode 100644 278.out

diff --git a/278 b/278
new file mode 100755
index 0000000..71f12e0
--- /dev/null
+++ b/278
@@ -0,0 +1,247 @@
+#! /bin/bash
+# FS QA Test No. 278
+#
+# Btrfs Online defragmentation tests
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2012 Fujitsu Liu Bo.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+# creator
+owner=liubo2009@cn.fujitsu.com
+
+seq=`basename $0`
+echo "QA output created by $seq"
+test_path="`pwd`"
+progs_dir="$test_path/src/btrfs_online_defragment/"
+tmp=tmp/$$
+defrag_args="$test_path/${seq}.args"
+
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    rm -f $tmp.*
+}
+
+_create_file()
+{
+	CNT=11999
+	FILESIZE=48000
+	if [ "$DEFRAG_TARGET" = "1" ];then
+		for i in `seq $CNT -1 0`; do
+			dd if=/dev/zero of=$SCRATCH_MNT/tmp_file bs=4k count=1 \
+			 conv=notrunc seek=$i oflag=sync &>/dev/null
+		done
+		# get md5sum
+		md5sum $SCRATCH_MNT/tmp_file > /tmp/checksum
+	elif [ "$DEFRAG_TARGET" = "2" ];then
+		mkdir $SCRATCH_MNT/tmp_dir
+		for i in `seq $CNT -1 0`; do
+			dd if=/dev/zero of=$SCRATCH_MNT/tmp_dir/tmp_file bs=4k \
+			count=1 conv=notrunc seek=$i oflag=sync &>/dev/null
+		done
+		# get md5sum
+		md5sum $SCRATCH_MNT/tmp_dir/tmp_file > /tmp/checksum
+	elif [ "$DEFRAG_TARGET" = "3" ];then
+		for i in `seq $CNT -1 0`; do
+			dd if=/dev/zero of=$SCRATCH_MNT/tmp_file bs=4k count=1 \
+			conv=notrunc seek=$i oflag=sync &>/dev/null
+		done
+		# get md5sum
+		md5sum $SCRATCH_MNT/tmp_file > /tmp/checksum
+	fi
+}
+
+_btrfs_online_defrag()
+{
+	str=""
+	if [ "$FILE_RANGE" = "2" ];then
+		str="$str -s -1 -l $((FILESIZE / 2)) "
+	elif [ "$FILE_RANGE" = "3" ];then
+		str="$str -s $((FILESIZE + 1)) -l $((FILESIZE / 2)) "
+		HAVE_DEFRAG=1
+	elif [ "$FILE_RANGE" = "4" ];then
+		str="$str -l -1 "
+	elif [ "$FILE_RANGE" = "5" ];then
+		str="$str -l $((FILESIZE + 1)) "
+	elif [ "$FILE_RANGE" = "6" ];then
+		str="$str -l $((FILESIZE / 2)) "
+	fi
+
+	if [ "$DEFRAG_COMPRESS" = "2" ];then
+		str="$str -c "
+	fi
+
+	if [ "$FLUSH" = "2" ];then
+		str="$str -f "
+	fi
+
+	if [ "$THRESH" = "2" ];then
+		str="$str -t -1 "
+	elif [ "$THRESH" = "3" ];then
+		str="$str -t $PAGESIZE "
+	fi
+
+	if [ "$str" != "" ]; then
+		btrfs filesystem defragment $str $SCRATCH_MNT/tmp_file
+	else
+		if [ "$DEFRAG_TARGET" = "1" ];then
+			btrfs filesystem defragment $SCRATCH_MNT/tmp_file
+		elif [ "$DEFRAG_TARGET" = "2" ];then
+			btrfs filesystem defragment $SCRATCH_MNT/tmp_dir
+		elif [ "$DEFRAG_TARGET" = "3" ];then
+			btrfs filesystem defragment $SCRATCH_MNT
+		fi
+	fi
+	ret_val=$?
+	sync
+	if [ $ret_val -ne 20 ];then
+		echo "btrfs filesystem defragment failed! err is $ret_val"
+	fi
+}
+
+_checksum()
+{
+	md5sum -c /tmp/checksum > /dev/null 2>&1
+	if [ $? -ne 0 ]; then
+		echo "md5 checksum failed!"
+	fi
+}
+
+_fsck()
+{
+	btrfsck $SCRATCH_DEV > /dev/null 2>&1
+	ret_val=$?
+	if [ $ret_val -ne 0 ]; then
+		echo "btrfsck _FAIL_! err is $ret_val"
+	fi
+}
+
+_parse_options()
+{
+	PASS=0
+	if [ "`echo $args | grep "#"`" != "" ];then
+		PASS=1
+	fi
+
+	if [ $PASS -ne 1 ];then
+	DEFRAG_TARGET=`echo $args | awk -F ' ' '{ print $1 }'`
+	case $DEFRAG_TARGET in
+		"1")
+			echo "a single file"
+			;;
+		"2")
+			echo "a directory"
+			;;
+		"3")
+			echo "a filesystem"
+			;;
+	esac
+
+	FILE_RANGE=`echo $args | awk -F ' ' '{ print $2 }'`
+	case $FILE_RANGE in
+		"1")
+			echo "online defragment range: default"
+			;;
+		"2")
+			echo "online defragment range: start < 0 && 0 < len < file size"
+			;;
+		"3")
+			echo "online defragment range: start > file size && 0 < len < file size"
+			;;
+		"4")
+			echo "online defragment range: start = 0 && len < 0"
+			;;
+		"5")
+			echo "online defragment range: start = 0 && len > file size"
+			;;
+		"6")
+			echo "online defragment range: start = 0 && 0 < len < file size"
+			;;
+	esac
+
+	DEFRAG_COMPRESS=`echo $args | awk -F ' ' '{ print $3 }'`
+	case $DEFRAG_COMPRESS in
+		"1")
+			echo "online defragment compress: off"
+			;;
+		"2")
+			echo "online defragment compress: on"
+	esac
+	fi
+}
+
+_cleanup_defrag()
+{
+	rm -fr $SCRATCH_MNT/*
+	umount $SCRATCH_MNT > /dev/null 2>&1
+}
+
+_setup_defrag()
+{
+	umount $SCRATCH_MNT > /dev/null 2>&1
+	_scratch_mkfs > /dev/null 2>&1
+	_scratch_mount
+	_create_file
+}
+
+_rundefrag()
+{
+	args=$1
+
+	echo "btrfs online defragment test start"
+	while read args
+	do
+		echo "$args"
+		_parse_options
+		_setup_defrag
+		_btrfs_online_defrag
+		_checksum
+		_cleanup_defrag
+		_fsck
+	done < $args
+	echo "btrfs online defragment test done"
+}
+
+_runtest()
+{
+	_rundefrag $defrag_args
+}
+
+# get standard environment, filters and checks
+. ./common.rc
+. ./common.filter
+. ./common.defrag
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+
+_setup_testdir
+## We require scratch so that we'll have free contiguous space
+_require_scratch
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount
+
+_require_defrag
+
+_runtest
+
+status=0
+exit
diff --git a/278.args b/278.args
new file mode 100644
index 0000000..9c22dc9
--- /dev/null
+++ b/278.args
@@ -0,0 +1,18 @@
+1	1	1	1	1
+1	1	1	1	2
+1	1	1	1	3
+1	1	1	2	1
+1	1	2	-	-
+1	6	1	1	1
+1	1	1	1	1
+1	1	1	1	2
+1	1	1	1	3
+1	1	1	2	1
+1	1	2	-	-
+1	2	1	1	1
+1	3	1	1	1
+1	4	1	1	1
+1	5	1	1	1
+1	6	1	1	1
+2	1	1	1	1
+3	1	1	1	1
diff --git a/278.out b/278.out
new file mode 100644
index 0000000..2fc167d
--- /dev/null
+++ b/278.out
@@ -0,0 +1,75 @@
+QA output created by 278
+btrfs online defragment test start
+1	1	1	1	1
+a single file
+online defragment range: default
+online defragment compress: off
+1	1	1	1	2
+a single file
+online defragment range: default
+online defragment compress: off
+1	1	1	1	3
+a single file
+online defragment range: default
+online defragment compress: off
+1	1	1	2	1
+a single file
+online defragment range: default
+online defragment compress: off
+1	1	2	-	-
+a single file
+online defragment range: default
+online defragment compress: on
+1	6	1	1	1
+a single file
+online defragment range: start = 0 && 0 < len < file size
+online defragment compress: off
+1	1	1	1	1
+a single file
+online defragment range: default
+online defragment compress: off
+1	1	1	1	2
+a single file
+online defragment range: default
+online defragment compress: off
+1	1	1	1	3
+a single file
+online defragment range: default
+online defragment compress: off
+1	1	1	2	1
+a single file
+online defragment range: default
+online defragment compress: off
+1	1	2	-	-
+a single file
+online defragment range: default
+online defragment compress: on
+1	2	1	1	1
+a single file
+online defragment range: start < 0 && 0 < len < file size
+online defragment compress: off
+1	3	1	1	1
+a single file
+online defragment range: start > file size && 0 < len < file size
+online defragment compress: off
+1	4	1	1	1
+a single file
+online defragment range: start = 0 && len < 0
+online defragment compress: off
+1	5	1	1	1
+a single file
+online defragment range: start = 0 && len > file size
+online defragment compress: off
+1	6	1	1	1
+a single file
+online defragment range: start = 0 && 0 < len < file size
+online defragment compress: off
+2	1	1	1	1
+a directory
+online defragment range: default
+online defragment compress: off
+3	1	1	1	1
+a filesystem
+online defragment range: default
+online defragment compress: off
+btrfs online defragment test done
diff --git a/group b/group
index 99592d3..9dedd25 100644
--- a/group
+++ b/group
@@ -391,3 +391,4 @@ deprecated
 275 auto rw
 276 auto rw metadata
 277 auto ioctl quick metadata
+278 auto
-- 
1.6.5.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3 v2] xfstests: add btrfs online defragments QA test
@ 2012-02-09  5:40 ` Liu Bo
  0 siblings, 0 replies; 6+ messages in thread
From: Liu Bo @ 2012-02-09  5:40 UTC (permalink / raw)
  To: xfs; +Cc: hch, linux-btrfs

As the title shows, we port btrfs online defragments QA test into xfstests.

v1->v2:
- place the real tests inside testcases.

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
---
 278      |  247 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 278.args |   18 +++++
 278.out  |   75 +++++++++++++++++++
 group    |    1 +
 4 files changed, 341 insertions(+), 0 deletions(-)
 create mode 100755 278
 create mode 100644 278.args
 create mode 100644 278.out

diff --git a/278 b/278
new file mode 100755
index 0000000..71f12e0
--- /dev/null
+++ b/278
@@ -0,0 +1,247 @@
+#! /bin/bash
+# FS QA Test No. 278
+#
+# Btrfs Online defragmentation tests
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2012 Fujitsu Liu Bo.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+# creator
+owner=liubo2009@cn.fujitsu.com
+
+seq=`basename $0`
+echo "QA output created by $seq"
+test_path="`pwd`"
+progs_dir="$test_path/src/btrfs_online_defragment/"
+tmp=tmp/$$
+defrag_args="$test_path/${seq}.args"
+
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    rm -f $tmp.*
+}
+
+_create_file()
+{
+	CNT=11999
+	FILESIZE=48000
+	if [ "$DEFRAG_TARGET" = "1" ];then
+		for i in `seq $CNT -1 0`; do
+			dd if=/dev/zero of=$SCRATCH_MNT/tmp_file bs=4k count=1 \
+			 conv=notrunc seek=$i oflag=sync &>/dev/null
+		done
+		# get md5sum
+		md5sum $SCRATCH_MNT/tmp_file > /tmp/checksum
+	elif [ "$DEFRAG_TARGET" = "2" ];then
+		mkdir $SCRATCH_MNT/tmp_dir
+		for i in `seq $CNT -1 0`; do
+			dd if=/dev/zero of=$SCRATCH_MNT/tmp_dir/tmp_file bs=4k \
+			count=1 conv=notrunc seek=$i oflag=sync &>/dev/null
+		done
+		# get md5sum
+		md5sum $SCRATCH_MNT/tmp_dir/tmp_file > /tmp/checksum
+	elif [ "$DEFRAG_TARGET" = "3" ];then
+		for i in `seq $CNT -1 0`; do
+			dd if=/dev/zero of=$SCRATCH_MNT/tmp_file bs=4k count=1 \
+			conv=notrunc seek=$i oflag=sync &>/dev/null
+		done
+		# get md5sum
+		md5sum $SCRATCH_MNT/tmp_file > /tmp/checksum
+	fi
+}
+
+_btrfs_online_defrag()
+{
+	str=""
+	if [ "$FILE_RANGE" = "2" ];then
+		str="$str -s -1 -l $((FILESIZE / 2)) "
+	elif [ "$FILE_RANGE" = "3" ];then
+		str="$str -s $((FILESIZE + 1)) -l $((FILESIZE / 2)) "
+		HAVE_DEFRAG=1
+	elif [ "$FILE_RANGE" = "4" ];then
+		str="$str -l -1 "
+	elif [ "$FILE_RANGE" = "5" ];then
+		str="$str -l $((FILESIZE + 1)) "
+	elif [ "$FILE_RANGE" = "6" ];then
+		str="$str -l $((FILESIZE / 2)) "
+	fi
+
+	if [ "$DEFRAG_COMPRESS" = "2" ];then
+		str="$str -c "
+	fi
+
+	if [ "$FLUSH" = "2" ];then
+		str="$str -f "
+	fi
+
+	if [ "$THRESH" = "2" ];then
+		str="$str -t -1 "
+	elif [ "$THRESH" = "3" ];then
+		str="$str -t $PAGESIZE "
+	fi
+
+	if [ "$str" != "" ]; then
+		btrfs filesystem defragment $str $SCRATCH_MNT/tmp_file
+	else
+		if [ "$DEFRAG_TARGET" = "1" ];then
+			btrfs filesystem defragment $SCRATCH_MNT/tmp_file
+		elif [ "$DEFRAG_TARGET" = "2" ];then
+			btrfs filesystem defragment $SCRATCH_MNT/tmp_dir
+		elif [ "$DEFRAG_TARGET" = "3" ];then
+			btrfs filesystem defragment $SCRATCH_MNT
+		fi
+	fi
+	ret_val=$?
+	sync
+	if [ $ret_val -ne 20 ];then
+		echo "btrfs filesystem defragment failed! err is $ret_val"
+	fi
+}
+
+_checksum()
+{
+	md5sum -c /tmp/checksum > /dev/null 2>&1
+	if [ $? -ne 0 ]; then
+		echo "md5 checksum failed!"
+	fi
+}
+
+_fsck()
+{
+	btrfsck $SCRATCH_DEV > /dev/null 2>&1
+	ret_val=$?
+	if [ $ret_val -ne 0 ]; then
+		echo "btrfsck _FAIL_! err is $ret_val"
+	fi
+}
+
+_parse_options()
+{
+	PASS=0
+	if [ "`echo $args | grep "#"`" != "" ];then
+		PASS=1
+	fi
+
+	if [ $PASS -ne 1 ];then
+	DEFRAG_TARGET=`echo $args | awk -F ' ' '{ print $1 }'`
+	case $DEFRAG_TARGET in
+		"1")
+			echo "a single file"
+			;;
+		"2")
+			echo "a directory"
+			;;
+		"3")
+			echo "a filesystem"
+			;;
+	esac
+
+	FILE_RANGE=`echo $args | awk -F ' ' '{ print $2 }'`
+	case $FILE_RANGE in
+		"1")
+			echo "online defragment range: default"
+			;;
+		"2")
+			echo "online defragment range: start < 0 && 0 < len < file size"
+			;;
+		"3")
+			echo "online defragment range: start > file size && 0 < len < file size"
+			;;
+		"4")
+			echo "online defragment range: start = 0 && len < 0"
+			;;
+		"5")
+			echo "online defragment range: start = 0 && len > file size"
+			;;
+		"6")
+			echo "online defragment range: start = 0 && 0 < len < file size"
+			;;
+	esac
+
+	DEFRAG_COMPRESS=`echo $args | awk -F ' ' '{ print $3 }'`
+	case $DEFRAG_COMPRESS in
+		"1")
+			echo "online defragment compress: off"
+			;;
+		"2")
+			echo "online defragment compress: on"
+	esac
+	fi
+}
+
+_cleanup_defrag()
+{
+	rm -fr $SCRATCH_MNT/*
+	umount $SCRATCH_MNT > /dev/null 2>&1
+}
+
+_setup_defrag()
+{
+	umount $SCRATCH_MNT > /dev/null 2>&1
+	_scratch_mkfs > /dev/null 2>&1
+	_scratch_mount
+	_create_file
+}
+
+_rundefrag()
+{
+	args=$1
+
+	echo "btrfs online defragment test start"
+	while read args
+	do
+		echo "$args"
+		_parse_options
+		_setup_defrag
+		_btrfs_online_defrag
+		_checksum
+		_cleanup_defrag
+		_fsck
+	done < $args
+	echo "btrfs online defragment test done"
+}
+
+_runtest()
+{
+	_rundefrag $defrag_args
+}
+
+# get standard environment, filters and checks
+. ./common.rc
+. ./common.filter
+. ./common.defrag
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+
+_setup_testdir
+## We require scratch so that we'll have free contiguous space
+_require_scratch
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount
+
+_require_defrag
+
+_runtest
+
+status=0
+exit
diff --git a/278.args b/278.args
new file mode 100644
index 0000000..9c22dc9
--- /dev/null
+++ b/278.args
@@ -0,0 +1,18 @@
+1	1	1	1	1
+1	1	1	1	2
+1	1	1	1	3
+1	1	1	2	1
+1	1	2	-	-
+1	6	1	1	1
+1	1	1	1	1
+1	1	1	1	2
+1	1	1	1	3
+1	1	1	2	1
+1	1	2	-	-
+1	2	1	1	1
+1	3	1	1	1
+1	4	1	1	1
+1	5	1	1	1
+1	6	1	1	1
+2	1	1	1	1
+3	1	1	1	1
diff --git a/278.out b/278.out
new file mode 100644
index 0000000..2fc167d
--- /dev/null
+++ b/278.out
@@ -0,0 +1,75 @@
+QA output created by 278
+btrfs online defragment test start
+1	1	1	1	1
+a single file
+online defragment range: default
+online defragment compress: off
+1	1	1	1	2
+a single file
+online defragment range: default
+online defragment compress: off
+1	1	1	1	3
+a single file
+online defragment range: default
+online defragment compress: off
+1	1	1	2	1
+a single file
+online defragment range: default
+online defragment compress: off
+1	1	2	-	-
+a single file
+online defragment range: default
+online defragment compress: on
+1	6	1	1	1
+a single file
+online defragment range: start = 0 && 0 < len < file size
+online defragment compress: off
+1	1	1	1	1
+a single file
+online defragment range: default
+online defragment compress: off
+1	1	1	1	2
+a single file
+online defragment range: default
+online defragment compress: off
+1	1	1	1	3
+a single file
+online defragment range: default
+online defragment compress: off
+1	1	1	2	1
+a single file
+online defragment range: default
+online defragment compress: off
+1	1	2	-	-
+a single file
+online defragment range: default
+online defragment compress: on
+1	2	1	1	1
+a single file
+online defragment range: start < 0 && 0 < len < file size
+online defragment compress: off
+1	3	1	1	1
+a single file
+online defragment range: start > file size && 0 < len < file size
+online defragment compress: off
+1	4	1	1	1
+a single file
+online defragment range: start = 0 && len < 0
+online defragment compress: off
+1	5	1	1	1
+a single file
+online defragment range: start = 0 && len > file size
+online defragment compress: off
+1	6	1	1	1
+a single file
+online defragment range: start = 0 && 0 < len < file size
+online defragment compress: off
+2	1	1	1	1
+a directory
+online defragment range: default
+online defragment compress: off
+3	1	1	1	1
+a filesystem
+online defragment range: default
+online defragment compress: off
+btrfs online defragment test done
diff --git a/group b/group
index 99592d3..9dedd25 100644
--- a/group
+++ b/group
@@ -391,3 +391,4 @@ deprecated
 275 auto rw
 276 auto rw metadata
 277 auto ioctl quick metadata
+278 auto
-- 
1.6.5.2

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3 v2] xfstests: add btrfs online defragments QA test
  2012-02-09  5:40 ` Liu Bo
@ 2012-02-13 17:53   ` Christoph Hellwig
  -1 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2012-02-13 17:53 UTC (permalink / raw)
  To: Liu Bo; +Cc: xfs, hch, linux-btrfs

This still needs a bit more work:

> +test_path="`pwd`"
> +progs_dir="$test_path/src/btrfs_online_defragment/"

this isn't actually used.


> +tmp=tmp/$$
> +defrag_args="$test_path/${seq}.args"

Just hardcode the arguments, preferably without the args file
indirection.

> +_create_file()
> +{
> +	CNT=11999
> +	FILESIZE=48000
> +	if [ "$DEFRAG_TARGET" = "1" ];then
> +		for i in `seq $CNT -1 0`; do
> +			dd if=/dev/zero of=$SCRATCH_MNT/tmp_file bs=4k count=1 \
> +			 conv=notrunc seek=$i oflag=sync &>/dev/null
> +		done
> +		# get md5sum
> +		md5sum $SCRATCH_MNT/tmp_file > /tmp/checksum
> +	elif [ "$DEFRAG_TARGET" = "2" ];then
> +		mkdir $SCRATCH_MNT/tmp_dir
> +		for i in `seq $CNT -1 0`; do
> +			dd if=/dev/zero of=$SCRATCH_MNT/tmp_dir/tmp_file bs=4k \
> +			count=1 conv=notrunc seek=$i oflag=sync &>/dev/null
> +		done
> +		# get md5sum
> +		md5sum $SCRATCH_MNT/tmp_dir/tmp_file > /tmp/checksum
> +	elif [ "$DEFRAG_TARGET" = "3" ];then
> +		for i in `seq $CNT -1 0`; do
> +			dd if=/dev/zero of=$SCRATCH_MNT/tmp_file bs=4k count=1 \
> +			conv=notrunc seek=$i oflag=sync &>/dev/null
> +		done
> +		# get md5sum
> +		md5sum $SCRATCH_MNT/tmp_file > /tmp/checksum
> +	fi
> +}

It seems like each of these cases should be a different function.

> +_btrfs_online_defrag()
> +{
> +	str=""
> +	if [ "$FILE_RANGE" = "2" ];then
> +		str="$str -s -1 -l $((FILESIZE / 2)) "
> +	elif [ "$FILE_RANGE" = "3" ];then
> +		str="$str -s $((FILESIZE + 1)) -l $((FILESIZE / 2)) "
> +		HAVE_DEFRAG=1
> +	elif [ "$FILE_RANGE" = "4" ];then
> +		str="$str -l -1 "
> +	elif [ "$FILE_RANGE" = "5" ];then
> +		str="$str -l $((FILESIZE + 1)) "
> +	elif [ "$FILE_RANGE" = "6" ];then
> +		str="$str -l $((FILESIZE / 2)) "
> +	fi
> +
> +	if [ "$DEFRAG_COMPRESS" = "2" ];then
> +		str="$str -c "
> +	fi
> +
> +	if [ "$FLUSH" = "2" ];then
> +		str="$str -f "
> +	fi
> +
> +	if [ "$THRESH" = "2" ];then
> +		str="$str -t -1 "
> +	elif [ "$THRESH" = "3" ];then
> +		str="$str -t $PAGESIZE "
> +	fi
> +
> +	if [ "$str" != "" ]; then
> +		btrfs filesystem defragment $str $SCRATCH_MNT/tmp_file
> +	else
> +		if [ "$DEFRAG_TARGET" = "1" ];then
> +			btrfs filesystem defragment $SCRATCH_MNT/tmp_file
> +		elif [ "$DEFRAG_TARGET" = "2" ];then
> +			btrfs filesystem defragment $SCRATCH_MNT/tmp_dir
> +		elif [ "$DEFRAG_TARGET" = "3" ];then
> +			btrfs filesystem defragment $SCRATCH_MNT
> +		fi
> +	fi
> +	ret_val=$?
> +	sync
> +	if [ $ret_val -ne 20 ];then
> +		echo "btrfs filesystem defragment failed! err is $ret_val"
> +	fi
> +}

> +_fsck()
> +{
> +	btrfsck $SCRATCH_DEV > /dev/null 2>&1
> +	ret_val=$?
> +	if [ $ret_val -ne 0 ]; then
> +		echo "btrfsck _FAIL_! err is $ret_val"
> +	fi
> +}

This should use the generic xfstests fsck invocation wrappers.

> +_parse_options()

Please don't use an option parser but just call the low-level file
creation functions directly.

> +_cleanup_defrag()
> +{
> +	rm -fr $SCRATCH_MNT/*
> +	umount $SCRATCH_MNT > /dev/null 2>&1
> +}

No need to remove everything as the scratch filesystem gets recreated
every time.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3 v2] xfstests: add btrfs online defragments QA test
@ 2012-02-13 17:53   ` Christoph Hellwig
  0 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2012-02-13 17:53 UTC (permalink / raw)
  To: Liu Bo; +Cc: hch, linux-btrfs, xfs

This still needs a bit more work:

> +test_path="`pwd`"
> +progs_dir="$test_path/src/btrfs_online_defragment/"

this isn't actually used.


> +tmp=tmp/$$
> +defrag_args="$test_path/${seq}.args"

Just hardcode the arguments, preferably without the args file
indirection.

> +_create_file()
> +{
> +	CNT=11999
> +	FILESIZE=48000
> +	if [ "$DEFRAG_TARGET" = "1" ];then
> +		for i in `seq $CNT -1 0`; do
> +			dd if=/dev/zero of=$SCRATCH_MNT/tmp_file bs=4k count=1 \
> +			 conv=notrunc seek=$i oflag=sync &>/dev/null
> +		done
> +		# get md5sum
> +		md5sum $SCRATCH_MNT/tmp_file > /tmp/checksum
> +	elif [ "$DEFRAG_TARGET" = "2" ];then
> +		mkdir $SCRATCH_MNT/tmp_dir
> +		for i in `seq $CNT -1 0`; do
> +			dd if=/dev/zero of=$SCRATCH_MNT/tmp_dir/tmp_file bs=4k \
> +			count=1 conv=notrunc seek=$i oflag=sync &>/dev/null
> +		done
> +		# get md5sum
> +		md5sum $SCRATCH_MNT/tmp_dir/tmp_file > /tmp/checksum
> +	elif [ "$DEFRAG_TARGET" = "3" ];then
> +		for i in `seq $CNT -1 0`; do
> +			dd if=/dev/zero of=$SCRATCH_MNT/tmp_file bs=4k count=1 \
> +			conv=notrunc seek=$i oflag=sync &>/dev/null
> +		done
> +		# get md5sum
> +		md5sum $SCRATCH_MNT/tmp_file > /tmp/checksum
> +	fi
> +}

It seems like each of these cases should be a different function.

> +_btrfs_online_defrag()
> +{
> +	str=""
> +	if [ "$FILE_RANGE" = "2" ];then
> +		str="$str -s -1 -l $((FILESIZE / 2)) "
> +	elif [ "$FILE_RANGE" = "3" ];then
> +		str="$str -s $((FILESIZE + 1)) -l $((FILESIZE / 2)) "
> +		HAVE_DEFRAG=1
> +	elif [ "$FILE_RANGE" = "4" ];then
> +		str="$str -l -1 "
> +	elif [ "$FILE_RANGE" = "5" ];then
> +		str="$str -l $((FILESIZE + 1)) "
> +	elif [ "$FILE_RANGE" = "6" ];then
> +		str="$str -l $((FILESIZE / 2)) "
> +	fi
> +
> +	if [ "$DEFRAG_COMPRESS" = "2" ];then
> +		str="$str -c "
> +	fi
> +
> +	if [ "$FLUSH" = "2" ];then
> +		str="$str -f "
> +	fi
> +
> +	if [ "$THRESH" = "2" ];then
> +		str="$str -t -1 "
> +	elif [ "$THRESH" = "3" ];then
> +		str="$str -t $PAGESIZE "
> +	fi
> +
> +	if [ "$str" != "" ]; then
> +		btrfs filesystem defragment $str $SCRATCH_MNT/tmp_file
> +	else
> +		if [ "$DEFRAG_TARGET" = "1" ];then
> +			btrfs filesystem defragment $SCRATCH_MNT/tmp_file
> +		elif [ "$DEFRAG_TARGET" = "2" ];then
> +			btrfs filesystem defragment $SCRATCH_MNT/tmp_dir
> +		elif [ "$DEFRAG_TARGET" = "3" ];then
> +			btrfs filesystem defragment $SCRATCH_MNT
> +		fi
> +	fi
> +	ret_val=$?
> +	sync
> +	if [ $ret_val -ne 20 ];then
> +		echo "btrfs filesystem defragment failed! err is $ret_val"
> +	fi
> +}

> +_fsck()
> +{
> +	btrfsck $SCRATCH_DEV > /dev/null 2>&1
> +	ret_val=$?
> +	if [ $ret_val -ne 0 ]; then
> +		echo "btrfsck _FAIL_! err is $ret_val"
> +	fi
> +}

This should use the generic xfstests fsck invocation wrappers.

> +_parse_options()

Please don't use an option parser but just call the low-level file
creation functions directly.

> +_cleanup_defrag()
> +{
> +	rm -fr $SCRATCH_MNT/*
> +	umount $SCRATCH_MNT > /dev/null 2>&1
> +}

No need to remove everything as the scratch filesystem gets recreated
every time.

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3 v2] xfstests: add btrfs online defragments QA test
  2012-02-13 17:53   ` Christoph Hellwig
@ 2012-02-14  1:20     ` Liu Bo
  -1 siblings, 0 replies; 6+ messages in thread
From: Liu Bo @ 2012-02-14  1:20 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs, linux-btrfs

On 02/14/2012 01:53 AM, Christoph Hellwig wrote:
> This still needs a bit more work:
> 
>> +test_path="`pwd`"
>> +progs_dir="$test_path/src/btrfs_online_defragment/"
> 
> this isn't actually used.
> 
> 
>> +tmp=tmp/$$
>> +defrag_args="$test_path/${seq}.args"
> 
> Just hardcode the arguments, preferably without the args file
> indirection.
> 
>> +_create_file()
>> +{
>> +	CNT=11999
>> +	FILESIZE=48000
>> +	if [ "$DEFRAG_TARGET" = "1" ];then
>> +		for i in `seq $CNT -1 0`; do
>> +			dd if=/dev/zero of=$SCRATCH_MNT/tmp_file bs=4k count=1 \
>> +			 conv=notrunc seek=$i oflag=sync &>/dev/null
>> +		done
>> +		# get md5sum
>> +		md5sum $SCRATCH_MNT/tmp_file > /tmp/checksum
>> +	elif [ "$DEFRAG_TARGET" = "2" ];then
>> +		mkdir $SCRATCH_MNT/tmp_dir
>> +		for i in `seq $CNT -1 0`; do
>> +			dd if=/dev/zero of=$SCRATCH_MNT/tmp_dir/tmp_file bs=4k \
>> +			count=1 conv=notrunc seek=$i oflag=sync &>/dev/null
>> +		done
>> +		# get md5sum
>> +		md5sum $SCRATCH_MNT/tmp_dir/tmp_file > /tmp/checksum
>> +	elif [ "$DEFRAG_TARGET" = "3" ];then
>> +		for i in `seq $CNT -1 0`; do
>> +			dd if=/dev/zero of=$SCRATCH_MNT/tmp_file bs=4k count=1 \
>> +			conv=notrunc seek=$i oflag=sync &>/dev/null
>> +		done
>> +		# get md5sum
>> +		md5sum $SCRATCH_MNT/tmp_file > /tmp/checksum
>> +	fi
>> +}
> 
> It seems like each of these cases should be a different function.
> 
>> +_btrfs_online_defrag()
>> +{
>> +	str=""
>> +	if [ "$FILE_RANGE" = "2" ];then
>> +		str="$str -s -1 -l $((FILESIZE / 2)) "
>> +	elif [ "$FILE_RANGE" = "3" ];then
>> +		str="$str -s $((FILESIZE + 1)) -l $((FILESIZE / 2)) "
>> +		HAVE_DEFRAG=1
>> +	elif [ "$FILE_RANGE" = "4" ];then
>> +		str="$str -l -1 "
>> +	elif [ "$FILE_RANGE" = "5" ];then
>> +		str="$str -l $((FILESIZE + 1)) "
>> +	elif [ "$FILE_RANGE" = "6" ];then
>> +		str="$str -l $((FILESIZE / 2)) "
>> +	fi
>> +
>> +	if [ "$DEFRAG_COMPRESS" = "2" ];then
>> +		str="$str -c "
>> +	fi
>> +
>> +	if [ "$FLUSH" = "2" ];then
>> +		str="$str -f "
>> +	fi
>> +
>> +	if [ "$THRESH" = "2" ];then
>> +		str="$str -t -1 "
>> +	elif [ "$THRESH" = "3" ];then
>> +		str="$str -t $PAGESIZE "
>> +	fi
>> +
>> +	if [ "$str" != "" ]; then
>> +		btrfs filesystem defragment $str $SCRATCH_MNT/tmp_file
>> +	else
>> +		if [ "$DEFRAG_TARGET" = "1" ];then
>> +			btrfs filesystem defragment $SCRATCH_MNT/tmp_file
>> +		elif [ "$DEFRAG_TARGET" = "2" ];then
>> +			btrfs filesystem defragment $SCRATCH_MNT/tmp_dir
>> +		elif [ "$DEFRAG_TARGET" = "3" ];then
>> +			btrfs filesystem defragment $SCRATCH_MNT
>> +		fi
>> +	fi
>> +	ret_val=$?
>> +	sync
>> +	if [ $ret_val -ne 20 ];then
>> +		echo "btrfs filesystem defragment failed! err is $ret_val"
>> +	fi
>> +}
> 
>> +_fsck()
>> +{
>> +	btrfsck $SCRATCH_DEV > /dev/null 2>&1
>> +	ret_val=$?
>> +	if [ $ret_val -ne 0 ]; then
>> +		echo "btrfsck _FAIL_! err is $ret_val"
>> +	fi
>> +}
> 
> This should use the generic xfstests fsck invocation wrappers.
> 
>> +_parse_options()
> 
> Please don't use an option parser but just call the low-level file
> creation functions directly.
> 
>> +_cleanup_defrag()
>> +{
>> +	rm -fr $SCRATCH_MNT/*
>> +	umount $SCRATCH_MNT > /dev/null 2>&1
>> +}
> 
> No need to remove everything as the scratch filesystem gets recreated
> every time.
> 
> 

OK, I'll update this more carefully ;)
and thanks for your time!

thanks,
liubo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3 v2] xfstests: add btrfs online defragments QA test
@ 2012-02-14  1:20     ` Liu Bo
  0 siblings, 0 replies; 6+ messages in thread
From: Liu Bo @ 2012-02-14  1:20 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-btrfs, xfs

On 02/14/2012 01:53 AM, Christoph Hellwig wrote:
> This still needs a bit more work:
> 
>> +test_path="`pwd`"
>> +progs_dir="$test_path/src/btrfs_online_defragment/"
> 
> this isn't actually used.
> 
> 
>> +tmp=tmp/$$
>> +defrag_args="$test_path/${seq}.args"
> 
> Just hardcode the arguments, preferably without the args file
> indirection.
> 
>> +_create_file()
>> +{
>> +	CNT=11999
>> +	FILESIZE=48000
>> +	if [ "$DEFRAG_TARGET" = "1" ];then
>> +		for i in `seq $CNT -1 0`; do
>> +			dd if=/dev/zero of=$SCRATCH_MNT/tmp_file bs=4k count=1 \
>> +			 conv=notrunc seek=$i oflag=sync &>/dev/null
>> +		done
>> +		# get md5sum
>> +		md5sum $SCRATCH_MNT/tmp_file > /tmp/checksum
>> +	elif [ "$DEFRAG_TARGET" = "2" ];then
>> +		mkdir $SCRATCH_MNT/tmp_dir
>> +		for i in `seq $CNT -1 0`; do
>> +			dd if=/dev/zero of=$SCRATCH_MNT/tmp_dir/tmp_file bs=4k \
>> +			count=1 conv=notrunc seek=$i oflag=sync &>/dev/null
>> +		done
>> +		# get md5sum
>> +		md5sum $SCRATCH_MNT/tmp_dir/tmp_file > /tmp/checksum
>> +	elif [ "$DEFRAG_TARGET" = "3" ];then
>> +		for i in `seq $CNT -1 0`; do
>> +			dd if=/dev/zero of=$SCRATCH_MNT/tmp_file bs=4k count=1 \
>> +			conv=notrunc seek=$i oflag=sync &>/dev/null
>> +		done
>> +		# get md5sum
>> +		md5sum $SCRATCH_MNT/tmp_file > /tmp/checksum
>> +	fi
>> +}
> 
> It seems like each of these cases should be a different function.
> 
>> +_btrfs_online_defrag()
>> +{
>> +	str=""
>> +	if [ "$FILE_RANGE" = "2" ];then
>> +		str="$str -s -1 -l $((FILESIZE / 2)) "
>> +	elif [ "$FILE_RANGE" = "3" ];then
>> +		str="$str -s $((FILESIZE + 1)) -l $((FILESIZE / 2)) "
>> +		HAVE_DEFRAG=1
>> +	elif [ "$FILE_RANGE" = "4" ];then
>> +		str="$str -l -1 "
>> +	elif [ "$FILE_RANGE" = "5" ];then
>> +		str="$str -l $((FILESIZE + 1)) "
>> +	elif [ "$FILE_RANGE" = "6" ];then
>> +		str="$str -l $((FILESIZE / 2)) "
>> +	fi
>> +
>> +	if [ "$DEFRAG_COMPRESS" = "2" ];then
>> +		str="$str -c "
>> +	fi
>> +
>> +	if [ "$FLUSH" = "2" ];then
>> +		str="$str -f "
>> +	fi
>> +
>> +	if [ "$THRESH" = "2" ];then
>> +		str="$str -t -1 "
>> +	elif [ "$THRESH" = "3" ];then
>> +		str="$str -t $PAGESIZE "
>> +	fi
>> +
>> +	if [ "$str" != "" ]; then
>> +		btrfs filesystem defragment $str $SCRATCH_MNT/tmp_file
>> +	else
>> +		if [ "$DEFRAG_TARGET" = "1" ];then
>> +			btrfs filesystem defragment $SCRATCH_MNT/tmp_file
>> +		elif [ "$DEFRAG_TARGET" = "2" ];then
>> +			btrfs filesystem defragment $SCRATCH_MNT/tmp_dir
>> +		elif [ "$DEFRAG_TARGET" = "3" ];then
>> +			btrfs filesystem defragment $SCRATCH_MNT
>> +		fi
>> +	fi
>> +	ret_val=$?
>> +	sync
>> +	if [ $ret_val -ne 20 ];then
>> +		echo "btrfs filesystem defragment failed! err is $ret_val"
>> +	fi
>> +}
> 
>> +_fsck()
>> +{
>> +	btrfsck $SCRATCH_DEV > /dev/null 2>&1
>> +	ret_val=$?
>> +	if [ $ret_val -ne 0 ]; then
>> +		echo "btrfsck _FAIL_! err is $ret_val"
>> +	fi
>> +}
> 
> This should use the generic xfstests fsck invocation wrappers.
> 
>> +_parse_options()
> 
> Please don't use an option parser but just call the low-level file
> creation functions directly.
> 
>> +_cleanup_defrag()
>> +{
>> +	rm -fr $SCRATCH_MNT/*
>> +	umount $SCRATCH_MNT > /dev/null 2>&1
>> +}
> 
> No need to remove everything as the scratch filesystem gets recreated
> every time.
> 
> 

OK, I'll update this more carefully ;)
and thanks for your time!

thanks,
liubo

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-02-14  1:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-09  5:40 [PATCH 3/3 v2] xfstests: add btrfs online defragments QA test Liu Bo
2012-02-09  5:40 ` Liu Bo
2012-02-13 17:53 ` Christoph Hellwig
2012-02-13 17:53   ` Christoph Hellwig
2012-02-14  1:20   ` Liu Bo
2012-02-14  1:20     ` Liu Bo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.