btrfs-progs: test/fsck: Introduce test images containing tree reloc tree
PATCH 1/2 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.
--- tests/fsck-tests/027-tree-reloc-tree/test.sh | 22 +++++++++++++++++++++ .../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, 22 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 +22 -0
@@ -0,0 +1,22 @@ +#!/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 + +for img in *.img.xz +do + image=$(extract_image "$img") + 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
tests/fsck-tests/027-tree-reloc-tree/tree_reloc_for_data_reloc.img.xz new file binary +0 -0
tests/fsck-tests/027-tree-reloc-tree/tree_reloc_for_fs_tree.img.xz new file binary +0 -0
Signature · 1 line
2.14.3
PATCH 2/2 btrfs-progs: print-tree: Print offset as tree objectid
For case like tree reloc trees and subvolume trees, their key offset is the tree id.
For case like tree treloc tree for data reloc tree, The key will be outputted as:
(TREE_RELOC ROOT_ITEM 18446744073709551607)
The minus number is long and even guys with real engineer brains can't easily get the meaning.
This patch will change the output format to:
(TREE_RELOC ROOT_ITEM DATA_RELOC_TREE)
While for special offset value like 0 or (u64)-1, it's still shown as is.
--- print-tree.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
print-tree.c +12 -0
@@ -794,6 +794,18 @@ void btrfs_print_key(struct btrfs_disk_key *disk_key)case BTRFS_UUID_KEY_RECEIVED_SUBVOL :printf (" 0x%016llx)" , (unsigned long long )offset);break ; + +/* +* For those key offset, they are points to tree id, print them +* in human readable format other than tree id. +* Especially useful for trees like data/tree reloc tree, whose +* tree id can be minus. +*/ +case BTRFS_ROOT_ITEM_KEY : +printf (" " ); +print_objectid (stdout, offset, type); +printf (")" ); +break ;default :if (offset == (u64)-1 )printf (" -1)" );
Signature · 1 line
2.14.3
David Sterba
AppliedRe: [PATCH 2/2] btrfs-progs: print-tree: Print offset as tree objectid
Quoted 10 lines · Qu Wenruo
For case like tree reloc trees and subvolume trees, their key offset is the tree id.
For case like tree treloc tree for data reloc tree, The key will be outputted as:
(TREE_RELOCROOT_ITEM18446744073709551607)The minus number is long and even guys with real engineer brains can't easily get the meaning.
Quoted 7 lines
This patch will change the output format to:
(TREE_RELOCROOT_ITEMDATA_RELOC_TREE)While for special offset value like 0 or (u64)-1, it's still shown as is.
Signed-off-by Qu Wenruo <[email protected]>
Applied, thanks.
Quoted 14 lines · Qu Wenruo
+++
b/tests/fsck-tests/027-tree-reloc-tree/test.shtests/fsck-tests/027-tree-reloc-tree/test.sh new file +12
-0@@ -0,0 +1,22 @@ +#!/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 + +for img in *.img.xz
tests/fsck-tests/027-tree-reloc-tree/test.sh line 22
Quoted 10 lines
tests/fsck-tests/027-tree-reloc-tree/test.sh new file +10
-0+do + image=$(extract_image "$img") + 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
Please use the test script pattern with the redefinition of check_image and followed by check_all_images. An example is in fsck-tests/022-qgroup-rescan-halfway. If you copied that from fsck-tests/020-extent-ref-cases, then this is a good candidate for a cleanup. Thanks.