linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Lakshmipathi.G" <Lakshmipathi.G@giis.co.in>
To: dsterba@suse.cz, linux-btrfs@vger.kernel.org
Subject: [PATCH] btrfs-progs: fsck-tests: script to verify init-csum-tree
Date: Fri, 27 Jan 2017 01:09:26 +0530	[thread overview]
Message-ID: <20170126193926.GA12017@giis.co.in> (raw)

Corrupt csum entry of a file and re-create csum tree using --init-csum

Signed-off-by: Lakshmipathi.G <Lakshmipathi.G@giis.co.in>
---
 .../fsck-tests/025-verify-init-csum-option/test.sh | 38 ++++++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100755 tests/fsck-tests/025-verify-init-csum-option/test.sh

diff --git a/tests/fsck-tests/025-verify-init-csum-option/test.sh b/tests/fsck-tests/025-verify-init-csum-option/test.sh
new file mode 100755
index 0000000..f496b33
--- /dev/null
+++ b/tests/fsck-tests/025-verify-init-csum-option/test.sh
@@ -0,0 +1,38 @@
+#!/bin/bash
+# This is a basic script to verify --init-csum recreates the csum tree.
+
+source $TOP/tests/common
+
+check_prereq btrfs-corrupt-block
+check_prereq mkfs.btrfs
+check_prereq btrfs
+
+setup_root_helper
+prepare_test_dev 512M
+
+
+# simulate missing csum error and repair using init-csum option
+test_csum_corruption()
+{
+	run_check $SUDO_HELPER $TOP/mkfs.btrfs -f $TEST_DEV
+
+	run_check_mount_test_dev
+
+	export DATASET_SIZE=1
+	generate_dataset small
+
+	run_check_umount_test_dev
+
+	# find bytenr
+	bytenr=`$SUDO_HELPER $TOP/btrfs inspect-internal dump-tree -t csum $TEST_DEV | \
+        sed -n -r 's/.*EXTENT_CSUM (.*)\) itemoff .*/\1/p'`
+
+	# corrupt csum bytenr
+	run_check $SUDO_HELPER $TOP/btrfs-corrupt-block -C $bytenr $TEST_DEV
+	$SUDO_HELPER $TOP/btrfs check $TEST_DEV &>> $RESULTS && \
+			_fail "btrfs check failed to detect missing csum."
+	run_check $SUDO_HELPER $TOP/btrfs check --repair --init-csum $TEST_DEV
+	run_check $SUDO_HELPER $TOP/btrfs check  $TEST_DEV
+}
+
+test_csum_corruption
-- 
2.7.4


                 reply	other threads:[~2017-01-26 19:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20170126193926.GA12017@giis.co.in \
    --to=lakshmipathi.g@giis.co.in \
    --cc=dsterba@suse.cz \
    --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).