From patchwork Tue Feb 5 06:53:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10796943 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 876A7922 for ; Tue, 5 Feb 2019 06:53:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76FE92B9A8 for ; Tue, 5 Feb 2019 06:53:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6910A2B9F5; Tue, 5 Feb 2019 06:53:20 +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 0242E2B9A8 for ; Tue, 5 Feb 2019 06:53:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727340AbfBEGxR (ORCPT ); Tue, 5 Feb 2019 01:53:17 -0500 Received: from mx2.suse.de ([195.135.220.15]:53916 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726416AbfBEGxR (ORCPT ); Tue, 5 Feb 2019 01:53:17 -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 7D868AFC7 for ; Tue, 5 Feb 2019 06:53:16 +0000 (UTC) From: Qu Wenruo To: linux-btrfs@vger.kernel.org Subject: [PATCH 1/2] btrfs-progs: Port kernel fs_devices::total_rw_bytes to btrfs-progs Date: Tue, 5 Feb 2019 14:53:11 +0800 Message-Id: <20190205065312.19743-1-wqu@suse.com> X-Mailer: git-send-email 2.20.1 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 Unlike kernel, btrfs-progs doesn't (yet) support devices grow/shrink, the port only needs to handle open_ctree() time initialization (at read_one_dev()), and btrfs_add_device() used for mkfs. This provide the basis for incoming unification of chunk allocator behavior. Signed-off-by: Qu Wenruo --- volumes.c | 3 +++ volumes.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/volumes.c b/volumes.c index 2c6aaf42c5fb..2611a932c01c 100644 --- a/volumes.c +++ b/volumes.c @@ -744,6 +744,7 @@ int btrfs_add_device(struct btrfs_trans_handle *trans, write_extent_buffer(leaf, fs_info->fs_devices->metadata_uuid, ptr, BTRFS_UUID_SIZE); btrfs_mark_buffer_dirty(leaf); + fs_info->fs_devices->total_rw_bytes += device->total_bytes; ret = 0; out: @@ -2060,6 +2061,8 @@ static int read_one_dev(struct btrfs_fs_info *fs_info, fill_device_from_item(leaf, dev_item, device); device->dev_root = fs_info->dev_root; + fs_info->fs_devices->total_rw_bytes += + btrfs_device_total_bytes(leaf, dev_item); return ret; } diff --git a/volumes.h b/volumes.h index e30bcef7dba5..dbe9d3dea647 100644 --- a/volumes.h +++ b/volumes.h @@ -77,6 +77,9 @@ struct btrfs_fs_devices { u64 latest_devid; u64 latest_trans; u64 lowest_devid; + + u64 total_rw_bytes; + int latest_bdev; int lowest_bdev; struct list_head devices; 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); }