From 0ddcc49d8a4708e89a6c1d7ef2ab67df971f7988 Mon Sep 17 00:00:00 2001 From: Evgeniy Kochetov Date: Wed, 31 Jul 2019 12:07:58 +0000 Subject: [PATCH] bdev/null: Add metadata size configuration file parameter Configuration file allows to configure only metadata size. Metadata transfer method is always set to 'interleave'. Signed-off-by: Evgeniy Kochetov Signed-off-by: Sasha Kotchubievsky Signed-off-by: Alexey Marchuk Change-Id: I083375807162265c6c0cf82d46910e8658c2de9a Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/464779 Reviewed-by: Shuhei Matsumoto Reviewed-by: Broadcom SPDK FC-NVMe CI Reviewed-by: Jim Harris Reviewed-by: Ben Walker Tested-by: SPDK CI Jenkins --- module/bdev/null/bdev_null.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/module/bdev/null/bdev_null.c b/module/bdev/null/bdev_null.c index 0f60ac2089..a2e35616af 100644 --- a/module/bdev/null/bdev_null.c +++ b/module/bdev/null/bdev_null.c @@ -315,6 +315,7 @@ bdev_null_initialize(void) struct spdk_conf_section *sp = spdk_conf_find_section(NULL, "Null"); uint64_t size_in_mb, num_blocks; int block_size, i, rc = 0; + int md_size; struct spdk_bdev *bdev; const char *name, *val; struct spdk_null_bdev_opts opts = {}; @@ -377,11 +378,23 @@ bdev_null_initialize(void) } } + val = spdk_conf_section_get_nmval(sp, "Dev", i, 3); + if (val == NULL) { + md_size = 0; + } else { + md_size = (int)spdk_strtol(val, 10); + if (md_size < 0) { + SPDK_ERRLOG("Null entry %d: Invalid metadata size %s\n", i, val); + continue; + } + } num_blocks = size_in_mb * (1024 * 1024) / block_size; opts.name = name; opts.num_blocks = num_blocks; opts.block_size = block_size; + opts.md_size = md_size; + opts.md_interleave = true; rc = create_null_bdev(&bdev, &opts); if (rc) { SPDK_ERRLOG("Could not create null bdev\n"); @@ -419,8 +432,8 @@ bdev_null_get_spdk_running_config(FILE *fp) TAILQ_FOREACH(bdev, &g_null_bdev_head, tailq) { null_bdev_size = bdev->bdev.blocklen * bdev->bdev.blockcnt; null_bdev_size /= (1024 * 1024); - fprintf(fp, " %s %" PRIu64 " %d\n", - bdev->bdev.name, null_bdev_size, bdev->bdev.blocklen); + fprintf(fp, " Dev %s %" PRIu64 " %d %d\n", + bdev->bdev.name, null_bdev_size, bdev->bdev.blocklen, bdev->bdev.md_len); } }