diff mbox series

[2/2] btrfs-progs: Unify metadata chunk size with kernel

Message ID 20190205065312.19743-2-wqu@suse.com (mailing list archive)
State New, archived
Headers show
Series [1/2] btrfs-progs: Port kernel fs_devices::total_rw_bytes to btrfs-progs | expand

Commit Message

Qu Wenruo Feb. 5, 2019, 6:53 a.m. UTC
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 mbox series

Patch

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);
 		}