From ad30685c9d1a23822f1072aa93d377a1688e6a21 Mon Sep 17 00:00:00 2001 From: Wang Shilong Date: Tue, 21 May 2019 12:06:39 +0800 Subject: [PATCH] LU-12158 mke2fs: avoid too large stride and stripe_width According to benchmarks numbers, too large stripe and stripe_width will make preassure with ext4 mballoc allocater and hurts performances finally. 2MB Chunk size 256K Chunk size stripe_width,stride Write(MB/s) Read(MB/s) Write(MB/s) Read(MB/s) 512,512 10,810 10,124 10,492 6,923 1024,1024 10,793 10,064 10,431 6,921 2048,2048 8,047 10,080 6,629 7,381 4096,4096 7,350 10,089 6,505 7,282 Performance number comes from Shuichi Ihara. This patch try to avoid use too large stride and stripe_width when mkfs. If users really want large value they could do it by specify mkfs options or run tune2fs later. Change-Id: I768f1ecb39837338e08842b21b4fca8b98165d2a Signed-off-by: Wang Shilong Reviewed-on: https://review.whamcloud.com/34767 Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Andreas Dilger --- misc/mke2fs.c | 15 +++++++++++++++ tests/filter.sed | 1 + 2 files changed, 16 insertions(+) diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 51c71c1..0cb1112 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -1503,6 +1503,9 @@ struct device_param { unsigned int dax:1; /* supports dax? */ }; +#define OPTIMIZED_STRIPE_WIDTH 512 +#define OPTIMIZED_STRIDE 512 + #ifdef HAVE_BLKID_PROBE_GET_TOPOLOGY /* * Sets the geometry of a device (stripe/stride), and returns the @@ -1533,7 +1536,19 @@ static int get_device_geometry(const char *file, goto out; dev_param->min_io = blkid_topology_get_minimum_io_size(tp); + if (dev_param->min_io > OPTIMIZED_STRIDE) { + fprintf(stdout, + "detected raid stride %lu too large, use optimum %u\n", + dev_param->min_io, OPTIMIZED_STRIDE); + dev_param->min_io = OPTIMIZED_STRIDE; + } dev_param->opt_io = blkid_topology_get_optimal_io_size(tp); + if (dev_param->opt_io > OPTIMIZED_STRIPE_WIDTH) { + fprintf(stdout, + "detected raid stripe width %lu too large, use optimum %u\n", + dev_param->opt_io, OPTIMIZED_STRIPE_WIDTH); + dev_param->opt_io = OPTIMIZED_STRIPE_WIDTH; + } if ((dev_param->min_io == 0) && (psector_size > blocksize)) dev_param->min_io = psector_size; if ((dev_param->opt_io == 0) && dev_param->min_io > 0) diff --git a/tests/filter.sed b/tests/filter.sed index b612ce4..ab3b16c 100644 --- a/tests/filter.sed +++ b/tests/filter.sed @@ -7,6 +7,7 @@ /^e2image [1-9]\.[0-9]*[^ ]* ([0-9]*-[A-Za-z]*-[0-9]*)/d s/\\015//g /automatically checked/d +/detected raid stride [0-9]* too large, use optimum [0-9]*/d /^Directory Hash Seed:/d /Discarding device blocks/d /^Filesystem created:/d -- 1.8.3.1