btrfs: tests: fix free space tree test failure on 64K page system
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.
--- fs/btrfs/tests/btrfs-tests.c | 1 + 1 file changed, 1 insertion(+)
fs/btrfs/tests/btrfs-tests.c +1 -0
@@ -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
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:101free space tree is invalid
BTRFS: selftest:fs/btrfs/tests/free-space-tree-tests.c:529test_empty_block_group[btrfs] failed with extents, sectorsize=65536, nodesize=65536, alignment=134217728The cause is that, after commit
801dc0c9ff1f("btrfs: replacediv_u64by shift infree_space_bitmap_size"), we usefs_info->sectorsize_bitsfor free space cache.
Quoted 8 lines
But in comit
fc59cfa7d2ab("btrfs: use precalculatedsectorsize_bitsfromfs_info"), we only initialized thefs_infofor 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_bitsin selftest.David, please fold this fix into the offending commit.
Thanks for catching it, patch updated.