]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
xfstests: don't remove the two first devices from SCRATCH_DEV_POOL
authorStefan Behrens <sbehrens@giantdisaster.de>
Fri, 23 Aug 2013 13:07:10 +0000 (13:07 +0000)
committerRich Johnston <rjohnston@sgi.com>
Wed, 28 Aug 2013 13:33:21 +0000 (08:33 -0500)
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>
Reviewed-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Rich Johnston <rjohnston@sgi.com>
common/config
common/rc
tests/btrfs/002
tests/btrfs/003
tests/btrfs/006

index 39dd4697c058623b07c82844bc047bd31545bc96..586870be991b37c0a0c84a6aafd00b22694f1821 100644 (file)
@@ -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
index ae80b127e8355feb82f3fdab2604d7d577fcc235..77e96c4c7a9421b92af827e2be7cae1e245e359a 100644 (file)
--- 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()
index 03e9137f5e66b211176c20b23e4def261ea5aba4..f4389aeaacb9774399ed4a1b0f863ff5a25c0a9c 100755 (executable)
@@ -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
index 5c8865127d1fa0c309f7ce38754b1ebda05e8969..262b1d5d226d8e34c8159e70775cf6db03199fbe 100755 (executable)
@@ -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
index 9f7beff46bbf62f79566146c5a5ac7194869e315..715fd80fb6fc3c7e78ab11fa91d5d40fb9da1fa6 100755 (executable)
@@ -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"