linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] btrfs-progs: Port kernel fs_devices::total_rw_bytes to btrfs-progs
@ 2019-02-05  6:53 Qu Wenruo
  2019-02-05  6:53 ` [PATCH 2/2] btrfs-progs: Unify metadata chunk size with kernel Qu Wenruo
  2019-03-01 16:26 ` [PATCH 1/2] btrfs-progs: Port kernel fs_devices::total_rw_bytes to btrfs-progs David Sterba
  0 siblings, 2 replies; 3+ messages in thread
From: Qu Wenruo @ 2019-02-05  6:53 UTC (permalink / raw)
  To: linux-btrfs

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 <wqu@suse.com>
---
 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;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] btrfs-progs: Unify metadata chunk size with kernel
  2019-02-05  6:53 [PATCH 1/2] btrfs-progs: Port kernel fs_devices::total_rw_bytes to btrfs-progs Qu Wenruo
@ 2019-02-05  6:53 ` Qu Wenruo
  2019-03-01 16:26 ` [PATCH 1/2] btrfs-progs: Port kernel fs_devices::total_rw_bytes to btrfs-progs David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: Qu Wenruo @ 2019-02-05  6:53 UTC (permalink / raw)
  To: linux-btrfs

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 <wqu@suse.com>
---
 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);
 		}
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] btrfs-progs: Port kernel fs_devices::total_rw_bytes to btrfs-progs
  2019-02-05  6:53 [PATCH 1/2] btrfs-progs: Port kernel fs_devices::total_rw_bytes to btrfs-progs Qu Wenruo
  2019-02-05  6:53 ` [PATCH 2/2] btrfs-progs: Unify metadata chunk size with kernel Qu Wenruo
@ 2019-03-01 16:26 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2019-03-01 16:26 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: linux-btrfs

On Tue, Feb 05, 2019 at 02:53:11PM +0800, Qu Wenruo wrote:
> 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 <wqu@suse.com>

1 and 2 applied, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-03-01 16:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-05  6:53 [PATCH 1/2] btrfs-progs: Port kernel fs_devices::total_rw_bytes to btrfs-progs Qu Wenruo
2019-02-05  6:53 ` [PATCH 2/2] btrfs-progs: Unify metadata chunk size with kernel Qu Wenruo
2019-03-01 16:26 ` [PATCH 1/2] btrfs-progs: Port kernel fs_devices::total_rw_bytes to btrfs-progs David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).