public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: xfs@oss.sgi.com
Subject: [PATCH 4/4] xfstests: speed up 227 by using preallocation
Date: Thu, 26 Jul 2012 18:35:06 +1000	[thread overview]
Message-ID: <1343291706-14882-5-git-send-email-david@fromorbit.com> (raw)
In-Reply-To: <1343291706-14882-1-git-send-email-david@fromorbit.com>

From: Dave Chinner <dchinner@redhat.com>

Test 227 (fsr test) creates fragmented fre space by doing lots of
small writes to sparse offsets ni a file. This seeks the disk heads
around a lot writing data. We don't need to write data - just
trigger allocation. Hence use preallocation instead of data writes
and run at allocation speed rather than data write speed.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 227 |   46 +++++++++++++++++++++++++++++++++-------------
 1 file changed, 33 insertions(+), 13 deletions(-)

diff --git a/227 b/227
index cb7fa70..dfcb1a5 100755
--- a/227
+++ b/227
@@ -52,6 +52,8 @@ _supported_fs xfs
 _supported_os Linux
 _require_scratch
 
+rm -f $seq.full
+
 [ "$XFS_FSR_PROG" = "" ] && _notrun "xfs_fsr not found"
 
 # create freespace holes of 1-3 blocks in length
@@ -62,26 +64,41 @@ _require_scratch
 # (say 5 extents) and lots of variations around that dependent on the
 # number of attributes in the files being defragmented.
 #
+# We have to make sure there are enough free inodes for the test to
+# pass without needing to allocate new clusters during the test.
+# With such fragemented free space, that will fail.
+#
 fragment_freespace()
 {
 	_file="$SCRATCH_MNT/not_free"
+	_dir="$SCRATCH_MNT/saved"
 
-	for i in `seq 0 1 10000`; do
-		echo foo > $_file.$i
+	# allocate inode space
+	mkdir -p $_dir
+	for i in `seq 0 1 1000`; do
+		touch $_file.$i
 	done
-	sync
-
-	for i in `seq 0 2 10000`; do
-		rm -f $_file.$i
+	for i in `seq 0 63 1000`; do
+		mv $_file.$i $_dir
 	done
-	for i in `seq 0 7 10000`; do
+	for i in `seq 0 1 1000`; do
 		rm -f $_file.$i
 	done
+
+	$XFS_IO_PROG -fs -c "resvsp 0 40000k" $_file > /dev/null 2>&1
+
+	for i in `seq 0 8 40000`; do
+		$XFS_IO_PROG -f -c "unresvsp ${i}k 4k" $_file \
+					> /dev/null 2>&1
+	done
+	for i in `seq 0 28 40000`; do
+		$XFS_IO_PROG -f -c "unresvsp ${i}k 4k" $_file \
+					> /dev/null 2>&1
+	done
 	sync
 
 	# and now use up all the remaining extents larger than 3 blocks
-	dd if=/dev/zero of=$_file.large bs=4k count=1024 > /dev/null 2>&1
-	sync
+	$XFS_IO_PROG -fs -c "resvsp 0 4m" $_file.large > /dev/null 2>&1
 }
 
 create_attrs()
@@ -93,11 +110,12 @@ create_attrs()
 
 create_data()
 {
+	size=`expr \( $1 + 1 \) \* 4096`
+	$XFS_IO_PROG -f -c "truncate $size" $2 > /dev/null 2>&1
 	for foo in `seq $1 -1 0`; do
 		let offset=$foo*4096
-		$XFS_IO_PROG -f -c "pwrite $offset 4096" -c "fsync" $2 > /dev/null 2>&1
+		$XFS_IO_PROG -f -c "resvsp $offset 4096" $2 > /dev/null 2>&1
 	done
-	xfs_bmap -vp $2
 }
 
 # create the designated file with a certain number of attributes and a certain
@@ -113,7 +131,7 @@ create_target_attr_first()
 	target=$3
 
 	rm -f $target
-	echo > $target
+	touch $target
 	create_attrs $nattrs $target
 	create_data $file_blocks $target
 }
@@ -131,7 +149,7 @@ create_target_attr_last()
 	target=$3
 
 	rm -f $target
-	echo > $target
+	touch $target
 	create_data $file_blocks $target
 	create_attrs $nattrs $target
 }
@@ -176,11 +194,13 @@ for n in `seq 4 1 12`; do
 		for j in `seq 5 1 20`; do
 			create_target_attr_first $i $j $targ.$i.$j >> $seq.full 2>&1
 		done
+		xfs_bmap -vp $targ.$i.* >> $seq.full 2>&1
 		FSRXFSTEST=true xfs_fsr -d -v -C $n $targ.$i.* >> $seq.full 2>&1
 		xfs_bmap -vp $targ.$i.* >> $seq.full 2>&1
 		for j in `seq 5 1 20`; do
 			create_target_attr_last $i $j $targ.$i.$j >> $seq.full 2>&1
 		done
+		xfs_bmap -vp $targ.$i.* >> $seq.full 2>&1
 		FSRXFSTEST=true xfs_fsr -d -v -C $n $targ.$i.* >> $seq.full 2>&1
 		xfs_bmap -vp $targ.$i.* >> $seq.full 2>&1
 	done
-- 
1.7.10

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

  parent reply	other threads:[~2012-07-26  8:35 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-26  8:35 [PATCH 0/4] xfstests: random fixes and improvements Dave Chinner
2012-07-26  8:35 ` [PATCH 1/4] xfstests: test 110 sometimes fails to unmount scratch dev Dave Chinner
2012-08-16 19:16   ` Rich Johnston
2012-08-28 20:06   ` Christoph Hellwig
2012-08-28 20:20     ` Ben Myers
2012-07-26  8:35 ` [PATCH 2/4] xfstests: loop devices vs umount stupidity Dave Chinner
2012-08-16 19:16   ` Rich Johnston
2012-08-16 22:27     ` Dave Chinner
2012-08-17 12:45       ` Rich Johnston
2012-08-28 20:06   ` Christoph Hellwig
2012-07-26  8:35 ` [PATCH 3/4] xfstests: _check_quota_usage needs to unmount to get XFS quotacheck Dave Chinner
2012-07-26 22:55   ` Dave Chinner
2012-08-16 19:16     ` Rich Johnston
2012-08-28 20:07   ` Christoph Hellwig
2012-07-26  8:35 ` Dave Chinner [this message]
2012-08-16 19:16   ` [PATCH 4/4] xfstests: speed up 227 by using preallocation Rich Johnston
2012-08-28 20:07   ` Christoph Hellwig
2012-08-14 21:39 ` [PATCH 0/4] xfstests: random fixes and improvements Dave Chinner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1343291706-14882-5-git-send-email-david@fromorbit.com \
    --to=david@fromorbit.com \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox