Skip to contentSkip to conversation

btrfs-progs: mkfs: Fix minimal device size calculation for new temporary chunk layout

PATCH In review Qu Wenruo 3 participants 4 messages Jan 24, 2018 – Jan 25, 2018 Btrfs file system

lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

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.

Fixes 0b2161becf8e ("btrfs-progs: mkfs: Prevent temporary system chunk

to use space in reserved 1M range")

---
 mkfs/common.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
mkfs/common.c +4 -1
index 5c5e9c3b9e01..8e85942ef4eb 100644
@@ -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
author
#1 lore raw

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
index f75a22d8ff8d..f33b8aa399f4 100755
@@ -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
Reviewed-by on v1 1/2
#2 lore raw
In reply to Qu Wenruo
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 chunk

to use space in reserved 1M range")

Quoted 28 lines
---
 mkfs/common.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
mkfs/common.c +4 -1
index 5c5e9c3b9e01..8e85942ef4eb 100644
@@ -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:
#3 lore raw
In reply to Qu Wenruo
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 chunk

to use space in reserved 1M range")

As this would break bisection and the fix is short I've folded it to the patch that fixed th 0-1M range. Thanks.