All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Behrens <sbehrens@giantdisaster.de>
To: xfs@oss.sgi.com
Cc: linux-btrfs@vger.kernel.org
Subject: [PATCH V4] xfstests: don't remove the two first devices from SCRATCH_DEV_POOL
Date: Fri, 23 Aug 2013 15:07:10 +0200	[thread overview]
Message-ID: <1377263233-8903-1-git-send-email-sbehrens@giantdisaster.de> (raw)

Since common/config is executed twice, if SCRATCH_DEV_POOL is configured
via the environment, the current code removes the first device entry twice
which means that you lose the second device for the test.

The fix is to not remove anything from SCRATCH_DEV_POOL anymore.
That used to be done (I can only guess) to allow to pass the
SCRATCH_DEV_POOL as an argument to _scratch_mkfs. Since _scratch_mkfs adds
the SCRATCH_DEV, the pool mustn't contain that device anymore.

A new function _scratch_pool_mkfs is introduced that does the expected
thing.

Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
---
V1 -> V2:
- rebased.
- fixed a missing adaption to the new way to deal with SCRATCH_DEV_POOL
  in  _test_replace() in tests/btrfs/003.

V2 -> V3:
- V2 was the result of a git rebase mistake (a user error), forget it,
  sorry. V3 now contains the correct fix for a missing adaption to the
  new way to deal with SCRATCH_DEV_POOL in _test_replace() in
  tests/btrfs/003.

V3 -> V4:
- rebased, because it didn't apply cleanly anymore today.

 common/config   |  1 -
 common/rc       | 12 ++++++++++++
 tests/btrfs/002 |  3 ++-
 tests/btrfs/003 | 16 ++++++++--------
 tests/btrfs/006 |  4 ++--
 5 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/common/config b/common/config
index 39dd469..586870b 100644
--- a/common/config
+++ b/common/config
@@ -267,7 +267,6 @@ get_next_config() {
 			exit 1
 		fi
 		SCRATCH_DEV=`echo $SCRATCH_DEV_POOL | awk '{print $1}'`
-		SCRATCH_DEV_POOL=`echo $SCRATCH_DEV_POOL | awk '{ ORS=" "; for (i = 2; i <= NF; i++) print $i}'`
 	fi
 
 	echo $SCRATCH_DEV | grep -q ":" > /dev/null 2>&1
diff --git a/common/rc b/common/rc
index ae80b12..77e96c4 100644
--- a/common/rc
+++ b/common/rc
@@ -550,6 +550,18 @@ _scratch_mkfs()
     esac
 }
 
+_scratch_pool_mkfs()
+{
+    case $FSTYP in
+    btrfs)
+	$MKFS_BTRFS_PROG $MKFS_OPTIONS $* $SCRATCH_DEV_POOL > /dev/null
+	;;
+    *)
+	echo "_scratch_pool_mkfs is not implemented for $FSTYP" 1>&2
+	;;
+    esac
+}
+
 # Create fs of certain size on scratch device
 # _scratch_mkfs_sized <size in bytes> [optional blocksize]
 _scratch_mkfs_sized()
diff --git a/tests/btrfs/002 b/tests/btrfs/002
index 03e9137..f4389ae 100755
--- a/tests/btrfs/002
+++ b/tests/btrfs/002
@@ -45,8 +45,9 @@ _need_to_be_root
 _supported_fs btrfs
 _supported_os Linux
 _require_scratch
+_require_scratch_dev_pool
 
-_scratch_mkfs $SCRATCH_DEV_POOL > /dev/null 2>&1 || _fail "mkfs failed"
+_scratch_pool_mkfs > /dev/null 2>&1 || _fail "mkfs failed"
 _scratch_mount
 
 # Create and save sha256sum
