[PATCH] btrfs-progs: fsck-tests: script to verify init-csum-tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Lakshmipathi.G <Lakshmipathi.G@xxxxxxxxxx>
---
 .../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

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux