* [PATCH v2] btrfs: Extend btrfs/003 device removal test
@ 2019-03-19 11:04 Nikolay Borisov
2019-03-23 9:12 ` Eryu Guan
0 siblings, 1 reply; 2+ messages in thread
From: Nikolay Borisov @ 2019-03-19 11:04 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs, guaneryu, Nikolay Borisov
When a device is deleted/removed from a btrfs filesystem the kernel
ensures all superblocks on said device are zeroed out. Test for this
behavior. Since btrfs inspect-internal dump-super always return success
I cannot test for the return value of the command. Instead there are 2
cases to handle:
1. When the device is smaller than the requested super block copy, i.e.
super block copy 2 resides at 256GB. In such cases btrfs command just
returns blank screen
2. When the device is removed and a valid offset of the super block is
queried btrfs command returns a textual error to stderr.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
V2:
* properly assign the return value of the last command expression to ret
tests/btrfs/003 | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tests/btrfs/003 b/tests/btrfs/003
index 22aa57aad0b9..a805826ce891 100755
--- a/tests/btrfs/003
+++ b/tests/btrfs/003
@@ -161,6 +161,14 @@ _test_remove()
dev_del=`echo ${SCRATCH_DEV_POOL} | awk '{print $NF}'`
$BTRFS_UTIL_PROG device delete $dev_del $SCRATCH_MNT || _fail "btrfs device delete failed"
$BTRFS_UTIL_PROG filesystem show $SCRATCH_DEV 2>&1 | grep $dev_del >> $seqres.full && _fail "btrfs still shows the deleted dev"
+ for i in {0..2}; do
+ local output=$($BTRFS_UTIL_PROG inspect-internal dump-super -s $i $dev_del 2>&1)
+ $BTRFS_UTIL_PROG inspect-internal dump-super -s $i $dev_del 2>&1 | grep -q "bad magic"
+ ret=$?
+ if [[ "$output" != "" && $ret -eq 1 ]]; then
+ _fail "Delete dev superblocks not scratched"
+ fi
+ done
_scratch_unmount
}
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] btrfs: Extend btrfs/003 device removal test
2019-03-19 11:04 [PATCH v2] btrfs: Extend btrfs/003 device removal test Nikolay Borisov
@ 2019-03-23 9:12 ` Eryu Guan
0 siblings, 0 replies; 2+ messages in thread
From: Eryu Guan @ 2019-03-23 9:12 UTC (permalink / raw)
To: Nikolay Borisov; +Cc: fstests, linux-btrfs
On Tue, Mar 19, 2019 at 01:04:04PM +0200, Nikolay Borisov wrote:
> When a device is deleted/removed from a btrfs filesystem the kernel
> ensures all superblocks on said device are zeroed out. Test for this
> behavior. Since btrfs inspect-internal dump-super always return success
> I cannot test for the return value of the command. Instead there are 2
> cases to handle:
>
> 1. When the device is smaller than the requested super block copy, i.e.
> super block copy 2 resides at 256GB. In such cases btrfs command just
> returns blank screen
>
> 2. When the device is removed and a valid offset of the super block is
> queried btrfs command returns a textual error to stderr.
>
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
I think this test deserves a new test itself, not being embedded in an
existing test randomly.
Thanks,
Eryu
> ---
> V2:
> * properly assign the return value of the last command expression to ret
>
> tests/btrfs/003 | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/tests/btrfs/003 b/tests/btrfs/003
> index 22aa57aad0b9..a805826ce891 100755
> --- a/tests/btrfs/003
> +++ b/tests/btrfs/003
> @@ -161,6 +161,14 @@ _test_remove()
> dev_del=`echo ${SCRATCH_DEV_POOL} | awk '{print $NF}'`
> $BTRFS_UTIL_PROG device delete $dev_del $SCRATCH_MNT || _fail "btrfs device delete failed"
> $BTRFS_UTIL_PROG filesystem show $SCRATCH_DEV 2>&1 | grep $dev_del >> $seqres.full && _fail "btrfs still shows the deleted dev"
> + for i in {0..2}; do
> + local output=$($BTRFS_UTIL_PROG inspect-internal dump-super -s $i $dev_del 2>&1)
> + $BTRFS_UTIL_PROG inspect-internal dump-super -s $i $dev_del 2>&1 | grep -q "bad magic"
> + ret=$?
> + if [[ "$output" != "" && $ret -eq 1 ]]; then
> + _fail "Delete dev superblocks not scratched"
> + fi
> + done
> _scratch_unmount
> }
>
> --
> 2.7.4
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-03-23 9:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-19 11:04 [PATCH v2] btrfs: Extend btrfs/003 device removal test Nikolay Borisov
2019-03-23 9:12 ` Eryu Guan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).