diff mbox series

[3/3] btrfs-progs: convert-tests: trigger tree-checker more frequently

Message ID ab0d1243994c242fb321f775ed515670a71f7767.1705135055.git.wqu@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: allow tree-checker to be triggered more frequently for btrfs-convert | expand

Commit Message

Qu Wenruo Jan. 13, 2024, 8:45 a.m. UTC
Inspired by a recent bug report where a large ext4 fs can lead to
tree-checker warning on bad previous key objectid, we need a way to
trigger tree-checker more frequently to shake out hidden bugs.

This patch would set blocks_used threshold of btrfs-convert to 16K, and
global metadata cache size to 16K (instead of 1/4 of total memory) for
convert-tests/001 and convert-tests/003.

With those two small values, it's already enough to trigger the bad
previous key objectid bugs (without the proper fixes):

    [TEST/conv]   001-ext2-basic
    [TEST/conv]     ext2 4k nodesize, btrfs defaults
failed: /home/adam/btrfs-progs/btrfs-convert -N 4096 /home/adam/btrfs-progs/tests/test.img
test failed for case 001-ext2-basic

And the failure is exactly the reported one:

 Create ext2 image file
 Create btrfs metadata
 Copy inodes [o] [         0/       529]
 corrupt leaf: root=5 block=147079168 slot=25 ino=267, invalid previous key objectid, have 266 expect 267

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 tests/convert-tests/001-ext2-basic/test.sh | 7 +++++++
 tests/convert-tests/003-ext4-basic/test.sh | 7 +++++++
 2 files changed, 14 insertions(+)
diff mbox series

Patch

diff --git a/tests/convert-tests/001-ext2-basic/test.sh b/tests/convert-tests/001-ext2-basic/test.sh
index 6dc105b55e27..35bc39cee243 100755
--- a/tests/convert-tests/001-ext2-basic/test.sh
+++ b/tests/convert-tests/001-ext2-basic/test.sh
@@ -10,6 +10,13 @@  setup_root_helper
 prepare_test_dev
 check_kernel_support_acl
 
+# Extra finetunes to make btrfs-convert to commit transaction for each copied
+# inode, and keep cached tree blocks to minimal.
+# This is to ensure tree-checker is triggered for as many tree blocks as
+# possible, and expose any bad convert metadata behavior.
+export BTRFS_PROGS_DEBUG_BLOCKS_USED_THRESHOLD=16K
+export BTRFS_PROGS_DEBUG_METADATA_CACHE_SIZE=16K
+
 # Iterate over defaults and options that are not tied to hardware capabilities
 # or number of devices
 for feature in '' 'block-group-tree' ; do
diff --git a/tests/convert-tests/003-ext4-basic/test.sh b/tests/convert-tests/003-ext4-basic/test.sh
index 8ae5264cb340..64041d91fcb8 100755
--- a/tests/convert-tests/003-ext4-basic/test.sh
+++ b/tests/convert-tests/003-ext4-basic/test.sh
@@ -10,6 +10,13 @@  setup_root_helper
 prepare_test_dev
 check_kernel_support_acl
 
+# Extra finetunes to make btrfs-convert to commit transaction for each copied
+# inode, and keep cached tree blocks to minimal.
+# This is to ensure tree-checker is triggered for as many tree blocks as
+# possible, and expose any bad convert metadata behavior.
+export BTRFS_PROGS_DEBUG_BLOCKS_USED_THRESHOLD=16K
+export BTRFS_PROGS_DEBUG_METADATA_CACHE_SIZE=16K
+
 # Iterate over defaults and options that are not tied to hardware capabilities
 # or number of devices
 for feature in '' 'block-group-tree' ; do