* [PATCH 1/3] xfstests: btrfs: add functions to create dm-error device
2015-04-30 10:08 [PATCH 0/3] dm error based test cases Anand Jain
@ 2015-04-30 10:08 ` Anand Jain
2015-05-04 23:46 ` Dave Chinner
2015-04-30 10:08 ` [PATCH 2/3] xfstests: btrfs: test device replace, with EIO on the src dev Anand Jain
` (8 subsequent siblings)
9 siblings, 1 reply; 32+ messages in thread
From: Anand Jain @ 2015-04-30 10:08 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs
Controlled EIO from the device is achieved using the dm device.
Helper functions are at common/dmerror.
Broadly steps will include calling _init_dm_error_dev() with a blk
device as an argument, typically this device can be a device pealed
from the SCRATCH_DEV_POOL, and init_dm_error_dev() will use
this blk device as backing store of dm linear device and assign
DM_ERROR_DEV to /dev/mapper/error-dev, which then can be assigned back
to the SCRATCH_DEV_POOL.
When test script is read to get EIO, the test cases can call
_load_dm_error_table() which then it will load the dm error.
so that reading DM_ERROR_DEV will cause EIO. After the test case is
complete, cleanup must be done by calling _cleanup_dm_error_dev().
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
common/dmerror | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
common/rc | 18 ++++++++++++++++
2 files changed, 83 insertions(+)
create mode 100644 common/dmerror
diff --git a/common/dmerror b/common/dmerror
new file mode 100644
index 0000000..e1f92e6
--- /dev/null
+++ b/common/dmerror
@@ -0,0 +1,65 @@
+##/bin/bash
+#
+# Copyright (c) 2015 Oracle. 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
+#
+#
+# common functions for setting up and tearing down a dmerror device
+
+_init_dm_error_dev()
+{
+ DM_ERROR_DEV=''
+ $DMSETUP_PROG remove error-dev > /dev/null 2>&1
+ DM_BLK_DEV=$1
+ [ -b $DM_BLK_DEV ] || _fatal "$DM_BLK_DEV is not a block device"
+
+ DM_DEV_SIZE=`blockdev --getsz $DM_BLK_DEV`
+ [ $? -ne 0 ] && _fatal "failed to failed to read block dev size"
+
+ LINEAR_TABLE="0 $DM_DEV_SIZE linear $DM_BLK_DEV 0"
+ $DMSETUP_PROG create error-dev --table "$LINEAR_TABLE" || \
+ _fatal "failed to create dm linear device"
+
+ DM_ERROR_DEV='/dev/mapper/error-dev'
+ blockdev --setra 0 $DM_ERROR_DEV
+ [ $? -ne 0 ] && _fatal "failed to failed to setra for $DM_ERROR_DEV"
+}
+
+_cleanup_dm_error_dev()
+{
+ DM_ERROR_DEV=''
+ $DMSETUP_PROG remove error-dev > /dev/null 2>&1
+}
+
+_load_dm_error_table()
+{
+ [ -z $DM_BLK_DEV ] && _fatal "DM_BLK_DEV is not set"
+ [ -z $DM_ERROR_DEV ] && _fatal "DM_ERROR_DEV is not set"
+ [ -z $DM_DEV_SIZE ] && _fatal "DM_DEV_SIZE is not set call init_error_dev first"
+
+ echo 3 > /proc/sys/vm/drop_caches
+ $DMSETUP_PROG suspend error-dev
+ [ $? -ne 0 ] && _fatal "failed to suspend error-dev"
+
+ ERROR_TABLE="0 $DM_DEV_SIZE error $DM_BLK_DEV 0"
+ $DMSETUP_PROG load error-dev --table "$ERROR_TABLE"
+ [ $? -ne 0 ] && _fatal "failed to load table into error-dev"
+
+ $DMSETUP_PROG resume error-dev
+ [ $? -ne 0 ] && _fatal "failed to resume error-dev"
+
+ dd if=$DM_ERROR_DEV of=/dev/null count=1 > /dev/null 2>&1
+ [ $? -ne 0 ] || _fatal "failed to fail IO to $DM_ERROR_DEV"
+}
diff --git a/common/rc b/common/rc
index c5db0dd..2a50491 100644
--- a/common/rc
+++ b/common/rc
@@ -1305,6 +1305,24 @@ _require_block_device()
fi
}
+# this test requires the device mapper error target
+#
+_require_dm_error()
+{
+ DM_BACKSTORE_DEV=$1
+ # require SCRATCH_DEV to be a valid block device
+ _require_block_device $DM_BACKSTORE_DEV
+ _require_command "$DMSETUP_PROG" dmsetup
+
+ $DMSETUP_PROG targets | grep error >/dev/null 2>&1
+ if [ $? -eq 0 ]
+ then
+ :
+ else
+ _notrun "This test requires dm error support"
+ fi
+}
+
# this test requires the device mapper flakey target
#
_require_dm_flakey()
--
2.0.0.153.g79dcccc
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [PATCH 1/3] xfstests: btrfs: add functions to create dm-error device
2015-04-30 10:08 ` [PATCH 1/3] xfstests: btrfs: add functions to create dm-error device Anand Jain
@ 2015-05-04 23:46 ` Dave Chinner
0 siblings, 0 replies; 32+ messages in thread
From: Dave Chinner @ 2015-05-04 23:46 UTC (permalink / raw)
To: Anand Jain; +Cc: fstests, linux-btrfs
On Thu, Apr 30, 2015 at 06:08:45PM +0800, Anand Jain wrote:
> Controlled EIO from the device is achieved using the dm device.
> Helper functions are at common/dmerror.
>
> Broadly steps will include calling _init_dm_error_dev() with a blk
> device as an argument, typically this device can be a device pealed
> from the SCRATCH_DEV_POOL, and init_dm_error_dev() will use
> this blk device as backing store of dm linear device and assign
> DM_ERROR_DEV to /dev/mapper/error-dev, which then can be assigned back
> to the SCRATCH_DEV_POOL.
Don't play games with device pools like this. Create a single error
device from the SCRATCH_DEV, just like the dm-flakey code does. That
way this code can be used by any filesystem.
And like the dmflakey code, build the dm tables at init time so you
don't need all the blockdev variables to built them later on.
> When test script is read to get EIO, the test cases can call
^^^^
ready?
> _load_dm_error_table() which then it will load the dm error.
> so that reading DM_ERROR_DEV will cause EIO. After the test case is
> complete, cleanup must be done by calling _cleanup_dm_error_dev().
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> common/dmerror | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> common/rc | 18 ++++++++++++++++
> 2 files changed, 83 insertions(+)
> create mode 100644 common/dmerror
>
> diff --git a/common/dmerror b/common/dmerror
> new file mode 100644
> index 0000000..e1f92e6
> --- /dev/null
> +++ b/common/dmerror
> @@ -0,0 +1,65 @@
> +##/bin/bash
> +#
> +# Copyright (c) 2015 Oracle. 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
> +#
> +#
> +# common functions for setting up and tearing down a dmerror device
> +
> +_init_dm_error_dev()
> +{
> + DM_ERROR_DEV=''
> + $DMSETUP_PROG remove error-dev > /dev/null 2>&1
> + DM_BLK_DEV=$1
> + [ -b $DM_BLK_DEV ] || _fatal "$DM_BLK_DEV is not a block device"
This has already been checked in the _require function, right?
> + DM_DEV_SIZE=`blockdev --getsz $DM_BLK_DEV`
> + [ $? -ne 0 ] && _fatal "failed to failed to read block dev size"
And so this will never fail.
> + LINEAR_TABLE="0 $DM_DEV_SIZE linear $DM_BLK_DEV 0"
> + $DMSETUP_PROG create error-dev --table "$LINEAR_TABLE" || \
> + _fatal "failed to create dm linear device"
> +
> + DM_ERROR_DEV='/dev/mapper/error-dev'
> + blockdev --setra 0 $DM_ERROR_DEV
> + [ $? -ne 0 ] && _fatal "failed to failed to setra for $DM_ERROR_DEV"
Why are you doing this here, and, FWIW, it can't fail, either.
> +}
> +
> +_cleanup_dm_error_dev()
> +{
> + DM_ERROR_DEV=''
> + $DMSETUP_PROG remove error-dev > /dev/null 2>&1
> +}
> +
> +_load_dm_error_table()
> +{
> + [ -z $DM_BLK_DEV ] && _fatal "DM_BLK_DEV is not set"
> + [ -z $DM_ERROR_DEV ] && _fatal "DM_ERROR_DEV is not set"
> + [ -z $DM_DEV_SIZE ] && _fatal "DM_DEV_SIZE is not set call init_error_dev first"
These are not necessary if the tables are already built.
> +
> + ERROR_TABLE="0 $DM_DEV_SIZE error $DM_BLK_DEV 0"
> + $DMSETUP_PROG load error-dev --table "$ERROR_TABLE"
> + [ $? -ne 0 ] && _fatal "failed to load table into error-dev"
> +
> + $DMSETUP_PROG resume error-dev
> + [ $? -ne 0 ] && _fatal "failed to resume error-dev"
> +
> + dd if=$DM_ERROR_DEV of=/dev/null count=1 > /dev/null 2>&1
> + [ $? -ne 0 ] || _fatal "failed to fail IO to $DM_ERROR_DEV"
There is no need to test the dm-error device like this. If it's not
failing IO, then the caller is going to fail because the filesystem
failed to fail like expected...
> diff --git a/common/rc b/common/rc
> index c5db0dd..2a50491 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -1305,6 +1305,24 @@ _require_block_device()
> fi
> }
>
> +# this test requires the device mapper error target
> +#
> +_require_dm_error()
> +{
> + DM_BACKSTORE_DEV=$1
> + # require SCRATCH_DEV to be a valid block device
> + _require_block_device $DM_BACKSTORE_DEV
> + _require_command "$DMSETUP_PROG" dmsetup
8 space tabs, please, and this function can go in common/dmerror,
too.
> +
> + $DMSETUP_PROG targets | grep error >/dev/null 2>&1
> + if [ $? -eq 0 ]
> + then
> + :
> + else
> + _notrun "This test requires dm error support"
> + fi
if [...]; then
else
fi
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH 2/3] xfstests: btrfs: test device replace, with EIO on the src dev
2015-04-30 10:08 [PATCH 0/3] dm error based test cases Anand Jain
2015-04-30 10:08 ` [PATCH 1/3] xfstests: btrfs: add functions to create dm-error device Anand Jain
@ 2015-04-30 10:08 ` Anand Jain
2015-05-05 0:14 ` Dave Chinner
2015-04-30 10:08 ` [PATCH 3/3] xfstests: btrfs: test device delete with EIO on " Anand Jain
` (7 subsequent siblings)
9 siblings, 1 reply; 32+ messages in thread
From: Anand Jain @ 2015-04-30 10:08 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs
This test case will test to confirm the replace works when
the replacing source device has EIO errors.
EIO condition is achieved using the DM device.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
tests/btrfs/087 | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/087.out | 2 ++
tests/btrfs/group | 1 +
3 files changed, 100 insertions(+)
create mode 100755 tests/btrfs/087
create mode 100644 tests/btrfs/087.out
diff --git a/tests/btrfs/087 b/tests/btrfs/087
new file mode 100755
index 0000000..c2eb16a
--- /dev/null
+++ b/tests/btrfs/087
@@ -0,0 +1,97 @@
+#! /bin/bash
+# FS QA Test No. btrfs/087
+#
+# test device replace works when the source device has EIO
+#
+# Copyright (c) 2015 Oracle. 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
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+rm -f $seqres.full
+
+_cleanup()
+{
+ # remove dm erro-dev from the scratch pool
+ SCRATCH_DEV_POOL=`echo $SCRATCH_DEV_POOL | sed -e "s# *$DM_ERROR_DEV *##"`
+
+ _cleanup_dm_error_dev
+ SCRATCH_DEV_POOL="$SCRATCH_DEV_POOL $DEV_REPLACE_SRC"
+ SCRATCH_DEV_POOL="$SCRATCH_DEV_POOL $DEV_REPLACE_TGT"
+ for i in $SCRATCH_DEV_POOL; do
+ $WIPEFS_PROG -a $i > /dev/null 2>&1
+ done
+ rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/dmerror
+
+_need_to_be_root
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_scratch_dev_pool 4
+_require_command "$WIPEFS_PROG" wipefs
+
+# peal a (last) device from dev pool to be use it as replace target device
+DEV_REPLACE_TGT="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $NF}'`"
+SCRATCH_DEV_POOL=`echo $SCRATCH_DEV_POOL | sed -e "s# *$DEV_REPLACE_TGT *##"`
+
+# create a dmerror device
+# peal the last device in SCRATCH_DEV_POOL and assign it to DM_ERROR_DEV
+DEV_REPLACE_SRC="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $NF}'`"
+SCRATCH_DEV_POOL=`echo $SCRATCH_DEV_POOL | sed -e "s# *$DEV_REPLACE_SRC *##"`
+
+# Create dm linear device /dev/mapper/error-dev using dev_last
+# DM_ERROR_DEV will have dm linear device set if created successfully
+_require_dm_error $DEV_REPLACE_SRC
+_init_dm_error_dev $DEV_REPLACE_SRC
+
+# assign created dm device to the scratch pool
+SCRATCH_DEV_POOL="$SCRATCH_DEV_POOL $DM_ERROR_DEV"
+
+echo DEV_REPLACE_SRC=$DEV_REPLACE_SRC >> $seqres.full
+echo DEV_REPLACE_TGT=$DEV_REPLACE_TGT >> $seqres.full
+echo DM_ERROR_DEV=$DM_ERROR_DEV >> $seqres.full
+echo SCRATCH_DEV_POOL=$SCRATCH_DEV_POOL >> $seqres.full
+
+MKFS_OPTIONS="-m raid1 -d raid1"
+_scratch_pool_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
+_scratch_mount
+
+$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT >> $seqres.full
+
+error_dev_devid=`$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT |\
+ egrep $DM_ERROR_DEV | $AWK_PROG '{print $2}'`
+echo error_dev_devid=$error_dev_devid >> $seqres.full
+
+# now load the error into the DM_ERROR_DEV
+_load_dm_error_table
+
+$BTRFS_UTIL_PROG replace start -B $error_dev_devid $DEV_REPLACE_TGT $SCRATCH_MNT -f ||\
+ _fail "btrfs device replace failed, devid $error_dev_devid"
+
+echo "Silence is golden"
+status=0; exit
diff --git a/tests/btrfs/087.out b/tests/btrfs/087.out
new file mode 100644
index 0000000..e84c64c
--- /dev/null
+++ b/tests/btrfs/087.out
@@ -0,0 +1,2 @@
+QA output created by 087
+Silence is golden
diff --git a/tests/btrfs/group b/tests/btrfs/group
index e9c15af..d66b4fc 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -89,3 +89,4 @@
084 auto quick send
085 auto quick metadata subvol
086 auto quick clone
+087 auto quick replace
--
2.0.0.153.g79dcccc
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [PATCH 2/3] xfstests: btrfs: test device replace, with EIO on the src dev
2015-04-30 10:08 ` [PATCH 2/3] xfstests: btrfs: test device replace, with EIO on the src dev Anand Jain
@ 2015-05-05 0:14 ` Dave Chinner
2015-05-05 15:13 ` Anand Jain
0 siblings, 1 reply; 32+ messages in thread
From: Dave Chinner @ 2015-05-05 0:14 UTC (permalink / raw)
To: Anand Jain; +Cc: fstests, linux-btrfs
On Thu, Apr 30, 2015 at 06:08:46PM +0800, Anand Jain wrote:
> This test case will test to confirm the replace works when
> the replacing source device has EIO errors.
>
> EIO condition is achieved using the DM device.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> tests/btrfs/087 | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> tests/btrfs/087.out | 2 ++
> tests/btrfs/group | 1 +
> 3 files changed, 100 insertions(+)
> create mode 100755 tests/btrfs/087
> create mode 100644 tests/btrfs/087.out
>
> diff --git a/tests/btrfs/087 b/tests/btrfs/087
> new file mode 100755
> index 0000000..c2eb16a
> --- /dev/null
> +++ b/tests/btrfs/087
> @@ -0,0 +1,97 @@
> +#! /bin/bash
> +# FS QA Test No. btrfs/087
> +#
> +# test device replace works when the source device has EIO
> +#
> +# Copyright (c) 2015 Oracle. 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
> +#
> +
> +seq=`basename $0`
> +seqres=$RESULT_DIR/$seq
> +echo "QA output created by $seq"
> +
> +here=`pwd`
> +tmp=/tmp/$$
> +status=1 # failure is the default!
> +trap "_cleanup; exit \$status" 0 1 2 3 15
> +rm -f $seqres.full
> +
> +_cleanup()
> +{
> + # remove dm erro-dev from the scratch pool
> + SCRATCH_DEV_POOL=`echo $SCRATCH_DEV_POOL | sed -e "s# *$DM_ERROR_DEV *##"`
> +
> + _cleanup_dm_error_dev
> + SCRATCH_DEV_POOL="$SCRATCH_DEV_POOL $DEV_REPLACE_SRC"
> + SCRATCH_DEV_POOL="$SCRATCH_DEV_POOL $DEV_REPLACE_TGT"
> + for i in $SCRATCH_DEV_POOL; do
> + $WIPEFS_PROG -a $i > /dev/null 2>&1
> + done
If you need to ensure the devices are clean, then that is an
intialisation job, not a cleanup job. Otherwise the automatic
scratch fs check will fail....
> + rm -f $tmp.*
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +. ./common/dmerror
> +
> +_need_to_be_root
> +_supported_fs btrfs
> +_supported_os Linux
> +_require_scratch
> +_require_scratch_dev_pool 4
> +_require_command "$WIPEFS_PROG" wipefs
> +
> +# peal a (last) device from dev pool to be use it as replace target device
> +DEV_REPLACE_TGT="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $NF}'`"
> +SCRATCH_DEV_POOL=`echo $SCRATCH_DEV_POOL | sed -e "s# *$DEV_REPLACE_TGT *##"`
> +
> +# create a dmerror device
> +# peal the last device in SCRATCH_DEV_POOL and assign it to DM_ERROR_DEV
> +DEV_REPLACE_SRC="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $NF}'`"
> +SCRATCH_DEV_POOL=`echo $SCRATCH_DEV_POOL | sed -e "s# *$DEV_REPLACE_SRC *##"`
>
> +# Create dm linear device /dev/mapper/error-dev using dev_last
> +# DM_ERROR_DEV will have dm linear device set if created successfully
> +_require_dm_error $DEV_REPLACE_SRC
> +_init_dm_error_dev $DEV_REPLACE_SRC
> +
> +# assign created dm device to the scratch pool
> +SCRATCH_DEV_POOL="$SCRATCH_DEV_POOL $DM_ERROR_DEV"
This is a lot of screwing around to modify the device list.
Just make a local copy of the device pool, clear the
SCRATCH_DEV_POOL variable, and pass the local devices to
_scratch_pool_mkfs....
> +
> +echo DEV_REPLACE_SRC=$DEV_REPLACE_SRC >> $seqres.full
> +echo DEV_REPLACE_TGT=$DEV_REPLACE_TGT >> $seqres.full
> +echo DM_ERROR_DEV=$DM_ERROR_DEV >> $seqres.full
> +echo SCRATCH_DEV_POOL=$SCRATCH_DEV_POOL >> $seqres.full
> +
> +MKFS_OPTIONS="-m raid1 -d raid1"
> +_scratch_pool_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
> +_scratch_mount
> +
> +$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT >> $seqres.full
> +
> +error_dev_devid=`$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT |\
> + egrep $DM_ERROR_DEV | $AWK_PROG '{print $2}'`
> +echo error_dev_devid=$error_dev_devid >> $seqres.full
> +
> +# now load the error into the DM_ERROR_DEV
> +_load_dm_error_table
> +
> +$BTRFS_UTIL_PROG replace start -B $error_dev_devid $DEV_REPLACE_TGT $SCRATCH_MNT -f ||\
> + _fail "btrfs device replace failed, devid $error_dev_devid"
You haven't actually done any filesystem operations to trigger a
device error and have the filesystem react to it. before replacing
the device, you need to check that the filesystem doesn't fall over
on error, and that it recovers correctly once the device is
replaced.
> +echo "Silence is golden"
This test should not be silent - A user is running a maintenance
operation, and btrfs needs to be emitting a success of failure
message to the user. The golden output should capture that
message, not use return values to determine if the test failed or
not.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 2/3] xfstests: btrfs: test device replace, with EIO on the src dev
2015-05-05 0:14 ` Dave Chinner
@ 2015-05-05 15:13 ` Anand Jain
2015-05-05 23:11 ` Dave Chinner
0 siblings, 1 reply; 32+ messages in thread
From: Anand Jain @ 2015-05-05 15:13 UTC (permalink / raw)
To: Dave Chinner; +Cc: fstests, linux-btrfs
Dave,
Thanks for comments. I am rewriting it.
But any idea why should _scratch_mkfs_dmerror (below) should
fail with one of the device in SCRATCH_DEV_POOL being busy.?
(when I start the script non of the device provided is actually
busy).
I am showing section of the code below which is relevant
to my question.
----------
+SCRATCH_DEV_POOL_DEV1="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}'`"
+SCRATCH_DEV_POOL_DEV2="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}'`"
+
+_init_dmerror
+_scratch_mkfs_dmerror "-f -d raid1 -m raid1 $SCRATCH_DEV_POOL_DEV1
$SCRATCH_DEV_POOL_DEV2
+_mount_dmerror
+
+local error_dev_devid
+error_dev_devid=`$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT |\
+ egrep $DMERROR_DEV | $AWK_PROG '{print $2}'`
+
+# now load the error into the DM_ERROR_DEV
+_load_dmerror_table
+
+_run_btrfs_util_prog device delete $error_dev_devid $SCRATCH_MNT
+
+_cleanup_dmerror
----------------
+_init_dmerror()
+{
+ $DMSETUP_PROG remove error-test > /dev/null 2>&1
+
+ local BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
+
+ DMERROR_DEV='/dev/mapper/error-test'
+
+ DMLINEAR_TABLE="0 $BLK_DEV_SIZE linear $SCRATCH_DEV 0"
+
+ $DMSETUP_PROG create error-test --table "$DMLINEAR_TABLE" || \
+ _fatal "failed to create dm linear device"
+
+ DMERROR_TABLE="0 $BLK_DEV_SIZE error $SCRATCH_DEV 0"
+}
+
+_scratch_mkfs_dmerror()
+{
+ $MKFS_BTRFS_PROG $* $DMERROR_DEV >> $seqres.full 2>&1 || \
+ _fatal "failed to create mkfs.btrfs $* $DMERROR_DEV"
+}
----------------
Thanks, Anand
On 05/05/2015 08:14 AM, Dave Chinner wrote:
> On Thu, Apr 30, 2015 at 06:08:46PM +0800, Anand Jain wrote:
>> This test case will test to confirm the replace works when
>> the replacing source device has EIO errors.
>>
>> EIO condition is achieved using the DM device.
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>> tests/btrfs/087 | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>> tests/btrfs/087.out | 2 ++
>> tests/btrfs/group | 1 +
>> 3 files changed, 100 insertions(+)
>> create mode 100755 tests/btrfs/087
>> create mode 100644 tests/btrfs/087.out
>>
>> diff --git a/tests/btrfs/087 b/tests/btrfs/087
>> new file mode 100755
>> index 0000000..c2eb16a
>> --- /dev/null
>> +++ b/tests/btrfs/087
>> @@ -0,0 +1,97 @@
>> +#! /bin/bash
>> +# FS QA Test No. btrfs/087
>> +#
>> +# test device replace works when the source device has EIO
>> +#
>> +# Copyright (c) 2015 Oracle. 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
>> +#
>> +
>> +seq=`basename $0`
>> +seqres=$RESULT_DIR/$seq
>> +echo "QA output created by $seq"
>> +
>> +here=`pwd`
>> +tmp=/tmp/$$
>> +status=1 # failure is the default!
>> +trap "_cleanup; exit \$status" 0 1 2 3 15
>> +rm -f $seqres.full
>> +
>> +_cleanup()
>> +{
>> + # remove dm erro-dev from the scratch pool
>> + SCRATCH_DEV_POOL=`echo $SCRATCH_DEV_POOL | sed -e "s# *$DM_ERROR_DEV *##"`
>> +
>> + _cleanup_dm_error_dev
>> + SCRATCH_DEV_POOL="$SCRATCH_DEV_POOL $DEV_REPLACE_SRC"
>> + SCRATCH_DEV_POOL="$SCRATCH_DEV_POOL $DEV_REPLACE_TGT"
>> + for i in $SCRATCH_DEV_POOL; do
>> + $WIPEFS_PROG -a $i > /dev/null 2>&1
>> + done
>
> If you need to ensure the devices are clean, then that is an
> intialisation job, not a cleanup job. Otherwise the automatic
> scratch fs check will fail....
>
>> + rm -f $tmp.*
>> +}
>> +
>> +# get standard environment, filters and checks
>> +. ./common/rc
>> +. ./common/filter
>> +. ./common/dmerror
>> +
>> +_need_to_be_root
>> +_supported_fs btrfs
>> +_supported_os Linux
>> +_require_scratch
>> +_require_scratch_dev_pool 4
>> +_require_command "$WIPEFS_PROG" wipefs
>> +
>> +# peal a (last) device from dev pool to be use it as replace target device
>> +DEV_REPLACE_TGT="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $NF}'`"
>> +SCRATCH_DEV_POOL=`echo $SCRATCH_DEV_POOL | sed -e "s# *$DEV_REPLACE_TGT *##"`
>> +
>> +# create a dmerror device
>> +# peal the last device in SCRATCH_DEV_POOL and assign it to DM_ERROR_DEV
>> +DEV_REPLACE_SRC="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $NF}'`"
>> +SCRATCH_DEV_POOL=`echo $SCRATCH_DEV_POOL | sed -e "s# *$DEV_REPLACE_SRC *##"`
>>
>> +# Create dm linear device /dev/mapper/error-dev using dev_last
>> +# DM_ERROR_DEV will have dm linear device set if created successfully
>> +_require_dm_error $DEV_REPLACE_SRC
>> +_init_dm_error_dev $DEV_REPLACE_SRC
>> +
>> +# assign created dm device to the scratch pool
>> +SCRATCH_DEV_POOL="$SCRATCH_DEV_POOL $DM_ERROR_DEV"
>
> This is a lot of screwing around to modify the device list.
>
> Just make a local copy of the device pool, clear the
> SCRATCH_DEV_POOL variable, and pass the local devices to
> _scratch_pool_mkfs....
>
>> +
>> +echo DEV_REPLACE_SRC=$DEV_REPLACE_SRC >> $seqres.full
>> +echo DEV_REPLACE_TGT=$DEV_REPLACE_TGT >> $seqres.full
>> +echo DM_ERROR_DEV=$DM_ERROR_DEV >> $seqres.full
>> +echo SCRATCH_DEV_POOL=$SCRATCH_DEV_POOL >> $seqres.full
>> +
>> +MKFS_OPTIONS="-m raid1 -d raid1"
>> +_scratch_pool_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
>> +_scratch_mount
>> +
>> +$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT >> $seqres.full
>> +
>> +error_dev_devid=`$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT |\
>> + egrep $DM_ERROR_DEV | $AWK_PROG '{print $2}'`
>> +echo error_dev_devid=$error_dev_devid >> $seqres.full
>> +
>> +# now load the error into the DM_ERROR_DEV
>> +_load_dm_error_table
>> +
>> +$BTRFS_UTIL_PROG replace start -B $error_dev_devid $DEV_REPLACE_TGT $SCRATCH_MNT -f ||\
>> + _fail "btrfs device replace failed, devid $error_dev_devid"
>
> You haven't actually done any filesystem operations to trigger a
> device error and have the filesystem react to it. before replacing
> the device, you need to check that the filesystem doesn't fall over
> on error, and that it recovers correctly once the device is
> replaced.
>
>> +echo "Silence is golden"
>
> This test should not be silent - A user is running a maintenance
> operation, and btrfs needs to be emitting a success of failure
> message to the user. The golden output should capture that
> message, not use return values to determine if the test failed or
> not.
>
> Cheers,
>
> Dave.
>
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 2/3] xfstests: btrfs: test device replace, with EIO on the src dev
2015-05-05 15:13 ` Anand Jain
@ 2015-05-05 23:11 ` Dave Chinner
0 siblings, 0 replies; 32+ messages in thread
From: Dave Chinner @ 2015-05-05 23:11 UTC (permalink / raw)
To: Anand Jain; +Cc: fstests, linux-btrfs
On Tue, May 05, 2015 at 11:13:44PM +0800, Anand Jain wrote:
>
> Dave,
>
> Thanks for comments. I am rewriting it.
>
> But any idea why should _scratch_mkfs_dmerror (below) should
> fail with one of the device in SCRATCH_DEV_POOL being busy.?
> (when I start the script non of the device provided is actually
> busy).
$SCRATCH_DEV is the first device in $SCRATCH_DEV_POOL, right?
> +SCRATCH_DEV_POOL_DEV1="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}'`"
> +SCRATCH_DEV_POOL_DEV2="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}'`"
BTW, don't shout so much in your code: dev1 and dev2 are perfectly
good local variable names. In general, local variables are in lower
case, global/exported variables are in upper case.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH 3/3] xfstests: btrfs: test device delete with EIO on src dev
2015-04-30 10:08 [PATCH 0/3] dm error based test cases Anand Jain
2015-04-30 10:08 ` [PATCH 1/3] xfstests: btrfs: add functions to create dm-error device Anand Jain
2015-04-30 10:08 ` [PATCH 2/3] xfstests: btrfs: test device replace, with EIO on the src dev Anand Jain
@ 2015-04-30 10:08 ` Anand Jain
2015-05-05 19:03 ` [PATCH v2 0/3] dm error based test cases Anand Jain
` (6 subsequent siblings)
9 siblings, 0 replies; 32+ messages in thread
From: Anand Jain @ 2015-04-30 10:08 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs
This test case tests if the device delete would work when
the source device has failed with EIO errors.
EIO errors are achieved usign the DM device.
Also this test needs the latest btrfs-progs and kernel patch
under title
[PATCH] device delete by devid
When this patch is not found in the btrfs-progs, this test
will not run. However when the require patch is not found
in the kernel it will fail gracefully.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
common/rc | 6 ++++
tests/btrfs/088 | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/088.out | 2 ++
tests/btrfs/group | 1 +
4 files changed, 98 insertions(+)
create mode 100755 tests/btrfs/088
create mode 100644 tests/btrfs/088.out
diff --git a/common/rc b/common/rc
index 2a50491..a1df01b 100644
--- a/common/rc
+++ b/common/rc
@@ -2688,6 +2688,12 @@ _require_test_fcntl_advisory_locks()
_notrun "Require fcntl advisory locks support"
}
+_require_btrfs_dev_del_by_devid()
+{
+ $BTRFS_UTIL_PROG device delete --help | egrep devid > /dev/null 2>&1
+ [ $? -eq 0 ] || _notrun "$BTRFS_UTIL_PROG too old (must support 'btrfs device delete <devid> /<mnt>')"
+}
+
_get_total_inode()
{
if [ -z "$1" ]; then
diff --git a/tests/btrfs/088 b/tests/btrfs/088
new file mode 100755
index 0000000..a794352
--- /dev/null
+++ b/tests/btrfs/088
@@ -0,0 +1,89 @@
+#! /bin/bash
+# FS QA Test No. btrfs/088
+#
+# test device delete when the source device has EIO
+#
+# Copyright (c) 2015 Oracle. 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
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+rm -f $seqres.full
+
+_cleanup()
+{
+ SCRATCH_DEV_POOL=`echo $SCRATCH_DEV_POOL | sed -e "s# *$DM_ERROR_DEV *##"`
+ _cleanup_dm_error_dev
+ SCRATCH_DEV_POOL="$SCRATCH_DEV_POOL $DEV_DELETE_SRC"
+ for i in $SCRATCH_DEV_POOL; do
+ $WIPEFS_PROG -a $i > /dev/null 2>&1
+ done
+ rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/dmerror
+
+_need_to_be_root
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_scratch_dev_pool 3
+_require_command "$WIPEFS_PROG" wipefs
+_require_btrfs_dev_del_by_devid
+
+# peal the last device in SCRATCH_DEV_POOL and assign it to DEV_DELETE_SRC
+DEV_DELETE_SRC="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $NF}'`"
+SCRATCH_DEV_POOL=`echo $SCRATCH_DEV_POOL | sed -e "s# *$DEV_DELETE_SRC *##"`
+
+# Create dm linear device /dev/mapper/error-dev using DEV_DELETE_SRC
+# DM_ERROR_DEV will have dm linear device set if created successfully
+_require_dm_error $DEV_REPLACE_SRC
+_init_dm_error_dev $DEV_DELETE_SRC
+
+# assign created dm device to the scratch pool
+SCRATCH_DEV_POOL="$SCRATCH_DEV_POOL $DM_ERROR_DEV"
+
+echo DEV_DELETE_SRC=$DEV_DELETE_SRC >> $seqres.full
+echo DM_ERROR_DEV=$DM_ERROR_DEV >> $seqres.full
+echo SCRATCH_DEV_POOL=$SCRATCH_DEV_POOL >> $seqres.full
+
+MKFS_OPTIONS="-m raid1 -d raid1"
+_scratch_pool_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
+_scratch_mount
+
+$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT >> $seqres.full
+
+error_dev_devid=`$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT |\
+ egrep $DM_ERROR_DEV | $AWK_PROG '{print $2}'`
+echo error_dev_devid=$error_dev_devid >> $seqres.full
+
+# now load the error into the DM_ERROR_DEV
+_load_dm_error_table
+
+$BTRFS_UTIL_PROG device delete $error_dev_devid $DEV_REPLACE_TGT $SCRATCH_MNT ||\
+ _fail "btrfs device delete failed, errno $errno, ret $?, devid $error_dev_devid"
+
+echo "Silence is golden"
+status=0; exit
diff --git a/tests/btrfs/088.out b/tests/btrfs/088.out
new file mode 100644
index 0000000..c24480a
--- /dev/null
+++ b/tests/btrfs/088.out
@@ -0,0 +1,2 @@
+QA output created by 088
+Silence is golden
diff --git a/tests/btrfs/group b/tests/btrfs/group
index d66b4fc..d474c47 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -90,3 +90,4 @@
085 auto quick metadata subvol
086 auto quick clone
087 auto quick replace
+088 auto quick replace
--
2.0.0.153.g79dcccc
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v2 0/3] dm error based test cases
2015-04-30 10:08 [PATCH 0/3] dm error based test cases Anand Jain
` (2 preceding siblings ...)
2015-04-30 10:08 ` [PATCH 3/3] xfstests: btrfs: test device delete with EIO on " Anand Jain
@ 2015-05-05 19:03 ` Anand Jain
2015-05-05 19:03 ` [PATCH v2 1/3] xfstests: btrfs: add functions to create dm-error device Anand Jain
` (2 more replies)
2015-05-11 13:49 ` [PATCH v3 0/3] dm error based test cases Anand Jain
` (5 subsequent siblings)
9 siblings, 3 replies; 32+ messages in thread
From: Anand Jain @ 2015-05-05 19:03 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs, david
Most likely user would replace or delete the device when
there is a problem about it.
We want to test this condition by using the dm error target which
will help to create the EIO when needed.
Basically first create the linear device and then load the error
table to get the EIO when needed.
The fist patch will provide the helper dm functions to create such
a test case using dm error device.
2nd and 3rd patch uses it to test the device replace and delete,
respectively. Note that device delete will need kernel and progs
patch, which when not there tests will gracefully fail and
will not run respectively.
v1->v2: accepts Dave Chinner's review comments, thanks.
Anand Jain (3):
xfstests: btrfs: add functions to create dm-error device
xfstests: btrfs: test device replace, with EIO on the src dev
xfstests: btrfs: test device delete with EIO on src dev
common/dmerror | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++
common/rc | 21 ++++++++++++++++
tests/btrfs/087 | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/087.out | 2 ++
tests/btrfs/088 | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/088.out | 2 ++
tests/btrfs/group | 2 ++
7 files changed, 237 insertions(+)
create mode 100644 common/dmerror
create mode 100755 tests/btrfs/087
create mode 100644 tests/btrfs/087.out
create mode 100755 tests/btrfs/088
create mode 100644 tests/btrfs/088.out
--
2.0.0.153.g79dcccc
^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH v2 1/3] xfstests: btrfs: add functions to create dm-error device
2015-05-05 19:03 ` [PATCH v2 0/3] dm error based test cases Anand Jain
@ 2015-05-05 19:03 ` Anand Jain
2015-05-05 22:22 ` [PATCH v2.1 " Anand Jain
2015-05-05 19:03 ` [PATCH v2 2/3] xfstests: btrfs: test device replace, with EIO on the src dev Anand Jain
2015-05-05 19:03 ` [PATCH v2 3/3] xfstests: btrfs: test device delete with EIO on " Anand Jain
2 siblings, 1 reply; 32+ messages in thread
From: Anand Jain @ 2015-05-05 19:03 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs, david
Controlled EIO from the device is achieved using the dm device.
Helper functions are at common/dmerror.
Broadly steps will include calling _init_dmerror().
_init_dmerror() will use SCRATCH_DEV to create dm linear device and assign
DMERROR_DEV to /dev/mapper/error-test.
When test script is read to get EIO, the test cases can call
_load_dmerror_table() which then it will load the dm error.
so that reading DMERROR_DEV will cause EIO. After the test case is
complete, cleanup must be done by calling _cleanup_dmerror().
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v1->v2: accepts Dave Chinner's review comments, thanks
common/dmerror | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
common/rc | 15 +++++++++++++
2 files changed, 84 insertions(+)
create mode 100644 common/dmerror
diff --git a/common/dmerror b/common/dmerror
new file mode 100644
index 0000000..f895d90
--- /dev/null
+++ b/common/dmerror
@@ -0,0 +1,69 @@
+##/bin/bash
+#
+# Copyright (c) 2015 Oracle. 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
+#
+#
+# common functions for setting up and tearing down a dmerror device
+
+_init_dmerror()
+{
+ $DMSETUP_PROG remove error-test > /dev/null 2>&1
+
+ local BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
+
+ DMERROR_DEV='/dev/mapper/error-test'
+
+ DMLINEAR_TABLE="0 $BLK_DEV_SIZE linear $SCRATCH_DEV 0"
+
+ $DMSETUP_PROG create error-test --table "$DMLINEAR_TABLE" || \
+ _fatal "failed to create dm linear device"
+
+ DMERROR_TABLE="0 $BLK_DEV_SIZE error $SCRATCH_DEV 0"
+}
+
+_scratch_mkfs_dmerror()
+{
+ $MKFS_BTRFS_PROG $* $DMERROR_DEV >> $seqres.full 2>&1 || \
+ _fatal "failed to create mkfs.btrfs $* $DMERROR_DEV"
+}
+
+_mount_dmerror()
+{
+ mount -t $FSTYP $MOUNT_OPTIONS $DMERROR_DEV $SCRATCH_MNT
+}
+
+_unmount_dmerror()
+{
+ $UMOUNT_PROGS $SCRATCH_MNT
+}
+
+_cleanup_dmerror()
+{
+ $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1
+ $DMSETUP_PROG remove error-test > /dev/null 2>&1
+}
+
+_load_dmerror_table()
+{
+ $DMSETUP_PROG suspend error-test
+ [ $? -ne 0 ] && _fatal "failed to suspend error-test"
+
+ $DMSETUP_PROG load error-test --table "$DMERROR_TABLE"
+ [ $? -ne 0 ] && _fatal "failed to load error table error-test"
+
+ $DMSETUP_PROG resume error-test
+ [ $? -ne 0 ] && _fatal "failed to resume error-test"
+}
diff --git a/common/rc b/common/rc
index c5db0dd..447ab7f 100644
--- a/common/rc
+++ b/common/rc
@@ -1305,6 +1305,21 @@ _require_block_device()
fi
}
+# this test requires the device mapper error target
+#
+_require_dmerror()
+{
+ _require_command "$DMSETUP_PROG" dmsetup
+
+ $DMSETUP_PROG targets | grep error >/dev/null 2>&1
+ if [ $? -eq 0 ]
+ then
+ :
+ else
+ _notrun "This test requires dm error support"
+ fi
+}
+
# this test requires the device mapper flakey target
#
_require_dm_flakey()
--
2.0.0.153.g79dcccc
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v2.1 1/3] xfstests: btrfs: add functions to create dm-error device
2015-05-05 19:03 ` [PATCH v2 1/3] xfstests: btrfs: add functions to create dm-error device Anand Jain
@ 2015-05-05 22:22 ` Anand Jain
0 siblings, 0 replies; 32+ messages in thread
From: Anand Jain @ 2015-05-05 22:22 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs, david
From: Anand Jain <Anand.Jain@oracle.com>
Controlled EIO from the device is achieved using the dm device.
Helper functions are at common/dmerror.
Broadly steps will include calling _init_dmerror().
_init_dmerror() will use SCRATCH_DEV to create dm linear device and assign
DMERROR_DEV to /dev/mapper/error-test.
When test script is ready to get EIO, the test cases can call
_load_dmerror_table() which then it will load the dm error.
so that reading DMERROR_DEV will cause EIO. After the test case is
complete, cleanup must be done by calling _cleanup_dmerror().
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v2->v2.1: fixed missed typo error fixup in the commit.
v1->v2: accepts Dave Chinner's review comments, thanks
common/dmerror | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
common/rc | 15 +++++++++++++
2 files changed, 84 insertions(+)
create mode 100644 common/dmerror
diff --git a/common/dmerror b/common/dmerror
new file mode 100644
index 0000000..f895d90
--- /dev/null
+++ b/common/dmerror
@@ -0,0 +1,69 @@
+##/bin/bash
+#
+# Copyright (c) 2015 Oracle. 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
+#
+#
+# common functions for setting up and tearing down a dmerror device
+
+_init_dmerror()
+{
+ $DMSETUP_PROG remove error-test > /dev/null 2>&1
+
+ local BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
+
+ DMERROR_DEV='/dev/mapper/error-test'
+
+ DMLINEAR_TABLE="0 $BLK_DEV_SIZE linear $SCRATCH_DEV 0"
+
+ $DMSETUP_PROG create error-test --table "$DMLINEAR_TABLE" || \
+ _fatal "failed to create dm linear device"
+
+ DMERROR_TABLE="0 $BLK_DEV_SIZE error $SCRATCH_DEV 0"
+}
+
+_scratch_mkfs_dmerror()
+{
+ $MKFS_BTRFS_PROG $* $DMERROR_DEV >> $seqres.full 2>&1 || \
+ _fatal "failed to create mkfs.btrfs $* $DMERROR_DEV"
+}
+
+_mount_dmerror()
+{
+ mount -t $FSTYP $MOUNT_OPTIONS $DMERROR_DEV $SCRATCH_MNT
+}
+
+_unmount_dmerror()
+{
+ $UMOUNT_PROGS $SCRATCH_MNT
+}
+
+_cleanup_dmerror()
+{
+ $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1
+ $DMSETUP_PROG remove error-test > /dev/null 2>&1
+}
+
+_load_dmerror_table()
+{
+ $DMSETUP_PROG suspend error-test
+ [ $? -ne 0 ] && _fatal "failed to suspend error-test"
+
+ $DMSETUP_PROG load error-test --table "$DMERROR_TABLE"
+ [ $? -ne 0 ] && _fatal "failed to load error table error-test"
+
+ $DMSETUP_PROG resume error-test
+ [ $? -ne 0 ] && _fatal "failed to resume error-test"
+}
diff --git a/common/rc b/common/rc
index c5db0dd..447ab7f 100644
--- a/common/rc
+++ b/common/rc
@@ -1305,6 +1305,21 @@ _require_block_device()
fi
}
+# this test requires the device mapper error target
+#
+_require_dmerror()
+{
+ _require_command "$DMSETUP_PROG" dmsetup
+
+ $DMSETUP_PROG targets | grep error >/dev/null 2>&1
+ if [ $? -eq 0 ]
+ then
+ :
+ else
+ _notrun "This test requires dm error support"
+ fi
+}
+
# this test requires the device mapper flakey target
#
_require_dm_flakey()
--
2.0.0.153.g79dcccc
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v2 2/3] xfstests: btrfs: test device replace, with EIO on the src dev
2015-05-05 19:03 ` [PATCH v2 0/3] dm error based test cases Anand Jain
2015-05-05 19:03 ` [PATCH v2 1/3] xfstests: btrfs: add functions to create dm-error device Anand Jain
@ 2015-05-05 19:03 ` Anand Jain
2015-05-06 8:54 ` Filipe David Manana
2015-05-05 19:03 ` [PATCH v2 3/3] xfstests: btrfs: test device delete with EIO on " Anand Jain
2 siblings, 1 reply; 32+ messages in thread
From: Anand Jain @ 2015-05-05 19:03 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs, david
This test case will test to confirm the replace works when
the replacing source device has EIO errors.
EIO condition is achieved using the DM device.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v1->v2: accepts Dave Chinner's review comments
tests/btrfs/087 | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/087.out | 2 ++
tests/btrfs/group | 1 +
3 files changed, 73 insertions(+)
create mode 100755 tests/btrfs/087
create mode 100644 tests/btrfs/087.out
diff --git a/tests/btrfs/087 b/tests/btrfs/087
new file mode 100755
index 0000000..01b8aec
--- /dev/null
+++ b/tests/btrfs/087
@@ -0,0 +1,70 @@
+#! /bin/bash
+# FS QA Test No. btrfs/087
+#
+#test device replace works when the source device has EIO
+#
+# Copyright (c) 2015 Oracle. 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
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+
+_cleanup()
+{
+ _cleanup_dmerror
+ rm -f $tmp
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/dmerror
+
+_supported_fs btrfs
+_supported_os Linux
+_need_to_be_root
+_require_scratch_dev_pool 3
+_require_dmerror
+
+rm -f $seqres.full
+
+dev1="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}'`"
+dev2="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $3}'`"
+
+_init_dmerror
+_scratch_mkfs_dmerror "-f -d raid1 -m raid1 $dev1"
+_mount_dmerror
+
+#$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | _filter_btrfs_filesystem_show
+
+error_devid=`$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT |\
+ egrep $DMERROR_DEV | $AWK_PROG '{print $2}'`
+
+# now load the error into the DMERROR_DEV
+_load_dmerror_table
+
+_run_btrfs_util_prog replace start -B $error_devid $dev2 $SCRATCH_MNT
+
+echo "Silence is golden"
+status=0; exit
diff --git a/tests/btrfs/087.out b/tests/btrfs/087.out
new file mode 100644
index 0000000..e84c64c
--- /dev/null
+++ b/tests/btrfs/087.out
@@ -0,0 +1,2 @@
+QA output created by 087
+Silence is golden
diff --git a/tests/btrfs/group b/tests/btrfs/group
index e9c15af..d66b4fc 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -89,3 +89,4 @@
084 auto quick send
085 auto quick metadata subvol
086 auto quick clone
+087 auto quick replace
--
2.0.0.153.g79dcccc
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [PATCH v2 2/3] xfstests: btrfs: test device replace, with EIO on the src dev
2015-05-05 19:03 ` [PATCH v2 2/3] xfstests: btrfs: test device replace, with EIO on the src dev Anand Jain
@ 2015-05-06 8:54 ` Filipe David Manana
0 siblings, 0 replies; 32+ messages in thread
From: Filipe David Manana @ 2015-05-06 8:54 UTC (permalink / raw)
To: Anand Jain; +Cc: fstests, linux-btrfs@vger.kernel.org, Dave Chinner
On Tue, May 5, 2015 at 8:03 PM, Anand Jain <anand.jain@oracle.com> wrote:
> This test case will test to confirm the replace works when
> the replacing source device has EIO errors.
>
> EIO condition is achieved using the DM device.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> v1->v2: accepts Dave Chinner's review comments
>
> tests/btrfs/087 | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> tests/btrfs/087.out | 2 ++
> tests/btrfs/group | 1 +
> 3 files changed, 73 insertions(+)
> create mode 100755 tests/btrfs/087
> create mode 100644 tests/btrfs/087.out
>
> diff --git a/tests/btrfs/087 b/tests/btrfs/087
> new file mode 100755
> index 0000000..01b8aec
> --- /dev/null
> +++ b/tests/btrfs/087
> @@ -0,0 +1,70 @@
> +#! /bin/bash
> +# FS QA Test No. btrfs/087
> +#
> +#test device replace works when the source device has EIO
> +#
> +# Copyright (c) 2015 Oracle. 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
> +#
> +
> +seq=`basename $0`
> +seqres=$RESULT_DIR/$seq
> +echo "QA output created by $seq"
> +
> +here=`pwd`
> +tmp=/tmp/$$
> +
> +status=1 # failure is the default!
> +trap "_cleanup; exit \$status" 0 1 2 3 15
> +
> +
> +_cleanup()
> +{
> + _cleanup_dmerror
> + rm -f $tmp
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +. ./common/dmerror
> +
> +_supported_fs btrfs
> +_supported_os Linux
> +_need_to_be_root
> +_require_scratch_dev_pool 3
> +_require_dmerror
> +
> +rm -f $seqres.full
> +
> +dev1="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}'`"
> +dev2="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $3}'`"
> +
> +_init_dmerror
> +_scratch_mkfs_dmerror "-f -d raid1 -m raid1 $dev1"
> +_mount_dmerror
> +
> +#$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | _filter_btrfs_filesystem_show
> +
> +error_devid=`$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT |\
> + egrep $DMERROR_DEV | $AWK_PROG '{print $2}'`
> +
> +# now load the error into the DMERROR_DEV
> +_load_dmerror_table
> +
> +_run_btrfs_util_prog replace start -B $error_devid $dev2 $SCRATCH_MNT
Can we make this more interesting/useful by having a non-empty fs
before exercising the replace?
For e.g. fsstress with a bunch snapshots:
snapshot_cmd="$BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT"
snapshot_cmd="$snapshot_cmd $SCRATCH_MNT/snap_\`date +'%H_%M_%S_%N'\`"
$FSSTRESS_PROG -d $SCRATCH_MNT -n 200 -p 8 $FSSTRESS_AVOID -x
"$snapshot_cmd" -X 50
Same observation for your other test in this patch series.
thanks
> +
> +echo "Silence is golden"
> +status=0; exit
> diff --git a/tests/btrfs/087.out b/tests/btrfs/087.out
> new file mode 100644
> index 0000000..e84c64c
> --- /dev/null
> +++ b/tests/btrfs/087.out
> @@ -0,0 +1,2 @@
> +QA output created by 087
> +Silence is golden
> diff --git a/tests/btrfs/group b/tests/btrfs/group
> index e9c15af..d66b4fc 100644
> --- a/tests/btrfs/group
> +++ b/tests/btrfs/group
> @@ -89,3 +89,4 @@
> 084 auto quick send
> 085 auto quick metadata subvol
> 086 auto quick clone
> +087 auto quick replace
> --
> 2.0.0.153.g79dcccc
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Filipe David Manana,
"Reasonable men adapt themselves to the world.
Unreasonable men adapt the world to themselves.
That's why all progress depends on unreasonable men."
^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH v2 3/3] xfstests: btrfs: test device delete with EIO on src dev
2015-05-05 19:03 ` [PATCH v2 0/3] dm error based test cases Anand Jain
2015-05-05 19:03 ` [PATCH v2 1/3] xfstests: btrfs: add functions to create dm-error device Anand Jain
2015-05-05 19:03 ` [PATCH v2 2/3] xfstests: btrfs: test device replace, with EIO on the src dev Anand Jain
@ 2015-05-05 19:03 ` Anand Jain
2015-08-07 10:31 ` Filipe David Manana
2 siblings, 1 reply; 32+ messages in thread
From: Anand Jain @ 2015-05-05 19:03 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs, david
This test case tests if the device delete would work when
the source device has failed with EIO errors.
EIO errors are achieved usign the DM device.
Also this test needs the latest btrfs-progs and kernel patch
under title
[PATCH] device delete by devid
When this patch is not found in the btrfs-progs, this test
will not run. However when the require patch is not found
in the kernel it will fail gracefully.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v1->v2: accepts Dave Chinner's review comments, thanks
common/rc | 6 +++++
tests/btrfs/088 | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/088.out | 2 ++
tests/btrfs/group | 1 +
4 files changed, 80 insertions(+)
create mode 100755 tests/btrfs/088
create mode 100644 tests/btrfs/088.out
diff --git a/common/rc b/common/rc
index 447ab7f..aca7a62 100644
--- a/common/rc
+++ b/common/rc
@@ -2685,6 +2685,12 @@ _require_test_fcntl_advisory_locks()
_notrun "Require fcntl advisory locks support"
}
+_require_btrfs_dev_del_by_devid()
+{
+ $BTRFS_UTIL_PROG device delete --help | egrep devid > /dev/null 2>&1
+ [ $? -eq 0 ] || _notrun "$BTRFS_UTIL_PROG too old (must support 'btrfs device delete <devid> /<mnt>')"
+}
+
_get_total_inode()
{
if [ -z "$1" ]; then
diff --git a/tests/btrfs/088 b/tests/btrfs/088
new file mode 100755
index 0000000..87814ec
--- /dev/null
+++ b/tests/btrfs/088
@@ -0,0 +1,71 @@
+#! /bin/bash
+# FS QA Test No. btrfs/088
+#
+# test device delete when the source device has EIO
+#
+# Copyright (c) 2015 Oracle. 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
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+
+_cleanup()
+{
+ _cleanup_dmerror
+ rm -f $tmp
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/dmerror
+
+_supported_fs btrfs
+_supported_os Linux
+_need_to_be_root
+_require_scratch_dev_pool 3
+_require_btrfs_dev_del_by_devid
+_require_dmerror
+
+rm -f $seqres.full
+
+dev1="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}'`"
+dev2="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $3}'`"
+
+_init_dmerror
+_scratch_mkfs_dmerror "-f -d raid1 -m raid1 $dev1 $dev2"
+_mount_dmerror
+
+#$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | _filter_btrfs_filesystem_show
+
+error_devid=`$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT |\
+ egrep $DMERROR_DEV | $AWK_PROG '{print $2}'`
+
+# now load the error into the DMERROR_DEV
+_load_dmerror_table
+
+_run_btrfs_util_prog device delete $error_devid $SCRATCH_MNT
+
+echo "Silence is golden"
+status=0; exit
diff --git a/tests/btrfs/088.out b/tests/btrfs/088.out
new file mode 100644
index 0000000..c24480a
--- /dev/null
+++ b/tests/btrfs/088.out
@@ -0,0 +1,2 @@
+QA output created by 088
+Silence is golden
diff --git a/tests/btrfs/group b/tests/btrfs/group
index d66b4fc..d474c47 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -90,3 +90,4 @@
085 auto quick metadata subvol
086 auto quick clone
087 auto quick replace
+088 auto quick replace
--
2.0.0.153.g79dcccc
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [PATCH v2 3/3] xfstests: btrfs: test device delete with EIO on src dev
2015-05-05 19:03 ` [PATCH v2 3/3] xfstests: btrfs: test device delete with EIO on " Anand Jain
@ 2015-08-07 10:31 ` Filipe David Manana
2015-08-13 14:35 ` Anand Jain
0 siblings, 1 reply; 32+ messages in thread
From: Filipe David Manana @ 2015-08-07 10:31 UTC (permalink / raw)
To: Anand Jain; +Cc: fstests, linux-btrfs@vger.kernel.org, Dave Chinner
On Tue, May 5, 2015 at 8:03 PM, Anand Jain <anand.jain@oracle.com> wrote:
> This test case tests if the device delete would work when
> the source device has failed with EIO errors.
>
> EIO errors are achieved usign the DM device.
>
> Also this test needs the latest btrfs-progs and kernel patch
Not patch, but patch set instead. I was looking for a patch with that
title and didn't found any, only a cover letter with the subject:
"[PATCH 0/8 v2] device delete by devid".
> under title
> [PATCH] device delete by devid
>
> When this patch is not found in the btrfs-progs, this test
> will not run. However when the require patch is not found
> in the kernel it will fail gracefully.
What's the status of these patches (both kernel and btrfs-progs)? I've
noticed they've been around since april and no feedback on the mailing
list.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> v1->v2: accepts Dave Chinner's review comments, thanks
>
> common/rc | 6 +++++
> tests/btrfs/088 | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> tests/btrfs/088.out | 2 ++
> tests/btrfs/group | 1 +
> 4 files changed, 80 insertions(+)
> create mode 100755 tests/btrfs/088
> create mode 100644 tests/btrfs/088.out
>
> diff --git a/common/rc b/common/rc
> index 447ab7f..aca7a62 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -2685,6 +2685,12 @@ _require_test_fcntl_advisory_locks()
> _notrun "Require fcntl advisory locks support"
> }
>
> +_require_btrfs_dev_del_by_devid()
> +{
> + $BTRFS_UTIL_PROG device delete --help | egrep devid > /dev/null 2>&1
> + [ $? -eq 0 ] || _notrun "$BTRFS_UTIL_PROG too old (must support 'btrfs device delete <devid> /<mnt>')"
> +}
> +
> _get_total_inode()
> {
> if [ -z "$1" ]; then
> diff --git a/tests/btrfs/088 b/tests/btrfs/088
> new file mode 100755
> index 0000000..87814ec
> --- /dev/null
> +++ b/tests/btrfs/088
> @@ -0,0 +1,71 @@
> +#! /bin/bash
> +# FS QA Test No. btrfs/088
> +#
> +# test device delete when the source device has EIO
> +#
> +# Copyright (c) 2015 Oracle. 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
> +#
> +
> +seq=`basename $0`
> +seqres=$RESULT_DIR/$seq
> +echo "QA output created by $seq"
> +
> +here=`pwd`
> +tmp=/tmp/$$
> +
> +status=1 # failure is the default!
> +trap "_cleanup; exit \$status" 0 1 2 3 15
> +
> +
> +_cleanup()
> +{
> + _cleanup_dmerror
> + rm -f $tmp
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +. ./common/dmerror
> +
> +_supported_fs btrfs
> +_supported_os Linux
> +_need_to_be_root
> +_require_scratch_dev_pool 3
> +_require_btrfs_dev_del_by_devid
> +_require_dmerror
> +
> +rm -f $seqres.full
> +
> +dev1="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}'`"
> +dev2="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $3}'`"
> +
> +_init_dmerror
> +_scratch_mkfs_dmerror "-f -d raid1 -m raid1 $dev1 $dev2"
> +_mount_dmerror
> +
> +#$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | _filter_btrfs_filesystem_show
> +
> +error_devid=`$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT |\
> + egrep $DMERROR_DEV | $AWK_PROG '{print $2}'`
Any reason to not run here fsstress like the test from patch 2? Doing
the device delete with a non-empty fs is a lot more interesting and
can help find bugs and regressions in the future.
> +
> +# now load the error into the DMERROR_DEV
> +_load_dmerror_table
> +
> +_run_btrfs_util_prog device delete $error_devid $SCRATCH_MNT
> +
> +echo "Silence is golden"
> +status=0; exit
> diff --git a/tests/btrfs/088.out b/tests/btrfs/088.out
> new file mode 100644
> index 0000000..c24480a
> --- /dev/null
> +++ b/tests/btrfs/088.out
> @@ -0,0 +1,2 @@
> +QA output created by 088
> +Silence is golden
> diff --git a/tests/btrfs/group b/tests/btrfs/group
> index d66b4fc..d474c47 100644
> --- a/tests/btrfs/group
> +++ b/tests/btrfs/group
> @@ -90,3 +90,4 @@
> 085 auto quick metadata subvol
> 086 auto quick clone
> 087 auto quick replace
> +088 auto quick replace
> --
> 2.0.0.153.g79dcccc
>
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Filipe David Manana,
"Reasonable men adapt themselves to the world.
Unreasonable men adapt the world to themselves.
That's why all progress depends on unreasonable men."
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v2 3/3] xfstests: btrfs: test device delete with EIO on src dev
2015-08-07 10:31 ` Filipe David Manana
@ 2015-08-13 14:35 ` Anand Jain
0 siblings, 0 replies; 32+ messages in thread
From: Anand Jain @ 2015-08-13 14:35 UTC (permalink / raw)
To: fdmanana; +Cc: fstests, linux-btrfs@vger.kernel.org, Dave Chinner
Hi Filipe,
> Any reason to not run here fsstress like the test from patch 2? Doing
> the device delete with a non-empty fs is a lot more interesting and
> can help find bugs and regressions in the future.
You are reviewing v2. fsstress was added in v4.
>> Also this test needs the latest btrfs-progs and kernel patch
>
> Not patch, but patch set instead. I was looking for a patch with that
> title and didn't found any, only a cover letter with the subject:
> "[PATCH 0/8 v2] device delete by devid".
>
>> under title
>> [PATCH] device delete by devid
will update comments.
>> When this patch is not found in the btrfs-progs, this test
>> will not run. However when the require patch is not found
>> in the kernel it will fail gracefully.
>
> What's the status of these patches (both kernel and btrfs-progs)? I've
> noticed they've been around since april and no feedback on the mailing
> list.
Thanks, Anand
^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH v3 0/3] dm error based test cases
2015-04-30 10:08 [PATCH 0/3] dm error based test cases Anand Jain
` (3 preceding siblings ...)
2015-05-05 19:03 ` [PATCH v2 0/3] dm error based test cases Anand Jain
@ 2015-05-11 13:49 ` Anand Jain
2015-05-11 13:49 ` [PATCH v3 1/3] xfstests: btrfs: add functions to create dm-error device Anand Jain
` (4 subsequent siblings)
9 siblings, 0 replies; 32+ messages in thread
From: Anand Jain @ 2015-05-11 13:49 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs, david, fdmanana
Most likely user would replace or delete the device when
there is a problem about it.
We want to test this condition by using the dm error target which
will help to create the EIO when needed.
Basically first create the linear device and then load the error
table to get the EIO when needed.
The fist patch will provide the helper dm functions to create such
a test case using dm error device.
2nd and 3rd patch uses it to test the device replace and delete,
respectively. Note that device delete will need kernel and progs
patch, which when not there tests will gracefully fail and
will not run respectively.
v2->v3: accepts Filipe Manana's review comments, thanks.
v1->v2: accepts Dave Chinner's review comments, thanks.
Anand Jain (3):
xfstests: btrfs: add functions to create dm-error device
xfstests: btrfs: test device replace, with EIO on the src dev
xfstests: btrfs: test device delete with EIO on src dev
common/dmerror | 69 +++++++++++++++++++++++++++++++++++++++++++++
common/rc | 21 ++++++++++++++
tests/btrfs/087 | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/087.out | 10 ++++++
tests/btrfs/088 | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/088.out | 10 ++++++
tests/btrfs/group | 2 +
7 files changed, 265 insertions(+), 0 deletions(-)
create mode 100644 common/dmerror
create mode 100755 tests/btrfs/087
create mode 100644 tests/btrfs/087.out
create mode 100755 tests/btrfs/088
create mode 100644 tests/btrfs/088.out
^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH v3 1/3] xfstests: btrfs: add functions to create dm-error device
2015-04-30 10:08 [PATCH 0/3] dm error based test cases Anand Jain
` (4 preceding siblings ...)
2015-05-11 13:49 ` [PATCH v3 0/3] dm error based test cases Anand Jain
@ 2015-05-11 13:49 ` Anand Jain
2015-05-11 13:49 ` [PATCH v3 2/3] xfstests: btrfs: test device replace, with EIO on the src dev Anand Jain
` (3 subsequent siblings)
9 siblings, 0 replies; 32+ messages in thread
From: Anand Jain @ 2015-05-11 13:49 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs, david, fdmanana
From: Anand Jain <Anand.Jain@oracle.com>
Controlled EIO from the device is achieved using the dm device.
Helper functions are at common/dmerror.
Broadly steps will include calling _init_dmerror().
_init_dmerror() will use SCRATCH_DEV to create dm linear device and assign
DMERROR_DEV to /dev/mapper/error-test.
When test script is ready to get EIO, the test cases can call
_load_dmerror_table() which then it will load the dm error.
so that reading DMERROR_DEV will cause EIO. After the test case is
complete, cleanup must be done by calling _cleanup_dmerror().
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v2.1->v3: accepts Filipe Manana's review comments, thanks
v2->v2.1: fixed missed typo error fixup in the commit.
v1->v2: accepts Dave Chinner's review comments, thanks
common/dmerror | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
common/rc | 15 ++++++++++++
2 files changed, 84 insertions(+), 0 deletions(-)
create mode 100644 common/dmerror
diff --git a/common/dmerror b/common/dmerror
new file mode 100644
index 0000000..f895d90
--- /dev/null
+++ b/common/dmerror
@@ -0,0 +1,69 @@
+##/bin/bash
+#
+# Copyright (c) 2015 Oracle. 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
+#
+#
+# common functions for setting up and tearing down a dmerror device
+
+_init_dmerror()
+{
+ $DMSETUP_PROG remove error-test > /dev/null 2>&1
+
+ local BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
+
+ DMERROR_DEV='/dev/mapper/error-test'
+
+ DMLINEAR_TABLE="0 $BLK_DEV_SIZE linear $SCRATCH_DEV 0"
+
+ $DMSETUP_PROG create error-test --table "$DMLINEAR_TABLE" || \
+ _fatal "failed to create dm linear device"
+
+ DMERROR_TABLE="0 $BLK_DEV_SIZE error $SCRATCH_DEV 0"
+}
+
+_scratch_mkfs_dmerror()
+{
+ $MKFS_BTRFS_PROG $* $DMERROR_DEV >> $seqres.full 2>&1 || \
+ _fatal "failed to create mkfs.btrfs $* $DMERROR_DEV"
+}
+
+_mount_dmerror()
+{
+ mount -t $FSTYP $MOUNT_OPTIONS $DMERROR_DEV $SCRATCH_MNT
+}
+
+_unmount_dmerror()
+{
+ $UMOUNT_PROGS $SCRATCH_MNT
+}
+
+_cleanup_dmerror()
+{
+ $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1
+ $DMSETUP_PROG remove error-test > /dev/null 2>&1
+}
+
+_load_dmerror_table()
+{
+ $DMSETUP_PROG suspend error-test
+ [ $? -ne 0 ] && _fatal "failed to suspend error-test"
+
+ $DMSETUP_PROG load error-test --table "$DMERROR_TABLE"
+ [ $? -ne 0 ] && _fatal "failed to load error table error-test"
+
+ $DMSETUP_PROG resume error-test
+ [ $? -ne 0 ] && _fatal "failed to resume error-test"
+}
diff --git a/common/rc b/common/rc
index c5db0dd..447ab7f 100644
--- a/common/rc
+++ b/common/rc
@@ -1305,6 +1305,21 @@ _require_block_device()
fi
}
+# this test requires the device mapper error target
+#
+_require_dmerror()
+{
+ _require_command "$DMSETUP_PROG" dmsetup
+
+ $DMSETUP_PROG targets | grep error >/dev/null 2>&1
+ if [ $? -eq 0 ]
+ then
+ :
+ else
+ _notrun "This test requires dm error support"
+ fi
+}
+
# this test requires the device mapper flakey target
#
_require_dm_flakey()
--
1.7.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v3 2/3] xfstests: btrfs: test device replace, with EIO on the src dev
2015-04-30 10:08 [PATCH 0/3] dm error based test cases Anand Jain
` (5 preceding siblings ...)
2015-05-11 13:49 ` [PATCH v3 1/3] xfstests: btrfs: add functions to create dm-error device Anand Jain
@ 2015-05-11 13:49 ` Anand Jain
2015-05-11 13:49 ` [PATCH v3 3/3] xfstests: btrfs: test device delete with EIO on " Anand Jain
` (2 subsequent siblings)
9 siblings, 0 replies; 32+ messages in thread
From: Anand Jain @ 2015-05-11 13:49 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs, david, fdmanana
From: Anand Jain <Anand.Jain@oracle.com>
This test case will test to confirm the replace works when
the replacing source device has EIO errors.
EIO condition is achieved using the DM device.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v2->v3: accepts Filipe Manana's review comments, thanks
v1->v2: accepts Dave Chinner's review comments, thanks
tests/btrfs/087 | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/087.out | 10 +++++++
tests/btrfs/group | 1 +
3 files changed, 87 insertions(+), 0 deletions(-)
create mode 100755 tests/btrfs/087
create mode 100644 tests/btrfs/087.out
diff --git a/tests/btrfs/087 b/tests/btrfs/087
new file mode 100755
index 0000000..4872fbc
--- /dev/null
+++ b/tests/btrfs/087
@@ -0,0 +1,76 @@
+#! /bin/bash
+# FS QA Test No. btrfs/087
+#
+#test device replace works when the source device has EIO
+#
+# Copyright (c) 2015 Oracle. 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
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+
+_cleanup()
+{
+ _cleanup_dmerror
+ rm -f $tmp
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/filter.btrfs
+. ./common/dmerror
+
+_supported_fs btrfs
+_supported_os Linux
+_need_to_be_root
+_require_scratch_dev_pool 3
+_require_dmerror
+
+rm -f $seqres.full
+
+dev1="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}'`"
+dev2="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $3}'`"
+
+_init_dmerror
+_scratch_mkfs_dmerror "-f -d raid1 -m raid1 $dev1"
+_mount_dmerror
+
+$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | _filter_btrfs_filesystem_show
+
+error_devid=`$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT |\
+ egrep $DMERROR_DEV | $AWK_PROG '{print $2}'`
+
+snapshot_cmd="$BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT"
+snapshot_cmd="$snapshot_cmd $SCRATCH_MNT/snap_\`date +'%H_%M_%S_%N'\`"
+run_check $FSSTRESS_PROG -d $SCRATCH_MNT -n 200 -p 8 $FSSTRESS_AVOID -x "$snapshot_cmd" -X 50 >&/dev/null
+
+# now load the error into the DMERROR_DEV
+_load_dmerror_table
+
+_run_btrfs_util_prog replace start -B $error_devid $dev2 $SCRATCH_MNT
+
+$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | _filter_btrfs_filesystem_show
+
+status=0; exit
diff --git a/tests/btrfs/087.out b/tests/btrfs/087.out
new file mode 100644
index 0000000..9bc9562
--- /dev/null
+++ b/tests/btrfs/087.out
@@ -0,0 +1,10 @@
+QA output created by 087
+Label: none uuid: <UUID>
+ Total devices <NUM> FS bytes used <SIZE>
+ devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
+ devid <DEVID> size <SIZE> used <SIZE> path /dev/mapper/error-test
+
+Label: none uuid: <UUID>
+ Total devices <NUM> FS bytes used <SIZE>
+ devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
+
diff --git a/tests/btrfs/group b/tests/btrfs/group
index e9c15af..d66b4fc 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -89,3 +89,4 @@
084 auto quick send
085 auto quick metadata subvol
086 auto quick clone
+087 auto quick replace
--
1.7.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v3 3/3] xfstests: btrfs: test device delete with EIO on src dev
2015-04-30 10:08 [PATCH 0/3] dm error based test cases Anand Jain
` (6 preceding siblings ...)
2015-05-11 13:49 ` [PATCH v3 2/3] xfstests: btrfs: test device replace, with EIO on the src dev Anand Jain
@ 2015-05-11 13:49 ` Anand Jain
2015-07-22 10:12 ` [PATCH v4 0/3] dm error based test cases Anand Jain
2015-07-22 10:14 ` [PATCH v4 0/3] dm error based test cases Anand Jain
9 siblings, 0 replies; 32+ messages in thread
From: Anand Jain @ 2015-05-11 13:49 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs, david, fdmanana
From: Anand Jain <Anand.Jain@oracle.com>
This test case tests if the device delete would work when
the source device has failed with EIO errors.
EIO errors are achieved usign the DM device.
Also this test needs the latest btrfs-progs and kernel patch
under title
[PATCH] device delete by devid
When this patch is not found in the btrfs-progs, this test
will not run. However when the require patch is not found
in the kernel it will fail gracefully.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v2->v3: accepts Filipe Manana's review comments, thanks
v1->v2: accepts Dave Chinner's review comments, thanks
common/rc | 6 ++++
tests/btrfs/088 | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/088.out | 10 ++++++
tests/btrfs/group | 1 +
4 files changed, 94 insertions(+), 0 deletions(-)
create mode 100755 tests/btrfs/088
create mode 100644 tests/btrfs/088.out
diff --git a/common/rc b/common/rc
index 447ab7f..aca7a62 100644
--- a/common/rc
+++ b/common/rc
@@ -2685,6 +2685,12 @@ _require_test_fcntl_advisory_locks()
_notrun "Require fcntl advisory locks support"
}
+_require_btrfs_dev_del_by_devid()
+{
+ $BTRFS_UTIL_PROG device delete --help | egrep devid > /dev/null 2>&1
+ [ $? -eq 0 ] || _notrun "$BTRFS_UTIL_PROG too old (must support 'btrfs device delete <devid> /<mnt>')"
+}
+
_get_total_inode()
{
if [ -z "$1" ]; then
diff --git a/tests/btrfs/088 b/tests/btrfs/088
new file mode 100755
index 0000000..5ab226f
--- /dev/null
+++ b/tests/btrfs/088
@@ -0,0 +1,77 @@
+#! /bin/bash
+# FS QA Test No. btrfs/088
+#
+# test device delete when the source device has EIO
+#
+# Copyright (c) 2015 Oracle. 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
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+
+_cleanup()
+{
+ _cleanup_dmerror
+ rm -f $tmp
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/filter.btrfs
+. ./common/dmerror
+
+_supported_fs btrfs
+_supported_os Linux
+_need_to_be_root
+_require_scratch_dev_pool 3
+_require_btrfs_dev_del_by_devid
+_require_dmerror
+
+rm -f $seqres.full
+
+dev1="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}'`"
+dev2="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $3}'`"
+
+_init_dmerror
+_scratch_mkfs_dmerror "-f -d raid1 -m raid1 $dev1 $dev2"
+_mount_dmerror
+
+$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | _filter_btrfs_filesystem_show
+
+error_devid=`$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT |\
+ egrep $DMERROR_DEV | $AWK_PROG '{print $2}'`
+
+snapshot_cmd="$BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT"
+snapshot_cmd="$snapshot_cmd $SCRATCH_MNT/snap_\`date +'%H_%M_%S_%N'\`"
+run_check $FSSTRESS_PROG -d $SCRATCH_MNT -n 200 -p 8 $FSSTRESS_AVOID -x "$snapshot_cmd" -X 50 >&/dev/null
+
+# now load the error into the DMERROR_DEV
+_load_dmerror_table
+
+_run_btrfs_util_prog device delete $error_devid $SCRATCH_MNT
+
+$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | _filter_btrfs_filesystem_show
+
+status=0; exit
diff --git a/tests/btrfs/088.out b/tests/btrfs/088.out
new file mode 100644
index 0000000..32ee8f4
--- /dev/null
+++ b/tests/btrfs/088.out
@@ -0,0 +1,10 @@
+QA output created by 088
+Label: none uuid: <UUID>
+ Total devices <NUM> FS bytes used <SIZE>
+ devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
+ devid <DEVID> size <SIZE> used <SIZE> path /dev/mapper/error-test
+
+Label: none uuid: <UUID>
+ Total devices <NUM> FS bytes used <SIZE>
+ devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
+
diff --git a/tests/btrfs/group b/tests/btrfs/group
index d66b4fc..d474c47 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -90,3 +90,4 @@
085 auto quick metadata subvol
086 auto quick clone
087 auto quick replace
+088 auto quick replace
--
1.7.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v4 0/3] dm error based test cases
2015-04-30 10:08 [PATCH 0/3] dm error based test cases Anand Jain
` (7 preceding siblings ...)
2015-05-11 13:49 ` [PATCH v3 3/3] xfstests: btrfs: test device delete with EIO on " Anand Jain
@ 2015-07-22 10:12 ` Anand Jain
2015-07-22 10:12 ` [PATCH v4 1/3] xfstests: btrfs: add functions to create dm-error device Anand Jain
` (2 more replies)
2015-07-22 10:14 ` [PATCH v4 0/3] dm error based test cases Anand Jain
9 siblings, 3 replies; 32+ messages in thread
From: Anand Jain @ 2015-07-22 10:12 UTC (permalink / raw)
To: linux-btrfs; +Cc: dsterba, david
Most likely user would replace or delete the device when
there is a problem with the device.
We want to test this condition by using the dm error target which
will help to create the EIO when needed.
Basically first create the linear device and then load the error
table to get the EIO when needed.
The fist patch will provide the helper dm functions to create such
a test case using dm error device.
2nd and 3rd patch uses it to test the device replace and delete,
respectively. Note that device delete will need kernel and progs
patch, which when not there tests will gracefully fail and
will not run respectively.
v3->v4: rebase on latest xfstests code
v2->v3: accepts Filipe Manana's review comments, thanks.
v1->v2: accepts Dave Chinner's review comments, thanks.
Anand Jain (3):
xfstests: btrfs: add functions to create dm-error device
xfstests: btrfs: test device replace, with EIO on the src dev
xfstests: btrfs: test device delete with EIO on src dev
common/dmerror | 69 +++++++++++++++++++++++++++++++++++++++++++++++
common/rc | 21 +++++++++++++++
tests/btrfs/095 | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/095.out | 10 +++++++
tests/btrfs/096 | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/096.out | 10 +++++++
tests/btrfs/group | 2 ++
7 files changed, 265 insertions(+)
create mode 100644 common/dmerror
create mode 100755 tests/btrfs/095
create mode 100644 tests/btrfs/095.out
create mode 100755 tests/btrfs/096
create mode 100644 tests/btrfs/096.out
--
2.4.1
^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH v4 1/3] xfstests: btrfs: add functions to create dm-error device
2015-07-22 10:12 ` [PATCH v4 0/3] dm error based test cases Anand Jain
@ 2015-07-22 10:12 ` Anand Jain
2015-07-22 10:12 ` [PATCH v4 2/3] xfstests: btrfs: test device replace, with EIO on the src dev Anand Jain
2015-07-22 10:12 ` [PATCH v4 3/3] xfstests: btrfs: test device delete with EIO on " Anand Jain
2 siblings, 0 replies; 32+ messages in thread
From: Anand Jain @ 2015-07-22 10:12 UTC (permalink / raw)
To: linux-btrfs; +Cc: dsterba, david
From: Anand Jain <Anand.Jain@oracle.com>
Controlled EIO from the device is achieved using the dm device.
Helper functions are at common/dmerror.
Broadly steps will include calling _init_dmerror().
_init_dmerror() will use SCRATCH_DEV to create dm linear device and assign
DMERROR_DEV to /dev/mapper/error-test.
When test script is ready to get EIO, the test cases can call
_load_dmerror_table() which then it will load the dm error.
so that reading DMERROR_DEV will cause EIO. After the test case is
complete, cleanup must be done by calling _cleanup_dmerror().
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v3->v4: rebase on latest xfstests code
v2.1->v3: accepts Filipe Manana's review comments, thanks
v2->v2.1: fixed missed typo error fixup in the commit.
v1->v2: accepts Dave Chinner's review comments, thanks
common/dmerror | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
common/rc | 15 +++++++++++++
2 files changed, 84 insertions(+)
create mode 100644 common/dmerror
diff --git a/common/dmerror b/common/dmerror
new file mode 100644
index 0000000..f895d90
--- /dev/null
+++ b/common/dmerror
@@ -0,0 +1,69 @@
+##/bin/bash
+#
+# Copyright (c) 2015 Oracle. 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
+#
+#
+# common functions for setting up and tearing down a dmerror device
+
+_init_dmerror()
+{
+ $DMSETUP_PROG remove error-test > /dev/null 2>&1
+
+ local BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
+
+ DMERROR_DEV='/dev/mapper/error-test'
+
+ DMLINEAR_TABLE="0 $BLK_DEV_SIZE linear $SCRATCH_DEV 0"
+
+ $DMSETUP_PROG create error-test --table "$DMLINEAR_TABLE" || \
+ _fatal "failed to create dm linear device"
+
+ DMERROR_TABLE="0 $BLK_DEV_SIZE error $SCRATCH_DEV 0"
+}
+
+_scratch_mkfs_dmerror()
+{
+ $MKFS_BTRFS_PROG $* $DMERROR_DEV >> $seqres.full 2>&1 || \
+ _fatal "failed to create mkfs.btrfs $* $DMERROR_DEV"
+}
+
+_mount_dmerror()
+{
+ mount -t $FSTYP $MOUNT_OPTIONS $DMERROR_DEV $SCRATCH_MNT
+}
+
+_unmount_dmerror()
+{
+ $UMOUNT_PROGS $SCRATCH_MNT
+}
+
+_cleanup_dmerror()
+{
+ $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1
+ $DMSETUP_PROG remove error-test > /dev/null 2>&1
+}
+
+_load_dmerror_table()
+{
+ $DMSETUP_PROG suspend error-test
+ [ $? -ne 0 ] && _fatal "failed to suspend error-test"
+
+ $DMSETUP_PROG load error-test --table "$DMERROR_TABLE"
+ [ $? -ne 0 ] && _fatal "failed to load error table error-test"
+
+ $DMSETUP_PROG resume error-test
+ [ $? -ne 0 ] && _fatal "failed to resume error-test"
+}
diff --git a/common/rc b/common/rc
index 610045e..ff0732a 100644
--- a/common/rc
+++ b/common/rc
@@ -1336,6 +1336,21 @@ _require_sane_bdev_flush()
fi
}
+# this test requires the device mapper error target
+#
+_require_dmerror()
+{
+ _require_command "$DMSETUP_PROG" dmsetup
+
+ $DMSETUP_PROG targets | grep error >/dev/null 2>&1
+ if [ $? -eq 0 ]
+ then
+ :
+ else
+ _notrun "This test requires dm error support"
+ fi
+}
+
# this test requires the device mapper flakey target
#
_require_dm_flakey()
--
2.4.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v4 2/3] xfstests: btrfs: test device replace, with EIO on the src dev
2015-07-22 10:12 ` [PATCH v4 0/3] dm error based test cases Anand Jain
2015-07-22 10:12 ` [PATCH v4 1/3] xfstests: btrfs: add functions to create dm-error device Anand Jain
@ 2015-07-22 10:12 ` Anand Jain
2015-07-22 10:12 ` [PATCH v4 3/3] xfstests: btrfs: test device delete with EIO on " Anand Jain
2 siblings, 0 replies; 32+ messages in thread
From: Anand Jain @ 2015-07-22 10:12 UTC (permalink / raw)
To: linux-btrfs; +Cc: dsterba, david
From: Anand Jain <Anand.Jain@oracle.com>
This test case will test to confirm the replace works when
the replacing source device has EIO errors.
EIO condition is achieved using the DM device.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v3->v4: rebase on latest xfstests code
v2->v3: accepts Filipe Manana's review comments, thanks
v1->v2: accepts Dave Chinner's review comments, thanks
tests/btrfs/095 | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/095.out | 10 +++++++
tests/btrfs/group | 1 +
3 files changed, 87 insertions(+)
create mode 100755 tests/btrfs/095
create mode 100644 tests/btrfs/095.out
diff --git a/tests/btrfs/095 b/tests/btrfs/095
new file mode 100755
index 0000000..1da856f
--- /dev/null
+++ b/tests/btrfs/095
@@ -0,0 +1,76 @@
+#! /bin/bash
+# FS QA Test No. btrfs/095
+#
+#test device replace works when the source device has EIO
+#
+# Copyright (c) 2015 Oracle. 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
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+
+_cleanup()
+{
+ _cleanup_dmerror
+ rm -f $tmp
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/filter.btrfs
+. ./common/dmerror
+
+_supported_fs btrfs
+_supported_os Linux
+_need_to_be_root
+_require_scratch_dev_pool 3
+_require_dmerror
+
+rm -f $seqres.full
+
+dev1="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}'`"
+dev2="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $3}'`"
+
+_init_dmerror
+_scratch_mkfs_dmerror "-f -d raid1 -m raid1 $dev1"
+_mount_dmerror
+
+$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | _filter_btrfs_filesystem_show
+
+error_devid=`$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT |\
+ egrep $DMERROR_DEV | $AWK_PROG '{print $2}'`
+
+snapshot_cmd="$BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT"
+snapshot_cmd="$snapshot_cmd $SCRATCH_MNT/snap_\`date +'%H_%M_%S_%N'\`"
+run_check $FSSTRESS_PROG -d $SCRATCH_MNT -n 200 -p 8 $FSSTRESS_AVOID -x "$snapshot_cmd" -X 50 >&/dev/null
+
+# now load the error into the DMERROR_DEV
+_load_dmerror_table
+
+_run_btrfs_util_prog replace start -B $error_devid $dev2 $SCRATCH_MNT
+
+$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | _filter_btrfs_filesystem_show
+
+status=0; exit
diff --git a/tests/btrfs/095.out b/tests/btrfs/095.out
new file mode 100644
index 0000000..9af70bb
--- /dev/null
+++ b/tests/btrfs/095.out
@@ -0,0 +1,10 @@
+QA output created by 095
+Label: none uuid: <UUID>
+ Total devices <NUM> FS bytes used <SIZE>
+ devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
+ devid <DEVID> size <SIZE> used <SIZE> path /dev/mapper/error-test
+
+Label: none uuid: <UUID>
+ Total devices <NUM> FS bytes used <SIZE>
+ devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
+
diff --git a/tests/btrfs/group b/tests/btrfs/group
index ffe18bf..ed9b3bb 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -96,3 +96,4 @@
092 auto quick send
093 auto quick clone
094 auto quick send
+095 auto quick replace
--
2.4.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v4 3/3] xfstests: btrfs: test device delete with EIO on src dev
2015-07-22 10:12 ` [PATCH v4 0/3] dm error based test cases Anand Jain
2015-07-22 10:12 ` [PATCH v4 1/3] xfstests: btrfs: add functions to create dm-error device Anand Jain
2015-07-22 10:12 ` [PATCH v4 2/3] xfstests: btrfs: test device replace, with EIO on the src dev Anand Jain
@ 2015-07-22 10:12 ` Anand Jain
2 siblings, 0 replies; 32+ messages in thread
From: Anand Jain @ 2015-07-22 10:12 UTC (permalink / raw)
To: linux-btrfs; +Cc: dsterba, david
From: Anand Jain <Anand.Jain@oracle.com>
This test case tests if the device delete would work when
the source device has failed with EIO errors.
EIO errors are achieved usign the DM device.
Also this test needs the latest btrfs-progs and kernel patch
under title
[PATCH] device delete by devid
When this patch is not found in the btrfs-progs, this test
will not run. However when the require patch is not found
in the kernel it will fail gracefully.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v3->v4: rebase on latest xfstests code
v2->v3: accepts Filipe Manana's review comments, thanks
v1->v2: accepts Dave Chinner's review comments, thanks
common/rc | 6 +++++
tests/btrfs/096 | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/096.out | 10 +++++++
tests/btrfs/group | 1 +
4 files changed, 94 insertions(+)
create mode 100755 tests/btrfs/096
create mode 100644 tests/btrfs/096.out
diff --git a/common/rc b/common/rc
index ff0732a..a3af58f 100644
--- a/common/rc
+++ b/common/rc
@@ -2717,6 +2717,12 @@ _require_test_fcntl_advisory_locks()
_notrun "Require fcntl advisory locks support"
}
+_require_btrfs_dev_del_by_devid()
+{
+ $BTRFS_UTIL_PROG device delete --help | egrep devid > /dev/null 2>&1
+ [ $? -eq 0 ] || _notrun "$BTRFS_UTIL_PROG too old (must support 'btrfs device delete <devid> /<mnt>')"
+}
+
_get_total_inode()
{
if [ -z "$1" ]; then
diff --git a/tests/btrfs/096 b/tests/btrfs/096
new file mode 100755
index 0000000..7c09644
--- /dev/null
+++ b/tests/btrfs/096
@@ -0,0 +1,77 @@
+#! /bin/bash
+# FS QA Test No. btrfs/096
+#
+# test device delete when the source device has EIO
+#
+# Copyright (c) 2015 Oracle. 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
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+
+_cleanup()
+{
+ _cleanup_dmerror
+ rm -f $tmp
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/filter.btrfs
+. ./common/dmerror
+
+_supported_fs btrfs
+_supported_os Linux
+_need_to_be_root
+_require_scratch_dev_pool 3
+_require_btrfs_dev_del_by_devid
+_require_dmerror
+
+rm -f $seqres.full
+
+dev1="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}'`"
+dev2="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $3}'`"
+
+_init_dmerror
+_scratch_mkfs_dmerror "-f -d raid1 -m raid1 $dev1 $dev2"
+_mount_dmerror
+
+$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | _filter_btrfs_filesystem_show
+
+error_devid=`$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT |\
+ egrep $DMERROR_DEV | $AWK_PROG '{print $2}'`
+
+snapshot_cmd="$BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT"
+snapshot_cmd="$snapshot_cmd $SCRATCH_MNT/snap_\`date +'%H_%M_%S_%N'\`"
+run_check $FSSTRESS_PROG -d $SCRATCH_MNT -n 200 -p 8 $FSSTRESS_AVOID -x "$snapshot_cmd" -X 50 >&/dev/null
+
+# now load the error into the DMERROR_DEV
+_load_dmerror_table
+
+_run_btrfs_util_prog device delete $error_devid $SCRATCH_MNT
+
+$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | _filter_btrfs_filesystem_show
+
+status=0; exit
diff --git a/tests/btrfs/096.out b/tests/btrfs/096.out
new file mode 100644
index 0000000..8e7139c
--- /dev/null
+++ b/tests/btrfs/096.out
@@ -0,0 +1,10 @@
+QA output created by 096
+Label: none uuid: <UUID>
+ Total devices <NUM> FS bytes used <SIZE>
+ devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
+ devid <DEVID> size <SIZE> used <SIZE> path /dev/mapper/error-test
+
+Label: none uuid: <UUID>
+ Total devices <NUM> FS bytes used <SIZE>
+ devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
+
diff --git a/tests/btrfs/group b/tests/btrfs/group
index ed9b3bb..7a03794 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -97,3 +97,4 @@
093 auto quick clone
094 auto quick send
095 auto quick replace
+096 auto quick replace
--
2.4.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v4 0/3] dm error based test cases
2015-04-30 10:08 [PATCH 0/3] dm error based test cases Anand Jain
` (8 preceding siblings ...)
2015-07-22 10:12 ` [PATCH v4 0/3] dm error based test cases Anand Jain
@ 2015-07-22 10:14 ` Anand Jain
2015-07-22 10:14 ` [PATCH v4 1/3] xfstests: btrfs: add functions to create dm-error device Anand Jain
` (2 more replies)
9 siblings, 3 replies; 32+ messages in thread
From: Anand Jain @ 2015-07-22 10:14 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs, dsterba, david
Most likely user would replace or delete the device when
there is a problem with the device.
We want to test this condition by using the dm error target which
will help to create the EIO when needed.
Basically first create the linear device and then load the error
table to get the EIO when needed.
The fist patch will provide the helper dm functions to create such
a test case using dm error device.
2nd and 3rd patch uses it to test the device replace and delete,
respectively. Note that device delete will need kernel and progs
patch, which when not there tests will gracefully fail and
will not run respectively.
v3->v4: rebase on latest xfstests code
v2->v3: accepts Filipe Manana's review comments, thanks.
v1->v2: accepts Dave Chinner's review comments, thanks.
Anand Jain (3):
xfstests: btrfs: add functions to create dm-error device
xfstests: btrfs: test device replace, with EIO on the src dev
xfstests: btrfs: test device delete with EIO on src dev
common/dmerror | 69 +++++++++++++++++++++++++++++++++++++++++++++++
common/rc | 21 +++++++++++++++
tests/btrfs/095 | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/095.out | 10 +++++++
tests/btrfs/096 | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/096.out | 10 +++++++
tests/btrfs/group | 2 ++
7 files changed, 265 insertions(+)
create mode 100644 common/dmerror
create mode 100755 tests/btrfs/095
create mode 100644 tests/btrfs/095.out
create mode 100755 tests/btrfs/096
create mode 100644 tests/btrfs/096.out
--
2.4.1
^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH v4 1/3] xfstests: btrfs: add functions to create dm-error device
2015-07-22 10:14 ` [PATCH v4 0/3] dm error based test cases Anand Jain
@ 2015-07-22 10:14 ` Anand Jain
2015-08-07 10:26 ` Filipe David Manana
2015-07-22 10:14 ` [PATCH v4 2/3] xfstests: btrfs: test device replace, with EIO on the src dev Anand Jain
2015-07-22 10:14 ` [PATCH v4 3/3] xfstests: btrfs: test device delete with EIO on " Anand Jain
2 siblings, 1 reply; 32+ messages in thread
From: Anand Jain @ 2015-07-22 10:14 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs, dsterba, david
From: Anand Jain <Anand.Jain@oracle.com>
Controlled EIO from the device is achieved using the dm device.
Helper functions are at common/dmerror.
Broadly steps will include calling _init_dmerror().
_init_dmerror() will use SCRATCH_DEV to create dm linear device and assign
DMERROR_DEV to /dev/mapper/error-test.
When test script is ready to get EIO, the test cases can call
_load_dmerror_table() which then it will load the dm error.
so that reading DMERROR_DEV will cause EIO. After the test case is
complete, cleanup must be done by calling _cleanup_dmerror().
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v3->v4: rebase on latest xfstests code
v2.1->v3: accepts Filipe Manana's review comments, thanks
v2->v2.1: fixed missed typo error fixup in the commit.
v1->v2: accepts Dave Chinner's review comments, thanks
common/dmerror | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
common/rc | 15 +++++++++++++
2 files changed, 84 insertions(+)
create mode 100644 common/dmerror
diff --git a/common/dmerror b/common/dmerror
new file mode 100644
index 0000000..f895d90
--- /dev/null
+++ b/common/dmerror
@@ -0,0 +1,69 @@
+##/bin/bash
+#
+# Copyright (c) 2015 Oracle. 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
+#
+#
+# common functions for setting up and tearing down a dmerror device
+
+_init_dmerror()
+{
+ $DMSETUP_PROG remove error-test > /dev/null 2>&1
+
+ local BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
+
+ DMERROR_DEV='/dev/mapper/error-test'
+
+ DMLINEAR_TABLE="0 $BLK_DEV_SIZE linear $SCRATCH_DEV 0"
+
+ $DMSETUP_PROG create error-test --table "$DMLINEAR_TABLE" || \
+ _fatal "failed to create dm linear device"
+
+ DMERROR_TABLE="0 $BLK_DEV_SIZE error $SCRATCH_DEV 0"
+}
+
+_scratch_mkfs_dmerror()
+{
+ $MKFS_BTRFS_PROG $* $DMERROR_DEV >> $seqres.full 2>&1 || \
+ _fatal "failed to create mkfs.btrfs $* $DMERROR_DEV"
+}
+
+_mount_dmerror()
+{
+ mount -t $FSTYP $MOUNT_OPTIONS $DMERROR_DEV $SCRATCH_MNT
+}
+
+_unmount_dmerror()
+{
+ $UMOUNT_PROGS $SCRATCH_MNT
+}
+
+_cleanup_dmerror()
+{
+ $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1
+ $DMSETUP_PROG remove error-test > /dev/null 2>&1
+}
+
+_load_dmerror_table()
+{
+ $DMSETUP_PROG suspend error-test
+ [ $? -ne 0 ] && _fatal "failed to suspend error-test"
+
+ $DMSETUP_PROG load error-test --table "$DMERROR_TABLE"
+ [ $? -ne 0 ] && _fatal "failed to load error table error-test"
+
+ $DMSETUP_PROG resume error-test
+ [ $? -ne 0 ] && _fatal "failed to resume error-test"
+}
diff --git a/common/rc b/common/rc
index 610045e..ff0732a 100644
--- a/common/rc
+++ b/common/rc
@@ -1336,6 +1336,21 @@ _require_sane_bdev_flush()
fi
}
+# this test requires the device mapper error target
+#
+_require_dmerror()
+{
+ _require_command "$DMSETUP_PROG" dmsetup
+
+ $DMSETUP_PROG targets | grep error >/dev/null 2>&1
+ if [ $? -eq 0 ]
+ then
+ :
+ else
+ _notrun "This test requires dm error support"
+ fi
+}
+
# this test requires the device mapper flakey target
#
_require_dm_flakey()
--
2.4.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [PATCH v4 1/3] xfstests: btrfs: add functions to create dm-error device
2015-07-22 10:14 ` [PATCH v4 1/3] xfstests: btrfs: add functions to create dm-error device Anand Jain
@ 2015-08-07 10:26 ` Filipe David Manana
2015-08-13 14:39 ` Anand Jain
0 siblings, 1 reply; 32+ messages in thread
From: Filipe David Manana @ 2015-08-07 10:26 UTC (permalink / raw)
To: Anand Jain
Cc: fstests, linux-btrfs@vger.kernel.org, dsterba@suse.cz,
Dave Chinner
On Wed, Jul 22, 2015 at 11:14 AM, Anand Jain <anand.jain@oracle.com> wrote:
> From: Anand Jain <Anand.Jain@oracle.com>
>
> Controlled EIO from the device is achieved using the dm device.
> Helper functions are at common/dmerror.
>
> Broadly steps will include calling _init_dmerror().
> _init_dmerror() will use SCRATCH_DEV to create dm linear device and assign
> DMERROR_DEV to /dev/mapper/error-test.
>
> When test script is ready to get EIO, the test cases can call
> _load_dmerror_table() which then it will load the dm error.
> so that reading DMERROR_DEV will cause EIO. After the test case is
> complete, cleanup must be done by calling _cleanup_dmerror().
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> v3->v4: rebase on latest xfstests code
> v2.1->v3: accepts Filipe Manana's review comments, thanks
> v2->v2.1: fixed missed typo error fixup in the commit.
> v1->v2: accepts Dave Chinner's review comments, thanks
>
> common/dmerror | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> common/rc | 15 +++++++++++++
> 2 files changed, 84 insertions(+)
> create mode 100644 common/dmerror
>
> diff --git a/common/dmerror b/common/dmerror
> new file mode 100644
> index 0000000..f895d90
> --- /dev/null
> +++ b/common/dmerror
> @@ -0,0 +1,69 @@
> +##/bin/bash
> +#
> +# Copyright (c) 2015 Oracle. 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
> +#
> +#
> +# common functions for setting up and tearing down a dmerror device
> +
> +_init_dmerror()
> +{
> + $DMSETUP_PROG remove error-test > /dev/null 2>&1
> +
> + local BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
> +
> + DMERROR_DEV='/dev/mapper/error-test'
> +
> + DMLINEAR_TABLE="0 $BLK_DEV_SIZE linear $SCRATCH_DEV 0"
> +
> + $DMSETUP_PROG create error-test --table "$DMLINEAR_TABLE" || \
> + _fatal "failed to create dm linear device"
> +
> + DMERROR_TABLE="0 $BLK_DEV_SIZE error $SCRATCH_DEV 0"
> +}
> +
> +_scratch_mkfs_dmerror()
> +{
> + $MKFS_BTRFS_PROG $* $DMERROR_DEV >> $seqres.full 2>&1 || \
> + _fatal "failed to create mkfs.btrfs $* $DMERROR_DEV"
> +}
> +
> +_mount_dmerror()
> +{
> + mount -t $FSTYP $MOUNT_OPTIONS $DMERROR_DEV $SCRATCH_MNT
> +}
> +
> +_unmount_dmerror()
> +{
> + $UMOUNT_PROGS $SCRATCH_MNT
> +}
> +
> +_cleanup_dmerror()
> +{
> + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1
> + $DMSETUP_PROG remove error-test > /dev/null 2>&1
> +}
> +
> +_load_dmerror_table()
> +{
> + $DMSETUP_PROG suspend error-test
> + [ $? -ne 0 ] && _fatal "failed to suspend error-test"
> +
> + $DMSETUP_PROG load error-test --table "$DMERROR_TABLE"
> + [ $? -ne 0 ] && _fatal "failed to load error table error-test"
> +
> + $DMSETUP_PROG resume error-test
> + [ $? -ne 0 ] && _fatal "failed to resume error-test"
> +}
> diff --git a/common/rc b/common/rc
> index 610045e..ff0732a 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -1336,6 +1336,21 @@ _require_sane_bdev_flush()
> fi
> }
>
> +# this test requires the device mapper error target
> +#
> +_require_dmerror()
> +{
> + _require_command "$DMSETUP_PROG" dmsetup
> +
> + $DMSETUP_PROG targets | grep error >/dev/null 2>&1
> + if [ $? -eq 0 ]
> + then
> + :
> + else
> + _notrun "This test requires dm error support"
> + fi
Why not just:
[ $? -ne 0 ] && _notrun "This test requires dm error support"
The empty branch doesn't make much sense.
Also, please indent the body of this function using an 8 spaces tab,
which is the official style for fstests (just look at the surrounding
functions for example).
Other than that, it looks good to me. You can add:
Reviewed-by: Filipe Manana <fdmanana@suse.com>
> +}
> +
> # this test requires the device mapper flakey target
> #
> _require_dm_flakey()
> --
> 2.4.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Filipe David Manana,
"Reasonable men adapt themselves to the world.
Unreasonable men adapt the world to themselves.
That's why all progress depends on unreasonable men."
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v4 1/3] xfstests: btrfs: add functions to create dm-error device
2015-08-07 10:26 ` Filipe David Manana
@ 2015-08-13 14:39 ` Anand Jain
0 siblings, 0 replies; 32+ messages in thread
From: Anand Jain @ 2015-08-13 14:39 UTC (permalink / raw)
To: fdmanana
Cc: fstests, linux-btrfs@vger.kernel.org, dsterba@suse.cz,
Dave Chinner
>> +# this test requires the device mapper error target
>> +#
>> +_require_dmerror()
>> +{
>> + _require_command "$DMSETUP_PROG" dmsetup
>> +
>> + $DMSETUP_PROG targets | grep error >/dev/null 2>&1
>> + if [ $? -eq 0 ]
>> + then
>> + :
>> + else
>> + _notrun "This test requires dm error support"
>> + fi
>
> Why not just:
>
> [ $? -ne 0 ] && _notrun "This test requires dm error support"
>
> The empty branch doesn't make much sense.
yes.
> Also, please indent the body of this function using an 8 spaces tab,
> which is the official style for fstests (just look at the surrounding
> functions for example).
not sure how this got slipped. I am fixing it.
> Other than that, it looks good to me. You can add:
>
> Reviewed-by: Filipe Manana <fdmanana@suse.com>
Thanks.
Anand
^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH v4 2/3] xfstests: btrfs: test device replace, with EIO on the src dev
2015-07-22 10:14 ` [PATCH v4 0/3] dm error based test cases Anand Jain
2015-07-22 10:14 ` [PATCH v4 1/3] xfstests: btrfs: add functions to create dm-error device Anand Jain
@ 2015-07-22 10:14 ` Anand Jain
2015-08-07 10:27 ` Filipe David Manana
2015-07-22 10:14 ` [PATCH v4 3/3] xfstests: btrfs: test device delete with EIO on " Anand Jain
2 siblings, 1 reply; 32+ messages in thread
From: Anand Jain @ 2015-07-22 10:14 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs, dsterba, david
From: Anand Jain <Anand.Jain@oracle.com>
This test case will test to confirm the replace works when
the replacing source device has EIO errors.
EIO condition is achieved using the DM device.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v3->v4: rebase on latest xfstests code
v2->v3: accepts Filipe Manana's review comments, thanks
v1->v2: accepts Dave Chinner's review comments, thanks
tests/btrfs/095 | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/095.out | 10 +++++++
tests/btrfs/group | 1 +
3 files changed, 87 insertions(+)
create mode 100755 tests/btrfs/095
create mode 100644 tests/btrfs/095.out
diff --git a/tests/btrfs/095 b/tests/btrfs/095
new file mode 100755
index 0000000..1da856f
--- /dev/null
+++ b/tests/btrfs/095
@@ -0,0 +1,76 @@
+#! /bin/bash
+# FS QA Test No. btrfs/095
+#
+#test device replace works when the source device has EIO
+#
+# Copyright (c) 2015 Oracle. 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
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+
+_cleanup()
+{
+ _cleanup_dmerror
+ rm -f $tmp
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/filter.btrfs
+. ./common/dmerror
+
+_supported_fs btrfs
+_supported_os Linux
+_need_to_be_root
+_require_scratch_dev_pool 3
+_require_dmerror
+
+rm -f $seqres.full
+
+dev1="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}'`"
+dev2="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $3}'`"
+
+_init_dmerror
+_scratch_mkfs_dmerror "-f -d raid1 -m raid1 $dev1"
+_mount_dmerror
+
+$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | _filter_btrfs_filesystem_show
+
+error_devid=`$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT |\
+ egrep $DMERROR_DEV | $AWK_PROG '{print $2}'`
+
+snapshot_cmd="$BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT"
+snapshot_cmd="$snapshot_cmd $SCRATCH_MNT/snap_\`date +'%H_%M_%S_%N'\`"
+run_check $FSSTRESS_PROG -d $SCRATCH_MNT -n 200 -p 8 $FSSTRESS_AVOID -x "$snapshot_cmd" -X 50 >&/dev/null
+
+# now load the error into the DMERROR_DEV
+_load_dmerror_table
+
+_run_btrfs_util_prog replace start -B $error_devid $dev2 $SCRATCH_MNT
+
+$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | _filter_btrfs_filesystem_show
+
+status=0; exit
diff --git a/tests/btrfs/095.out b/tests/btrfs/095.out
new file mode 100644
index 0000000..9af70bb
--- /dev/null
+++ b/tests/btrfs/095.out
@@ -0,0 +1,10 @@
+QA output created by 095
+Label: none uuid: <UUID>
+ Total devices <NUM> FS bytes used <SIZE>
+ devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
+ devid <DEVID> size <SIZE> used <SIZE> path /dev/mapper/error-test
+
+Label: none uuid: <UUID>
+ Total devices <NUM> FS bytes used <SIZE>
+ devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
+
diff --git a/tests/btrfs/group b/tests/btrfs/group
index ffe18bf..ed9b3bb 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -96,3 +96,4 @@
092 auto quick send
093 auto quick clone
094 auto quick send
+095 auto quick replace
--
2.4.1
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [PATCH v4 2/3] xfstests: btrfs: test device replace, with EIO on the src dev
2015-07-22 10:14 ` [PATCH v4 2/3] xfstests: btrfs: test device replace, with EIO on the src dev Anand Jain
@ 2015-08-07 10:27 ` Filipe David Manana
2015-08-13 14:43 ` Anand Jain
0 siblings, 1 reply; 32+ messages in thread
From: Filipe David Manana @ 2015-08-07 10:27 UTC (permalink / raw)
To: Anand Jain
Cc: fstests, linux-btrfs@vger.kernel.org, dsterba@suse.cz,
Dave Chinner
On Wed, Jul 22, 2015 at 11:14 AM, Anand Jain <anand.jain@oracle.com> wrote:
> From: Anand Jain <Anand.Jain@oracle.com>
>
> This test case will test to confirm the replace works when
> the replacing source device has EIO errors.
>
> EIO condition is achieved using the DM device.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> v3->v4: rebase on latest xfstests code
> v2->v3: accepts Filipe Manana's review comments, thanks
> v1->v2: accepts Dave Chinner's review comments, thanks
>
> tests/btrfs/095 | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> tests/btrfs/095.out | 10 +++++++
> tests/btrfs/group | 1 +
> 3 files changed, 87 insertions(+)
> create mode 100755 tests/btrfs/095
> create mode 100644 tests/btrfs/095.out
>
> diff --git a/tests/btrfs/095 b/tests/btrfs/095
> new file mode 100755
> index 0000000..1da856f
> --- /dev/null
> +++ b/tests/btrfs/095
> @@ -0,0 +1,76 @@
> +#! /bin/bash
> +# FS QA Test No. btrfs/095
> +#
> +#test device replace works when the source device has EIO
> +#
> +# Copyright (c) 2015 Oracle. 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
> +#
> +
> +seq=`basename $0`
> +seqres=$RESULT_DIR/$seq
> +echo "QA output created by $seq"
> +
> +here=`pwd`
> +tmp=/tmp/$$
> +
> +status=1 # failure is the default!
> +trap "_cleanup; exit \$status" 0 1 2 3 15
> +
> +
> +_cleanup()
> +{
> + _cleanup_dmerror
> + rm -f $tmp
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +. ./common/filter.btrfs
> +. ./common/dmerror
> +
> +_supported_fs btrfs
> +_supported_os Linux
> +_need_to_be_root
> +_require_scratch_dev_pool 3
> +_require_dmerror
> +
> +rm -f $seqres.full
> +
> +dev1="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}'`"
> +dev2="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $3}'`"
> +
> +_init_dmerror
> +_scratch_mkfs_dmerror "-f -d raid1 -m raid1 $dev1"
> +_mount_dmerror
> +
> +$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | _filter_btrfs_filesystem_show
> +
> +error_devid=`$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT |\
> + egrep $DMERROR_DEV | $AWK_PROG '{print $2}'`
> +
> +snapshot_cmd="$BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT"
> +snapshot_cmd="$snapshot_cmd $SCRATCH_MNT/snap_\`date +'%H_%M_%S_%N'\`"
> +run_check $FSSTRESS_PROG -d $SCRATCH_MNT -n 200 -p 8 $FSSTRESS_AVOID -x "$snapshot_cmd" -X 50 >&/dev/null
Please keep the line length up to 80 characters.
> +
> +# now load the error into the DMERROR_DEV
> +_load_dmerror_table
> +
> +_run_btrfs_util_prog replace start -B $error_devid $dev2 $SCRATCH_MNT
> +
> +$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | _filter_btrfs_filesystem_show
> +
> +status=0; exit
> diff --git a/tests/btrfs/095.out b/tests/btrfs/095.out
> new file mode 100644
> index 0000000..9af70bb
> --- /dev/null
> +++ b/tests/btrfs/095.out
> @@ -0,0 +1,10 @@
> +QA output created by 095
> +Label: none uuid: <UUID>
So the test always fails due to a mismatch with this expected golden output:
-Label: none uuid: <UUID>
+Label: none uuid: <UUID>
Total devices <NUM> FS bytes used <SIZE>
devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
devid <DEVID> size <SIZE> used <SIZE> path /dev/mapper/error-test
The extra space after "uuid:" comes from _filter_uuid:
sed -e "s/\(uuid[ :=]\+\) *[0-9a-f-][0-9a-f-]*/\1 <UUID>/ig"
Which gets \1 with the string "uuid: " and then does "uuid: " + " " + "<UUID>".
We need to either to fix the golden output here or _filter_uuid (and
make sure it doesn't break any other tests using it directly or
indirectly such as yours).
Other than that, the test looks good and when fixed you can add:
Reviewed-by: Filipe Manana <fdmanana@suse.com>
> + Total devices <NUM> FS bytes used <SIZE>
> + devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
> + devid <DEVID> size <SIZE> used <SIZE> path /dev/mapper/error-test
> +
> +Label: none uuid: <UUID>
> + Total devices <NUM> FS bytes used <SIZE>
> + devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
> +
> diff --git a/tests/btrfs/group b/tests/btrfs/group
> index ffe18bf..ed9b3bb 100644
> --- a/tests/btrfs/group
> +++ b/tests/btrfs/group
> @@ -96,3 +96,4 @@
> 092 auto quick send
> 093 auto quick clone
> 094 auto quick send
> +095 auto quick replace
> --
> 2.4.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Filipe David Manana,
"Reasonable men adapt themselves to the world.
Unreasonable men adapt the world to themselves.
That's why all progress depends on unreasonable men."
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v4 2/3] xfstests: btrfs: test device replace, with EIO on the src dev
2015-08-07 10:27 ` Filipe David Manana
@ 2015-08-13 14:43 ` Anand Jain
0 siblings, 0 replies; 32+ messages in thread
From: Anand Jain @ 2015-08-13 14:43 UTC (permalink / raw)
To: fdmanana
Cc: fstests, linux-btrfs@vger.kernel.org, dsterba@suse.cz,
Dave Chinner, sandeen
> So the test always fails due to a mismatch with this expected golden output:
>
> -Label: none uuid: <UUID>
> +Label: none uuid: <UUID>
> Total devices <NUM> FS bytes used <SIZE>
> devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
> devid <DEVID> size <SIZE> used <SIZE> path /dev/mapper/error-test
>
> The extra space after "uuid:" comes from _filter_uuid:
>
> sed -e "s/\(uuid[ :=]\+\) *[0-9a-f-][0-9a-f-]*/\1 <UUID>/ig"
>
> Which gets \1 with the string "uuid: " and then does "uuid: " + " " + "<UUID>".
>
> We need to either to fix the golden output here or _filter_uuid (and
> make sure it doesn't break any other tests using it directly or
> indirectly such as yours).
commit a092363bbdfa6cc6e44353136bae9d3aa81baae2 (PATCH 3/3 V6] xfs: test
changing UUID on V5 superblock) caused the regression. btrfs/006 is
affected as well.
Thanks
Anand
^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH v4 3/3] xfstests: btrfs: test device delete with EIO on src dev
2015-07-22 10:14 ` [PATCH v4 0/3] dm error based test cases Anand Jain
2015-07-22 10:14 ` [PATCH v4 1/3] xfstests: btrfs: add functions to create dm-error device Anand Jain
2015-07-22 10:14 ` [PATCH v4 2/3] xfstests: btrfs: test device replace, with EIO on the src dev Anand Jain
@ 2015-07-22 10:14 ` Anand Jain
2 siblings, 0 replies; 32+ messages in thread
From: Anand Jain @ 2015-07-22 10:14 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs, dsterba, david
From: Anand Jain <Anand.Jain@oracle.com>
This test case tests if the device delete would work when
the source device has failed with EIO errors.
EIO errors are achieved usign the DM device.
Also this test needs the latest btrfs-progs and kernel patch
under title
[PATCH] device delete by devid
When this patch is not found in the btrfs-progs, this test
will not run. However when the require patch is not found
in the kernel it will fail gracefully.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v3->v4: rebase on latest xfstests code
v2->v3: accepts Filipe Manana's review comments, thanks
v1->v2: accepts Dave Chinner's review comments, thanks
common/rc | 6 +++++
tests/btrfs/096 | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/096.out | 10 +++++++
tests/btrfs/group | 1 +
4 files changed, 94 insertions(+)
create mode 100755 tests/btrfs/096
create mode 100644 tests/btrfs/096.out
diff --git a/common/rc b/common/rc
index ff0732a..a3af58f 100644
--- a/common/rc
+++ b/common/rc
@@ -2717,6 +2717,12 @@ _require_test_fcntl_advisory_locks()
_notrun "Require fcntl advisory locks support"
}
+_require_btrfs_dev_del_by_devid()
+{
+ $BTRFS_UTIL_PROG device delete --help | egrep devid > /dev/null 2>&1
+ [ $? -eq 0 ] || _notrun "$BTRFS_UTIL_PROG too old (must support 'btrfs device delete <devid> /<mnt>')"
+}
+
_get_total_inode()
{
if [ -z "$1" ]; then
diff --git a/tests/btrfs/096 b/tests/btrfs/096
new file mode 100755
index 0000000..7c09644
--- /dev/null
+++ b/tests/btrfs/096
@@ -0,0 +1,77 @@
+#! /bin/bash
+# FS QA Test No. btrfs/096
+#
+# test device delete when the source device has EIO
+#
+# Copyright (c) 2015 Oracle. 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
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+
+_cleanup()
+{
+ _cleanup_dmerror
+ rm -f $tmp
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/filter.btrfs
+. ./common/dmerror
+
+_supported_fs btrfs
+_supported_os Linux
+_need_to_be_root
+_require_scratch_dev_pool 3
+_require_btrfs_dev_del_by_devid
+_require_dmerror
+
+rm -f $seqres.full
+
+dev1="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}'`"
+dev2="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $3}'`"
+
+_init_dmerror
+_scratch_mkfs_dmerror "-f -d raid1 -m raid1 $dev1 $dev2"
+_mount_dmerror
+
+$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | _filter_btrfs_filesystem_show
+
+error_devid=`$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT |\
+ egrep $DMERROR_DEV | $AWK_PROG '{print $2}'`
+
+snapshot_cmd="$BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT"
+snapshot_cmd="$snapshot_cmd $SCRATCH_MNT/snap_\`date +'%H_%M_%S_%N'\`"
+run_check $FSSTRESS_PROG -d $SCRATCH_MNT -n 200 -p 8 $FSSTRESS_AVOID -x "$snapshot_cmd" -X 50 >&/dev/null
+
+# now load the error into the DMERROR_DEV
+_load_dmerror_table
+
+_run_btrfs_util_prog device delete $error_devid $SCRATCH_MNT
+
+$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | _filter_btrfs_filesystem_show
+
+status=0; exit
diff --git a/tests/btrfs/096.out b/tests/btrfs/096.out
new file mode 100644
index 0000000..8e7139c
--- /dev/null
+++ b/tests/btrfs/096.out
@@ -0,0 +1,10 @@
+QA output created by 096
+Label: none uuid: <UUID>
+ Total devices <NUM> FS bytes used <SIZE>
+ devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
+ devid <DEVID> size <SIZE> used <SIZE> path /dev/mapper/error-test
+
+Label: none uuid: <UUID>
+ Total devices <NUM> FS bytes used <SIZE>
+ devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
+
diff --git a/tests/btrfs/group b/tests/btrfs/group
index ed9b3bb..7a03794 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -97,3 +97,4 @@
093 auto quick clone
094 auto quick send
095 auto quick replace
+096 auto quick replace
--
2.4.1
^ permalink raw reply related [flat|nested] 32+ messages in thread