Skip to contentSkip to conversation

btrfs-progs: test/fsck: Introduce test images containing tree reloc tree

PATCH In review Qu Wenruo 2 participants 4 messages Nov 10, 2017 – Nov 27, 2017 Btrfs file system

lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

PATCH v2 1/3 btrfs-progs: test/fsck: Introduce test images containing tree reloc tree

Tree reloc tree is a special tree with very short life spawn. It acts as a special snapshot for any tree, with related nodes/leaves or EXTENT_DATA modified to point to new position.

Considering the short life spawn and its specialness, it should be quite reasonable to keep them as both corner case for fsck and educational dump for anyone interested in relocation.

---
v2:
Use check_image() override other than custom check function. Suggested by David.

---
 tests/fsck-tests/027-tree-reloc-tree/test.sh         |  19 +++++++++++++++++++
 .../tree_reloc_for_data_reloc.img.xz                 | Bin 0 -> 2112 bytes
 .../tree_reloc_for_fs_tree.img.xz                    | Bin 0 -> 2424 bytes
 3 files changed, 19 insertions(+)
 create mode 100755 tests/fsck-tests/027-tree-reloc-tree/test.sh
 create mode 100644 tests/fsck-tests/027-tree-reloc-tree/tree_reloc_for_data_reloc.img.xz
 create mode 100644 tests/fsck-tests/027-tree-reloc-tree/tree_reloc_for_fs_tree.img.xz
tests/fsck-tests/027-tree-reloc-tree/test.sh new file +19 -0
new file mode 100755
index 000000000000..1198e5da10a2
@@ -0,0 +1,19 @@
+#!/bin/bash
+# Make sure btrfs check won't report any false alert for valid image with
+# tree reloc tree.
+#
+# Also due to the short life spawn of tree reloc tree, save them as dump
+# example for later usage.
+
+source "$TOP/tests/common"
+
+check_prereq btrfs
+
+check_image() {
+	local image
+
+	image=$1
+	run_check "$TOP/btrfs" check "$image"
+}
+
+check_all_images
tests/fsck-tests/027-tree-reloc-tree/tree_reloc_for_data_reloc.img.xz new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..66d8bde6b7a6c451eb7b3b6f4dbc6a919144d1f5
GIT binary patch
tests/fsck-tests/027-tree-reloc-tree/tree_reloc_for_fs_tree.img.xz new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..22af324b95f61902ef6d3afa4b4930b7de3da41f
GIT binary patch
Signature · 1 line
2.15.0
author
#1 lore raw

PATCH 2/3 btrfs-progs: test/fsck/020: Cleanup custom check function by overriding check_image function

---
 tests/fsck-tests/020-extent-ref-cases/test.sh | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
tests/fsck-tests/020-extent-ref-cases/test.sh +6 -7
index 1e1e4e2386fb..f5c6591a92b8 100755
@@ -19,12 +19,11 @@ source "$TOP/tests/common"
 
 check_prereq btrfs
 
-for img in *.img *.raw.xz
-do
-	image=$(extract_image "$img")
+check_image() {
+	local image
 
-	# Since the return value bug is already fixed, we don't need
-	# the old grep hack to detect bug.
+	image=$1
 	run_check "$TOP/btrfs" check "$image"
-	rm -f "$image"
-done
+}
+
+check_all_images
Signature · 1 line
2.15.0
author
#2 lore raw

PATCH 3/3 btrfs-progs: test/fsck/021: Cleanup custom check by overriding check_image

In reply to Qu Wenruo
---
 .../fsck-tests/021-partially-dropped-snapshot-case/test.sh | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
tests/fsck-tests/021-partially-dropped-snapshot-case/test.sh +9 -5
index 44a33a63d269..a5e166ec5060 100755
@@ -5,14 +5,18 @@ source "$TOP/tests/common"
 
 check_prereq btrfs
 
-for img in *.img
-do
-	image=$(extract_image "$img")
+check_image()
+{
+	local image
+
+	image=$1
+
 	run_check_stdout "$TOP/btrfs" check "$image" 2>&1 |
 		grep -q "Errors found in extent allocation tree or chunk allocation"
 	if [ $? -eq 0 ]; then
 		rm -f "$image"
 		_fail "unexpected error occurred when checking $img"
 	fi
-	rm -f "$image"
-done
+}
+
+check_all_images
Signature · 1 line
2.15.0
#3 lore raw
In reply to Qu Wenruo
Quoted 9 lines · Qu Wenruo

Tree reloc tree is a special tree with very short life spawn. It acts as a special snapshot for any tree, with related nodes/leaves or EXTENT_DATA modified to point to new position.

Considering the short life spawn and its specialness, it should be quite reasonable to keep them as both corner case for fsck and educational dump for anyone interested in relocation.

1-3 applied, thanks.