diff mbox

[1/2] btrfs-progs: mkfs: Fix minimal device size calculation for new temporary chunk layout

Message ID 20180124023830.26184-1-wqu@suse.com (mailing list archive)
State New, archived
Headers show

Commit Message

Qu Wenruo Jan. 24, 2018, 2:38 a.m. UTC
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")
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 mkfs/common.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Nikolay Borisov Jan. 24, 2018, 9:40 a.m. UTC | #1
On 24.01.2018 04:38, Qu Wenruo wrote:
> 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")
> Signed-off-by: Qu Wenruo <wqu@suse.com>

Reviewed-by: Nikolay Borisov <nborisov@suse.com>

> ---
>  mkfs/common.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/mkfs/common.c b/mkfs/common.c
> index 5c5e9c3b9e01..8e85942ef4eb 100644
> --- a/mkfs/common.c
> +++ b/mkfs/common.c
> @@ -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:
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Sterba Jan. 25, 2018, 6:25 p.m. UTC | #2
On Wed, Jan 24, 2018 at 10:38:29AM +0800, Qu Wenruo wrote:
> 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")
> Signed-off-by: Qu Wenruo <wqu@suse.com>

As this would break bisection and the fix is short I've folded it to the
patch that fixed th 0-1M range. Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/mkfs/common.c b/mkfs/common.c
index 5c5e9c3b9e01..8e85942ef4eb 100644
--- a/mkfs/common.c
+++ b/mkfs/common.c
@@ -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: