Skip to contentSkip to conversation

btrfs: tests: fix free space tree test failure on 64K page system

PATCH Superseded Qu Wenruo 2 participants 2 messages Nov 11, 2020 – Nov 13, 2020 Btrfs file system

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

PATCH 1/1 btrfs: tests: fix free space tree test failure on 64K page system

When trying to load btrfs with selftest compiled in, on 64K page system the test will always fail:

BTRFS: selftest: running free space tree tests
BTRFS: selftest: fs/btrfs/tests/free-space-tree-tests.c:101 free space tree is invalid
BTRFS: selftest: fs/btrfs/tests/free-space-tree-tests.c:529 test_empty_block_group [btrfs] failed with extents, sectorsize=65536, nodesize=65536, alignment=134217728

The cause is that, after commit 801dc0c9ff1f ("btrfs: replace div_u64 by shift in free_space_bitmap_size"), we use fs_info->sectorsize_bits for free space cache.

But in comit fc59cfa7d2ab ("btrfs: use precalculated sectorsize_bits from fs_info"), we only initialized the fs_info for non-testing environment, leaving the default bits to be ilog2(4K), screwing up the selftest on 64K page system.

Fix it by also honor sectorsize_bits in selftest.

David, please fold this fix into the offending commit.

Fixes fc59cfa7d2ab ("btrfs: use precalculated sectorsize_bits from fs_info")
---
 fs/btrfs/tests/btrfs-tests.c | 1 +
 1 file changed, 1 insertion(+)
fs/btrfs/tests/btrfs-tests.c +1 -0
index 8519f7746b2e..8ca334d554af 100644
@@ -134,6 +134,7 @@ struct btrfs_fs_info *btrfs_alloc_dummy_fs_info(u32 nodesize, u32 sectorsize)
 
 	fs_info->nodesize = nodesize;
 	fs_info->sectorsize = sectorsize;
+	fs_info->sectorsize_bits = ilog2(sectorsize);
 	set_bit(BTRFS_FS_STATE_DUMMY_FS_INFO, &fs_info->fs_state);
 
 	test_mnt->mnt_sb->s_fs_info = fs_info;
Signature · 1 line
2.29.2
#1 lore raw
Quoted 11 lines · Qu Wenruo

When trying to load btrfs with selftest compiled in, on 64K page system the test will always fail:

BTRFS: selftest: running free space tree tests
BTRFS: selftest: fs/btrfs/tests/free-space-tree-tests.c:101 free space tree is invalid
BTRFS: selftest: fs/btrfs/tests/free-space-tree-tests.c:529 test_empty_block_group [btrfs] failed with extents, sectorsize=65536, nodesize=65536, alignment=134217728

The cause is that, after commit 801dc0c9ff1f ("btrfs: replace div_u64 by shift in free_space_bitmap_size"), we use fs_info->sectorsize_bits for free space cache.

Quoted 8 lines

But in comit fc59cfa7d2ab ("btrfs: use precalculated sectorsize_bits from fs_info"), we only initialized the fs_info for non-testing environment, leaving the default bits to be ilog2(4K), screwing up the selftest on 64K page system.

Fix it by also honor sectorsize_bits in selftest.

David, please fold this fix into the offending commit.

Thanks for catching it, patch updated.