btrfs-progs: mkfs: Fix minimal device size calculation for new temporary chunk layout
PATCH 1/2 btrfs-progs: mkfs: Fix minimal device size calculation for new temporary chunk layout
Commit 0b2161becf8e ("btrfs-progs: mkfs: Prevent temporary system chunk to use space in reserved 1M range") changed the hard-coded temporary chunk layout to avoid the first 1M.
However this also affects btrfs_min_dev_size() which still assume temporary chunks starts at device offset 0.
This patch will fix it.
to use space in reserved 1M range")
--- mkfs/common.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
mkfs/common.c +4 -1
@@ -483,6 +483,8 @@ u64 btrfs_min_dev_size(u32 nodesize, int mixed, u64 meta_profile,/* * Minimal size calculation is complex due to several factors: +* 0) Reserved 1M range. +* * 1) Temporary chunk reuse * If specified chunk profile is SINGLE, we can reuse * temporary chunks, no need to allocate new chunks.
@@ -501,7 +503,8 @@ u64 btrfs_min_dev_size(u32 nodesize, int mixed, u64 meta_profile,* The latter two are all 8M, accroding to @calc_size of * btrfs_alloc_chunk(). */ - reserved +=BTRFS_MKFS_SYSTEM_GROUP_SIZE +SZ_8M *2 ; + reserved +=BTRFS_BLOCK_RESERVED_1M_FOR_SUPER + +BTRFS_MKFS_SYSTEM_GROUP_SIZE +SZ_8M *2 ;/* * For real chunks, we need to select different sizes:
Signature · 1 line
2.15.1
PATCH 2/2 btrfs-progs: test-mkfs: Output minimal device size
To make debugging a little easier.
--- tests/mkfs-tests/010-minimal-size/test.sh | 1 + 1 file changed, 1 insertion(+)
tests/mkfs-tests/010-minimal-size/test.sh +1 -0
@@ -18,6 +18,7 @@ do_test() good_size=$(echo "$output" | grep -oP "(?<=is )\d+") prepare_test_dev "$good_size" + echo "Minimal device size is $good_size" >> "$RESULTS" run_check $TOP/mkfs.btrfs -f $@ "$TEST_DEV" run_check_mount_test_dev run_check_umount_test_dev
Signature · 1 line
2.15.1
Quoted 4 lines · Qu Wenruo
Commit
0b2161becf8e("btrfs-progs: mkfs: Prevent temporary system chunk to use space in reserved 1M range") changed the hard-coded temporary chunk layout to avoid the first 1M.
Quoted 8 lines
However this also affects
btrfs_min_dev_size()which still assume temporary chunks starts at device offset 0.This patch will fix it.
Fixes 0b2161becf8e ("btrfs-progs: mkfs: Prevent temporary system chunkto use space in reserved 1M range")
Signed-off-by Qu Wenruo <[email protected]>
Quoted 28 lines
--- mkfs/common.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)mkfs/common.c +4
-1@@ -483,6 +483,8 @@ u64 btrfs_min_dev_size(u32 nodesize, int mixed, u64 meta_profile,/* * Minimal size calculation is complex due to several factors: +* 0) Reserved 1M range. +* * 1) Temporary chunk reuse * If specified chunk profile is SINGLE, we can reuse * temporary chunks, no need to allocate new chunks. @@ -501,7 +503,8 @@ u64 btrfs_min_dev_size(u32 nodesize, int mixed, u64 meta_profile,* The latter two are all 8M, accroding to @calc_size of * btrfs_alloc_chunk(). */ - reserved +=BTRFS_MKFS_SYSTEM_GROUP_SIZE +SZ_8M *2 ; + reserved +=BTRFS_BLOCK_RESERVED_1M_FOR_SUPER + +BTRFS_MKFS_SYSTEM_GROUP_SIZE +SZ_8M *2 ;/* * For real chunks, we need to select different sizes:
Quoted 4 lines · Qu Wenruo
Commit
0b2161becf8e("btrfs-progs: mkfs: Prevent temporary system chunk to use space in reserved 1M range") changed the hard-coded temporary chunk layout to avoid the first 1M.
Quoted 8 lines
However this also affects
btrfs_min_dev_size()which still assume temporary chunks starts at device offset 0.This patch will fix it.
Fixes 0b2161becf8e ("btrfs-progs: mkfs: Prevent temporary system chunkto use space in reserved 1M range")
Signed-off-by Qu Wenruo <[email protected]>
As this would break bisection and the fix is short I've folded it to the patch that fixed th 0-1M range. Thanks.