From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 3/3] btrfs-progs: tests/misc: Test if btrfs-image can handle RAID1 missing device
Date: Fri, 30 Mar 2018 15:35:28 +0800 [thread overview]
Message-ID: <20180330073528.20650-4-wqu@suse.com> (raw)
In-Reply-To: <20180330073528.20650-1-wqu@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
tests/misc-tests/030-missing-device-image/test.sh | 57 +++++++++++++++++++++++
1 file changed, 57 insertions(+)
create mode 100755 tests/misc-tests/030-missing-device-image/test.sh
diff --git a/tests/misc-tests/030-missing-device-image/test.sh b/tests/misc-tests/030-missing-device-image/test.sh
new file mode 100755
index 000000000000..b8ae3a950cc9
--- /dev/null
+++ b/tests/misc-tests/030-missing-device-image/test.sh
@@ -0,0 +1,57 @@
+#!/bin/bash
+# Test that btrfs-image can dump image correctly for missing device (RAID1)
+#
+# At least for RAID1, btrfs-image should be able to handle one missing device
+# without any problem
+
+source "$TEST_TOP/common"
+
+check_prereq btrfs-image
+check_prereq mkfs.btrfs
+check_prereq btrfs
+
+setup_root_helper
+setup_loopdevs 2
+prepare_loopdevs
+dev1=${loopdevs[1]}
+dev2=${loopdevs[2]}
+
+# $1: device number to remove (either 1 or 2)
+tmp=$(mktemp --tmpdir -d btrfs-progs-misc-test-XXXXXXX)
+test_missing()
+{
+ bad_num=$1
+ bad_dev=${loopdevs[$bad_num]}
+ good_num=$((3 - $bad_num))
+ good_dev=${loopdevs[$good_num]}
+
+ run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -d raid1 -m raid1 \
+ "$dev1" "$dev2"
+
+ # fill the fs with some data, we could create space cache
+ run_check $SUDO_HELPER mount "$dev1" "$TEST_MNT"
+ run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT/a" bs=1M count=10
+ run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT/b" bs=4k count=1000 conv=sync
+ run_check $SUDO_HELPER umount "$TEST_MNT"
+
+ # make sure we have space cache
+ run_check_stdout "$TOP/btrfs" inspect dump-tree -t root "$dev1" \
+ > "$tmp/output"
+ if ! grep -q "EXTENT_DATA" "$tmp/output" ; then
+ # normally above operation should create space cache.
+ # if not, it may means we have migrated to v2 cache by default
+ _not_run "unable to create v1 space cache"
+ fi
+
+ # now wipe the device
+ run_check wipefs -fa "$bad_dev"
+
+ # we don't care about the image but btrfs-image must not fail
+ run_check "$TOP/btrfs-image" "$good_dev" /dev/null
+}
+
+# Test with either device missing, so we're ensured to hit missing device
+test_missing 1
+test_missing 2
+cleanup_loopdevs
+rm $tmp -rf
--
2.16.3
next prev parent reply other threads:[~2018-03-30 7:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-30 7:35 [PATCH 0/3] btrfs-progs: Enhance btrfs-image to handle missing device Qu Wenruo
2018-03-30 7:35 ` [PATCH 1/3] btrfs-progs: disk-io: Fix read_extent_data() error handler for " Qu Wenruo
2018-03-30 7:35 ` [PATCH 2/3] btrfs-progs: convert: Fix offset-by-one error in read_data_extent() Qu Wenruo
2018-03-30 7:35 ` Qu Wenruo [this message]
2018-03-30 20:14 ` [PATCH 3/3] btrfs-progs: tests/misc: Test if btrfs-image can handle RAID1 missing device David Sterba
2018-03-30 20:15 ` [PATCH 0/3] btrfs-progs: Enhance btrfs-image to handle " David Sterba
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=20180330073528.20650-4-wqu@suse.com \
--to=wqu@suse.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 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).