diff --git a/tests/btrfs/003 b/tests/btrfs/003
index 5c88651..262b1d5 100755
--- a/tests/btrfs/003
+++ b/tests/btrfs/003
@@ -58,7 +58,7 @@ rm -f $seqres.full
 _test_raid0()
 {
 	export MKFS_OPTIONS="-m raid0 -d raid0"
-	_scratch_mkfs $SCRATCH_DEV_POOL >> $seqres.full 2>&1 || _fail "mkfs failed"
+	_scratch_pool_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
 	_scratch_mount
 	dirp=`mktemp -duq $SCRATCH_MNT/dir.XXXXXX`
 	_populate_fs -n 1 -f 20 -d 10 -r $dirp -s 10
@@ -68,7 +68,7 @@ _test_raid0()
 _test_raid1()
 {
 	export MKFS_OPTIONS="-m raid1 -d raid1"
-	_scratch_mkfs $SCRATCH_DEV_POOL >> $seqres.full 2>&1 || _fail "mkfs failed"
+	_scratch_pool_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
 	_scratch_mount
 	dirp=`mktemp -duq $SCRATCH_MNT/dir.XXXXXX`
 	_populate_fs -n 1 -f 20 -d 10 -r $dirp -s 10
@@ -78,7 +78,7 @@ _test_raid1()
 _test_raid10()
 {
 	export MKFS_OPTIONS="-m raid10 -d raid10"
-	_scratch_mkfs $SCRATCH_DEV_POOL >> $seqres.full 2>&1 || _fail "mkfs failed"
+	_scratch_pool_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
 	_scratch_mount
 	dirp=`mktemp -duq $SCRATCH_MNT/dir.XXXXXX`
 	_populate_fs -n 1 -f 20 -d 10 -r $dirp -s 10
@@ -88,7 +88,7 @@ _test_raid10()
 _test_single()
 {
 	export MKFS_OPTIONS="-m single -d single"
-	_scratch_mkfs $SCRATCH_DEV_POOL >> $seqres.full 2>&1 || _fail "mkfs failed"
+	_scratch_pool_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
 	_scratch_mount
 	dirp=`mktemp -duq $SCRATCH_MNT/dir.XXXXXX`
 	_populate_fs -n 1 -f 20 -d 10 -r $dirp -s 10
@@ -108,7 +108,7 @@ _test_add()
 	_scratch_mount
 	dirp=`mktemp -duq $SCRATCH_MNT/dir.XXXXXX`
 	_populate_fs -n 1 -f 20 -d 10 -r $dirp -s 10
-	for i in `seq 1 $n`; do
+	for i in `seq 2 $n`; do
 		$BTRFS_UTIL_PROG device add ${devs[$i]} $SCRATCH_MNT >> $seqres.full 2>&1 || _fail "device add failed"
 	done
 	$BTRFS_UTIL_PROG filesystem balance $SCRATCH_MNT >> $seqres.full 2>&1 || _fail "balance failed"
@@ -124,9 +124,9 @@ _test_replace()
 	local d
 	local DEVHTL=""
 
-	# exclude the last disk in the disk pool
+	# exclude the first and the last disk in the disk pool
 	n=$(($n-1))
-	ds=${devs[@]:0:$n}
+	ds=${devs[@]:1:$(($n-1))}
 
 	export MKFS_OPTIONS="-m raid1 -d raid1"
 	_scratch_mkfs "$ds" >> $seqres.full 2>&1 || _fail "tr: mkfs failed"
@@ -164,7 +164,7 @@ _test_replace()
 
 _test_remove()
 {
-	_scratch_mkfs "$SCRATCH_DEV_POOL" >> $seqres.full 2>&1 || _fail "mkfs failed"
+	_scratch_pool_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
 	_scratch_mount
 	dirp=`mktemp -duq $SCRATCH_MNT/dir.XXXXXX`
 	_populate_fs -n 1 -f 20 -d 10 -r $dirp -s 10
diff --git a/tests/btrfs/006 b/tests/btrfs/006
index 9f7beff..715fd80 100755
--- a/tests/btrfs/006
+++ b/tests/btrfs/006
@@ -53,12 +53,12 @@ rm -f $seqres.full
 
 FIRST_POOL_DEV=`echo $SCRATCH_DEV_POOL | awk '{print $1}'`
 LAST_POOL_DEV=`echo $SCRATCH_DEV_POOL | awk '{print $NF}'`
-TOTAL_DEVS=`echo $SCRATCH_DEV $SCRATCH_DEV_POOL | wc -w`
+TOTAL_DEVS=`echo $SCRATCH_DEV_POOL | wc -w`
 LABEL=TestLabel.$seq
 
 echo "Scratch $SCRATCH_DEV First $FIRST_POOL_DEV last $LAST_POOL_DEV Total $TOTAL_DEVS" > $seqres.full
 
-_scratch_mkfs $SCRATCH_DEV_POOL >> $seqres.full 2>&1 || _fail "mkfs failed"
+_scratch_pool_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
 
 # These have to be done unmounted...?
 echo "== Set filesystem label to $LABEL"
-- 
1.8.3.4


WARNING: multiple messages have this Message-ID
From: Stefan Behrens <sbehrens@giantdisaster.de>
To: xfs@oss.sgi.com
Cc: linux-btrfs@vger.kernel.org
Subject: [PATCH V4] xfstests: don't remove the two first devices from SCRATCH_DEV_POOL
Date: Fri, 23 Aug 2013 15:07:10 +0200	[thread overview]
Message-ID: <1377263233-8903-1-git-send-email-sbehrens@giantdisaster.de> (raw)

Since common/config is executed twice, if SCRATCH_DEV_POOL is configured
via the environment, the current code removes the first device entry twice
which means that you lose the second device for the test.

The fix is to not remove anything from SCRATCH_DEV_POOL anymore.
That used to be done (I can only guess) to allow to pass the
SCRATCH_DEV_POOL as an argument to _scratch_mkfs. Since _scratch_mkfs adds
the SCRATCH_DEV, the pool mustn't contain that device anymore.

A new function _scratch_pool_mkfs is introduced that does the expected
thing.

Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
---
V1 -> V2:
- rebased.
- fixed a missing adaption to the new way to deal with SCRATCH_DEV_POOL
  in  _test_replace() in tests/btrfs/003.

V2 -> V3:
- V2 was the result of a git rebase mistake (a user error), forget it,
  sorry. V3 now contains the correct fix for a missing adaption to the
  new way to deal with SCRATCH_DEV_POOL in _test_replace() in
  tests/btrfs/003.

V3 -> V4:
- rebased, because it didn't apply cleanly anymore today.

 common/config   |  1 -
 common/rc       | 12 ++++++++++++
 tests/btrfs/002 |  3 ++-
 tests/btrfs/003 | 16 ++++++++--------
 tests/btrfs/006 |  4 ++--
 5 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/common/config b/common/config
index 39dd469..586870b 100644
--- a/common/config
+++ b/common/config
@@ -267,7 +267,6 @@ get_next_config() {
 			exit 1
 		fi
 		SCRATCH_DEV=`echo $SCRATCH_DEV_POOL | awk '{print $1}'`
-		SCRATCH_DEV_POOL=`echo $SCRATCH_DEV_POOL | awk '{ ORS=" "; for (i = 2; i <= NF; i++) print $i}'`
 	fi
 
 	echo $SCRATCH_DEV | grep -q ":" > /dev/null 2>&1
diff --git a/common/rc b/common/rc
index ae80b12..77e96c4 100644
--- a/common/rc
+++ b/common/rc
@@ -550,6 +550,18 @@ _scratch_mkfs()
     esac
 }
 
+_scratch_pool_mkfs()
+{
+    case $FSTYP in
+    btrfs)
+	$MKFS_BTRFS_PROG $MKFS_OPTIONS $* $SCRATCH_DEV_POOL > /dev/null
+	;;
+    *)
+	echo "_scratch_pool_mkfs is not implemented for $FSTYP" 1>&2
+	;;
+    esac
+}
+
 # Create fs of certain size on scratch device
 # _scratch_mkfs_sized <size in bytes> [optional blocksize]
 _scratch_mkfs_sized()
diff --git a/tests/btrfs/002 b/tests/btrfs/002
index 03e9137..f4389ae 100755
--- a/tests/btrfs/002
+++ b/tests/btrfs/002
@@ -45,8 +45,9 @@ _need_to_be_root
 _supported_fs btrfs
 _supported_os Linux
 _require_scratch
+_require_scratch_dev_pool
 
-_scratch_mkfs $SCRATCH_DEV_POOL > /dev/null 2>&1 || _fail "mkfs failed"
+_scratch_pool_mkfs > /dev/null 2>&1 || _fail "mkfs failed"
 _scratch_mount
 
 # Create and save sha256sum
diff --git a/tests/btrfs/003 b/tests/btrfs/003
index 5c88651..262b1d5 100755
--- a/tests/btrfs/003
+++ b/tests/btrfs/003
@@ -58,7 +58,7 @@ rm -f $seqres.full
 _test_raid0()
 {
 	export MKFS_OPTIONS="-m raid0 -d raid0"
-	_scratch_mkfs $SCRATCH_DEV_POOL >> $seqres.full 2>&1 || _fail "mkfs failed"
+	_scratch_pool_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
 	_scratch_mount
 	dirp=`mktemp -duq $SCRATCH_MNT/dir.XXXXXX`
 	_populate_fs -n 1 -f 20 -d 10 -r $dirp -s 10
@@ -68,7 +68,7 @@ _test_raid0()
 _test_raid1()
 {
 	export MKFS_OPTIONS="-m raid1 -d raid1"
-	_scratch_mkfs $SCRATCH_DEV_POOL >> $seqres.full 2>&1 || _fail "mkfs failed"
+	_scratch_pool_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
 	_scratch_mount
 	dirp=`mktemp -duq $SCRATCH_MNT/dir.XXXXXX`
 	_populate_fs -n 1 -f 20 -d 10 -r $dirp -s 10
@@ -78,7 +78,7 @@ _test_raid1()
 _test_raid10()
 {
 	export MKFS_OPTIONS="-m raid10 -d raid10"
-	_scratch_mkfs $SCRATCH_DEV_POOL >> $seqres.full 2>&1 || _fail "mkfs failed"
+	_scratch_pool_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
 	_scratch_mount
 	dirp=`mktemp -duq $SCRATCH_MNT/dir.XXXXXX`
 	_populate_fs -n 1 -f 20 -d 10 -r $dirp -s 10
@@ -88,7 +88,7 @@ _test_raid10()
 _test_single()
 {
 	export MKFS_OPTIONS="-m single -d single"
-	_scratch_mkfs $SCRATCH_DEV_POOL >> $seqres.full 2>&1 || _fail "mkfs failed"
+	_scratch_pool_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
 	_scratch_mount
 	dirp=`mktemp -duq $SCRATCH_MNT/dir.XXXXXX`
 	_populate_fs -n 1 -f 20 -d 10 -r $dirp -s 10
@@ -108,7 +108,7 @@ _test_add()
 	_scratch_mount
 	dirp=`mktemp -duq $SCRATCH_MNT/dir.XXXXXX`
 	_populate_fs -n 1 -f 20 -d 10 -r $dirp -s 10
-	for i in `seq 1 $n`; do
+	for i in `seq 2 $n`; do
 		$BTRFS_UTIL_PROG device add ${devs[$i]} $SCRATCH_MNT >> $seqres.full 2>&1 || _fail "device add failed"
 	done
 	$BTRFS_UTIL_PROG filesystem balance $SCRATCH_MNT >> $seqres.full 2>&1 || _fail "balance failed"
@@ -124,9 +124,9 @@ _test_replace()
 	local d
 	local DEVHTL=""
 
-	# exclude the last disk in the disk pool
+	# exclude the first and the last disk in the disk pool
 	n=$(($n-1))
-	ds=${devs[@]:0:$n}
+	ds=${devs[@]:1:$(($n-1))}
 
 	export MKFS_OPTIONS="-m raid1 -d raid1"
 	_scratch_mkfs "$ds" >> $seqres.full 2>&1 || _fail "tr: mkfs failed"
@@ -164,7 +164,7 @@ _test_replace()
 
 _test_remove()
 {
-	_scratch_mkfs "$SCRATCH_DEV_POOL" >> $seqres.full 2>&1 || _fail "mkfs failed"
+	_scratch_pool_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
 	_scratch_mount
 	dirp=`mktemp -duq $SCRATCH_MNT/dir.XXXXXX`
 	_populate_fs -n 1 -f 20 -d 10 -r $dirp -s 10
diff --git a/tests/btrfs/006 b/tests/btrfs/006
index 9f7beff..715fd80 100755
--- a/tests/btrfs/006
+++ b/tests/btrfs/006
@@ -53,12 +53,12 @@ rm -f $seqres.full
 
 FIRST_POOL_DEV=`echo $SCRATCH_DEV_POOL | awk '{print $1}'`
 LAST_POOL_DEV=`echo $SCRATCH_DEV_POOL | awk '{print $NF}'`
-TOTAL_DEVS=`echo $SCRATCH_DEV $SCRATCH_DEV_POOL | wc -w`
+TOTAL_DEVS=`echo $SCRATCH_DEV_POOL | wc -w`
 LABEL=TestLabel.$seq
 
 echo "Scratch $SCRATCH_DEV First $FIRST_POOL_DEV last $LAST_POOL_DEV Total $TOTAL_DEVS" > $seqres.full
 
-_scratch_mkfs $SCRATCH_DEV_POOL >> $seqres.full 2>&1 || _fail "mkfs failed"
+_scratch_pool_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
 
 # These have to be done unmounted...?
 echo "== Set filesystem label to $LABEL"
-- 
1.8.3.4

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

             reply	other threads:[~2013-08-23 13:07 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-23 13:07 Stefan Behrens [this message]
2013-08-23 13:07 ` Stefan Behrens
2013-08-23 13:07 ` [PATCH][RESEND] xfstests: add a test for btrfs device replace operation Stefan Behrens
2013-08-23 13:07   ` Stefan Behrens
2013-08-23 18:35   ` Josef Bacik
2013-08-23 18:35     ` Josef Bacik
2013-08-28 16:25   ` Rich Johnston
2013-08-28 16:25     ` Rich Johnston
2013-08-23 13:07 ` [PATCH] xfstests: update _filter_size() for Btrfs Stefan Behrens
2013-08-23 13:07   ` Stefan Behrens
2013-08-23 18:34   ` Josef Bacik
2013-08-23 18:34     ` Josef Bacik
2013-08-28 15:38   ` Rich Johnston
2013-08-28 15:38     ` Rich Johnston
2013-08-23 13:07 ` [PATCH] xfstest: fix btrfs/006 for 10+ devices in SCRATCH_DEV_POOL Stefan Behrens
2013-08-23 13:07   ` Stefan Behrens
2013-08-23 18:33   ` Josef Bacik
2013-08-23 18:33     ` Josef Bacik
2013-08-28 15:30   ` Rich Johnston
2013-08-28 15:30     ` Rich Johnston
2013-08-23 18:32 ` [PATCH V4] xfstests: don't remove the two first devices from SCRATCH_DEV_POOL Josef Bacik
2013-08-23 18:32   ` Josef Bacik
2013-08-28 15:18 ` Rich Johnston
2013-08-28 15:18   ` Rich Johnston

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=1377263233-8903-1-git-send-email-sbehrens@giantdisaster.de \
    --to=sbehrens@giantdisaster.de \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=xfs@oss.sgi.com \
    --subject='Re: [PATCH V4] xfstests: don'\''t remove the two first devices from SCRATCH_DEV_POOL' \
    /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

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.