Thread (3 messages) 3 messages, 2 authors, 2012-02-14

Re: [PATCH 3/3 v2] xfstests: add btrfs online defragments QA test

From: Liu Bo <hidden>
Date: 2012-02-14 01:21:49
Also in: linux-xfs

On 02/14/2012 01:53 AM, Christoph Hellwig wrote:
This still needs a bit more work:
quoted
+test_path="`pwd`"
+progs_dir="$test_path/src/btrfs_online_defragment/"
this isn't actually used.

quoted
+tmp=tmp/$$
+defrag_args="$test_path/${seq}.args"
Just hardcode the arguments, preferably without the args file
indirection.
quoted
+_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.
quoted
+_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
+}
quoted
+_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.
quoted
+_parse_options()
Please don't use an option parser but just call the low-level file
creation functions directly.
quoted
+_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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help