From 9f583911fd21e6bc0bbd482f2e9a40560e70781e Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Mon, 11 Jun 2018 07:35:48 -0700 Subject: [PATCH] bdev: add INI config file options for bdev_io parameters Signed-off-by: Jim Harris Change-Id: I10bd5cab8789b8cf4d8fd9cb848cede8372be45e Reviewed-on: https://review.gerrithub.io/414712 Tested-by: SPDK Automated Test System Reviewed-by: Daniel Verkamp Reviewed-by: Ben Walker Reviewed-by: Shuhei Matsumoto --- etc/spdk/iscsi.conf.in | 9 +++++++++ etc/spdk/nvmf.conf.in | 9 +++++++++ etc/spdk/vhost.conf.in | 10 ++++++++++ lib/bdev/bdev.c | 25 +++++++++++++++++++++++++ test/unit/lib/bdev/bdev.c/bdev_ut.c | 1 + test/unit/lib/bdev/mt/bdev.c/bdev_ut.c | 1 + test/unit/lib/bdev/part.c/part_ut.c | 1 + 7 files changed, 56 insertions(+) diff --git a/etc/spdk/iscsi.conf.in b/etc/spdk/iscsi.conf.in index ce731761a..2935dc767 100644 --- a/etc/spdk/iscsi.conf.in +++ b/etc/spdk/iscsi.conf.in @@ -29,6 +29,15 @@ # Set to 0xFFFFFFFFFFFFFFFF to enable all tracepoint groups. #TpointGroupMask 0x0 +# Users may activate entries in this section to override default values for +# global parameters in the block device (bdev) subsystem. +[Bdev] + # Number of spdk_bdev_io structures allocated in the global bdev subsystem pool. + #BdevIoPoolSize 65536 + + # Maximum number of spdk_bdev_io structures to cache per thread. + #BdevIoCacheSize 256 + [iSCSI] # node name (not include optional part) # Users can optionally change this to fit their environment. diff --git a/etc/spdk/nvmf.conf.in b/etc/spdk/nvmf.conf.in index 2da074389..512dd1be8 100644 --- a/etc/spdk/nvmf.conf.in +++ b/etc/spdk/nvmf.conf.in @@ -26,6 +26,15 @@ #PciWhitelist 0000:03:00.0 #PciWhitelist 0000:04:00.0 +# Users may activate entries in this section to override default values for +# global parameters in the block device (bdev) subsystem. +[Bdev] + # Number of spdk_bdev_io structures allocated in the global bdev subsystem pool. + #BdevIoPoolSize 65536 + + # Maximum number of spdk_bdev_io structures to cache per thread. + #BdevIoCacheSize 256 + # Users may change this section to create a different number or size of # malloc LUNs. # This will generate 8 LUNs with a malloc-allocated backend. diff --git a/etc/spdk/vhost.conf.in b/etc/spdk/vhost.conf.in index eff4f77e5..261e58918 100644 --- a/etc/spdk/vhost.conf.in +++ b/etc/spdk/vhost.conf.in @@ -29,6 +29,16 @@ # Set to 0xFFFFFFFFFFFFFFFF to enable all tracepoint groups. #TpointGroupMask 0x0 +# Users may activate entries in this section to override default values for +# global parameters in the block device (bdev) subsystem. +[Bdev] + # Number of spdk_bdev_io structures allocated in the global bdev subsystem pool. + #BdevIoPoolSize 65536 + + # Maximum number of spdk_bdev_io structures to cache per thread. + #BdevIoCacheSize 256 + +# Users may not want to use offload even it is available. # Users can use offload by specifying "Enable Yes" in this section # if it is available. # Users may use the whitelist to initialize specified devices, IDS diff --git a/lib/bdev/bdev.c b/lib/bdev/bdev.c index df867ceda..39fa1f539 100644 --- a/lib/bdev/bdev.c +++ b/lib/bdev/bdev.c @@ -637,12 +637,37 @@ spdk_bdev_modules_init(void) void spdk_bdev_initialize(spdk_bdev_init_cb cb_fn, void *cb_arg) { + struct spdk_conf_section *sp; + struct spdk_bdev_opts bdev_opts; + int32_t bdev_io_pool_size, bdev_io_cache_size; int cache_size; int rc = 0; char mempool_name[32]; assert(cb_fn != NULL); + sp = spdk_conf_find_section(NULL, "Bdev"); + if (sp != NULL) { + spdk_bdev_get_opts(&bdev_opts); + + bdev_io_pool_size = spdk_conf_section_get_intval(sp, "BdevIoPoolSize"); + if (bdev_io_pool_size >= 0) { + bdev_opts.bdev_io_pool_size = bdev_io_pool_size; + } + + bdev_io_cache_size = spdk_conf_section_get_intval(sp, "BdevIoCacheSize"); + if (bdev_io_cache_size >= 0) { + bdev_opts.bdev_io_cache_size = bdev_io_cache_size; + } + + if (spdk_bdev_set_opts(&bdev_opts)) { + spdk_bdev_init_complete(-1); + return; + } + + assert(memcmp(&bdev_opts, &g_bdev_opts, sizeof(bdev_opts)) == 0); + } + g_init_cb_fn = cb_fn; g_init_cb_arg = cb_arg; diff --git a/test/unit/lib/bdev/bdev.c/bdev_ut.c b/test/unit/lib/bdev/bdev.c/bdev_ut.c index 99fac16d2..d7706b0a8 100644 --- a/test/unit/lib/bdev/bdev.c/bdev_ut.c +++ b/test/unit/lib/bdev/bdev.c/bdev_ut.c @@ -45,6 +45,7 @@ DEFINE_STUB(spdk_conf_find_section, struct spdk_conf_section *, (struct spdk_con const char *name), NULL); DEFINE_STUB(spdk_conf_section_get_nmval, char *, (struct spdk_conf_section *sp, const char *key, int idx1, int idx2), NULL); +DEFINE_STUB(spdk_conf_section_get_intval, int, (struct spdk_conf_section *sp, const char *key), -1); static void _bdev_send_msg(spdk_thread_fn fn, void *ctx, void *thread_ctx) diff --git a/test/unit/lib/bdev/mt/bdev.c/bdev_ut.c b/test/unit/lib/bdev/mt/bdev.c/bdev_ut.c index cc7d1f1a6..462395e1e 100644 --- a/test/unit/lib/bdev/mt/bdev.c/bdev_ut.c +++ b/test/unit/lib/bdev/mt/bdev.c/bdev_ut.c @@ -51,6 +51,7 @@ DEFINE_STUB(spdk_conf_find_section, struct spdk_conf_section *, (struct spdk_con const char *name), NULL); DEFINE_STUB(spdk_conf_section_get_nmval, char *, (struct spdk_conf_section *sp, const char *key, int idx1, int idx2), NULL); +DEFINE_STUB(spdk_conf_section_get_intval, int, (struct spdk_conf_section *sp, const char *key), -1); struct ut_bdev { struct spdk_bdev bdev; diff --git a/test/unit/lib/bdev/part.c/part_ut.c b/test/unit/lib/bdev/part.c/part_ut.c index 20f3571cb..6f8b93053 100644 --- a/test/unit/lib/bdev/part.c/part_ut.c +++ b/test/unit/lib/bdev/part.c/part_ut.c @@ -46,6 +46,7 @@ DEFINE_STUB(spdk_conf_find_section, struct spdk_conf_section *, (struct spdk_con const char *name), NULL); DEFINE_STUB(spdk_conf_section_get_nmval, char *, (struct spdk_conf_section *sp, const char *key, int idx1, int idx2), NULL); +DEFINE_STUB(spdk_conf_section_get_intval, int, (struct spdk_conf_section *sp, const char *key), -1); static void _part_send_msg(spdk_thread_fn fn, void *ctx, void *thread_ctx)