All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: fstests@vger.kernel.org
Cc: linux-btrfs@vger.kernel.org, guaneryu@gmail.com,
	Nikolay Borisov <nborisov@suse.com>
Subject: [PATCH v2] btrfs: Extend btrfs/003 device removal test
Date: Tue, 19 Mar 2019 13:04:04 +0200	[thread overview]
Message-ID: <20190319110404.9707-1-nborisov@suse.com> (raw)

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


             reply	other threads:[~2019-03-19 11:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-19 11:04 Nikolay Borisov [this message]
2019-03-23  9:12 ` [PATCH v2] btrfs: Extend btrfs/003 device removal test Eryu Guan

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=20190319110404.9707-1-nborisov@suse.com \
    --to=nborisov@suse.com \
    --cc=fstests@vger.kernel.org \
    --cc=guaneryu@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

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

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