From patchwork Wed Jan 24 02:38:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10181301 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 65962601D5 for ; Wed, 24 Jan 2018 02:38:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5636628614 for ; Wed, 24 Jan 2018 02:38:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A701286B5; Wed, 24 Jan 2018 02:38:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF46C28614 for ; Wed, 24 Jan 2018 02:38:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752135AbeAXCio (ORCPT ); Tue, 23 Jan 2018 21:38:44 -0500 Received: from victor.provo.novell.com ([137.65.250.26]:48992 "EHLO prv3-mh.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752009AbeAXCin (ORCPT ); Tue, 23 Jan 2018 21:38:43 -0500 Received: from adam-pc.lan (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by prv3-mh.provo.novell.com with ESMTP (NOT encrypted); Tue, 23 Jan 2018 19:38:33 -0700 From: Qu Wenruo To: linux-btrfs@vger.kernel.org, dsterba@suse.cz Subject: [PATCH 1/2] btrfs-progs: mkfs: Fix minimal device size calculation for new temporary chunk layout Date: Wed, 24 Jan 2018 10:38:29 +0800 Message-Id: <20180124023830.26184-1-wqu@suse.com> X-Mailer: git-send-email 2.15.1 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Nikolay Borisov --- 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: