From: "Lakshmipathi.G" <Lakshmipathi.G@giis.co.in>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] btrfs-progs: misc-tests: Primary Superblock corruption and recovery using backup Superblock.
Date: Wed, 15 Feb 2017 03:01:25 +0530 [thread overview]
Message-ID: <20170214213125.GA25514@giis.co.in> (raw)
Signed-off-by: Lakshmipathi.G <Lakshmipathi.G@giis.co.in>
---
.../019-fix-corrupted-superblock/test.sh | 37 ++++++++++++++++++++++
1 file changed, 37 insertions(+)
create mode 100755 tests/misc-tests/019-fix-corrupted-superblock/test.sh
diff --git a/tests/misc-tests/019-fix-corrupted-superblock/test.sh b/tests/misc-tests/019-fix-corrupted-superblock/test.sh
new file mode 100755
index 0000000..806c775
--- /dev/null
+++ b/tests/misc-tests/019-fix-corrupted-superblock/test.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+#
+# Corrupt primary superblock and restore it using backup superblock.
+#
+
+source $TOP/tests/common
+
+check_prereq btrfs-select-super
+
+setup_root_helper
+prepare_test_dev 512M
+
+superblock_offset=65536
+
+test_superblock_restore()
+{
+ run_check $SUDO_HELPER $TOP/mkfs.btrfs -f $TEST_DEV
+
+ # Corrupt superblock checksum
+ dd if=/dev/zero of=$TEST_DEV seek=$superblock_offset bs=1 \
+ count=4 conv=notrunc &> /dev/null
+ run_check_stdout $SUDO_HELPER mount $TEST_DEV $TEST_MNT | \
+ grep -q 'wrong fs type'
+ if [ $? -ne 0 ]; then
+ _fail "Failed to corrupt superblock."
+ fi
+
+ # Copy backup superblock to primary
+ run_check $TOP/btrfs-select-super -s 1 $TEST_DEV
+ run_check $SUDO_HELPER mount $TEST_DEV $TEST_MNT
+ if [ $? -ne 0 ]; then
+ _fail "Failed to fix superblock."
+ fi
+ run_check_umount_test_dev
+}
+
+test_superblock_restore
--
2.7.4
next reply other threads:[~2017-02-14 21:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-14 21:31 Lakshmipathi.G [this message]
[not found] ` <da0d119a-68eb-a8ed-5cd4-81202da17e8f@cn.fujitsu.com>
2017-02-15 9:14 ` [PATCH] btrfs-progs: misc-tests: Primary Superblock corruption and recovery using backup Superblock Lakshmipathi.G
2017-03-13 17:22 ` 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=20170214213125.GA25514@giis.co.in \
--to=lakshmipathi.g@giis.co.in \
--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).