* [PATCH] btrfs-progs: fsck-tests: missing csum test script
@ 2017-01-05 19:26 Lakshmipathi.G
2017-01-17 15:06 ` David Sterba
0 siblings, 1 reply; 3+ messages in thread
From: Lakshmipathi.G @ 2017-01-05 19:26 UTC (permalink / raw)
To: linux-btrfs
Signed-off-by: Lakshmipathi.G <Lakshmipathi.G@giis.co.in>
---
tests/fsck-tests/027-missing-data-csum/test.sh | 39 ++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
create mode 100755 tests/fsck-tests/027-missing-data-csum/test.sh
diff --git a/tests/fsck-tests/027-missing-data-csum/test.sh b/tests/fsck-tests/027-missing-data-csum/test.sh
new file mode 100755
index 0000000..6d1dc97
--- /dev/null
+++ b/tests/fsck-tests/027-missing-data-csum/test.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+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-debug-tree $TEST_DEV | \
+ grep "EXTENT_CSUM EXTENT_CSUM" | \
+ cut -f1 -d')' | awk '{print $6}'`
+
+ # corrupt csum bytenr
+ run_check $SUDO_HELPER $TOP/btrfs-corrupt-block -C $bytenr $TEST_DEV
+
+ $SUDO_HELPER $TOP/btrfs check $TEST_DEV >& /dev/null && \
+ _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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs-progs: fsck-tests: missing csum test script
2017-01-05 19:26 [PATCH] btrfs-progs: fsck-tests: missing csum test script Lakshmipathi.G
@ 2017-01-17 15:06 ` David Sterba
2017-01-25 19:52 ` Lakshmipathi.G
0 siblings, 1 reply; 3+ messages in thread
From: David Sterba @ 2017-01-17 15:06 UTC (permalink / raw)
To: Lakshmipathi.G; +Cc: linux-btrfs
It's not clear from the test what's the purpose. There's one corrupted
csum but the whole csum tree rebuild option is used. This is a pretty
basic check that the --init-csum-tree works, so it should be mentioned
somewhere in the test script.
On Thu, Jan 05, 2017 at 08:26:36PM +0100, Lakshmipathi.G wrote:
> Signed-off-by: Lakshmipathi.G <Lakshmipathi.G@giis.co.in>
> ---
> tests/fsck-tests/027-missing-data-csum/test.sh | 39 ++++++++++++++++++++++++++
> 1 file changed, 39 insertions(+)
> create mode 100755 tests/fsck-tests/027-missing-data-csum/test.sh
>
> diff --git a/tests/fsck-tests/027-missing-data-csum/test.sh b/tests/fsck-tests/027-missing-data-csum/test.sh
> new file mode 100755
> index 0000000..6d1dc97
> --- /dev/null
> +++ b/tests/fsck-tests/027-missing-data-csum/test.sh
> @@ -0,0 +1,39 @@
> +#!/bin/bash
> +
> +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-debug-tree $TEST_DEV | \
Please don't use btrfs-debug-tree, it's been obsoleted by the dump-tree
subcommand. And you can use the '-t csum' option to dump just the csum
tree.
> + grep "EXTENT_CSUM EXTENT_CSUM" | \
> + cut -f1 -d')' | awk '{print $6}'`
This can be simplified to one sed command.
> +
> + # corrupt csum bytenr
> + run_check $SUDO_HELPER $TOP/btrfs-corrupt-block -C $bytenr $TEST_DEV
> +
> + $SUDO_HELPER $TOP/btrfs check $TEST_DEV >& /dev/null && \
> + _fail "btrfs check failed to detect missing csum."
Here we want to capture the output from 'check' for analysis in case of
problems.
> + run_check $SUDO_HELPER $TOP/btrfs check --repair --init-csum $TEST_DEV
> + run_check $SUDO_HELPER $TOP/btrfs check $TEST_DEV
> +}
> +
> +test_csum_corruption
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs-progs: fsck-tests: missing csum test script
2017-01-17 15:06 ` David Sterba
@ 2017-01-25 19:52 ` Lakshmipathi.G
0 siblings, 0 replies; 3+ messages in thread
From: Lakshmipathi.G @ 2017-01-25 19:52 UTC (permalink / raw)
To: dsterba, linux-btrfs
On Tue, Jan 17, 2017 at 04:06:27PM +0100, David Sterba wrote:
> It's not clear from the test what's the purpose. There's one corrupted
> csum but the whole csum tree rebuild option is used. This is a pretty
> basic check that the --init-csum-tree works, so it should be mentioned
> somewhere in the test script.
I'll rename directory to 027-verify-init-csum-tree instead of current one.
Is it possible, to fix only the corrupted csum instead of re-building the
csum-tree?
>
> Please don't use btrfs-debug-tree, it's been obsoleted by the dump-tree
> subcommand. And you can use the '-t csum' option to dump just the csum
> tree.
>
> This can be simplified to one sed command.
>
>
> Here we want to capture the output from 'check' for analysis in case of
> problems.
>
Will fix above three issues with next patch.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-01-25 19:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-05 19:26 [PATCH] btrfs-progs: fsck-tests: missing csum test script Lakshmipathi.G
2017-01-17 15:06 ` David Sterba
2017-01-25 19:52 ` Lakshmipathi.G
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).