From patchwork Tue Feb 5 06:53:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10796945 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A905A13B5 for ; Tue, 5 Feb 2019 06:53:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97DDF2B992 for ; Tue, 5 Feb 2019 06:53:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89CCC2B9A8; Tue, 5 Feb 2019 06:53:21 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 34E712B2BD for ; Tue, 5 Feb 2019 06:53:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727497AbfBEGxU (ORCPT ); Tue, 5 Feb 2019 01:53:20 -0500 Received: from mx2.suse.de ([195.135.220.15]:53944 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726416AbfBEGxT (ORCPT ); Tue, 5 Feb 2019 01:53:19 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 41241AFC7 for ; Tue, 5 Feb 2019 06:53:18 +0000 (UTC) From: Qu Wenruo To: linux-btrfs@vger.kernel.org Subject: [PATCH 2/2] btrfs-progs: Unify metadata chunk size with kernel Date: Tue, 5 Feb 2019 14:53:12 +0800 Message-Id: <20190205065312.19743-2-wqu@suse.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190205065312.19743-1-wqu@suse.com> References: <20190205065312.19743-1-wqu@suse.com> MIME-Version: 1.0 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 Mkfs tends to create pretty large metadata chunk compared to kernel: Node size: 16384 Sector size: 4096 Filesystem size: 10.00GiB Block group profiles: Data: single 8.00MiB Metadata: DUP 1.00GiB System: DUP 8.00MiB While kernel only tends to create 256MiB metadata chunk: /* for larger filesystems, use larger metadata chunks */ if (fs_devices->total_rw_bytes > 50ULL * SZ_1G) max_stripe_size = SZ_1G; else max_stripe_size = SZ_256M; This won't cause problems in real world, but it's still better to make the behavior unified. Signed-off-by: Qu Wenruo --- volumes.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/volumes.c b/volumes.c index 2611a932c01c..3a91b43b378b 100644 --- a/volumes.c +++ b/volumes.c @@ -989,8 +989,12 @@ int btrfs_alloc_chunk(struct btrfs_trans_handle *trans, min_stripe_size = SZ_64M; max_stripes = BTRFS_MAX_DEVS(info); } else if (type & BTRFS_BLOCK_GROUP_METADATA) { - calc_size = SZ_1G; - max_chunk_size = 4 * calc_size; + /* for larger filesystems, use larger metadata chunks */ + if (info->fs_devices->total_rw_bytes > 50ULL * SZ_1G) + max_chunk_size = SZ_1G; + else + max_chunk_size = SZ_256M; + calc_size = max_chunk_size; min_stripe_size = SZ_32M; max_stripes = BTRFS_MAX_DEVS(info); }