From 962ba4e89ac97aa443d5cebcad0acf5f4105f138 Mon Sep 17 00:00:00 2001 From: Seth Howell Date: Fri, 19 Oct 2018 13:19:09 -0700 Subject: [PATCH] nvmf: remove tgt_opts from nvmf_tgt This option is deprecated. Also, rename the rpc and configuration options for setting the opts to reflect that they now only set the max number of subsystems Change-Id: Iaabcbf33dd0a0dc489d81233fda74e9e7f3e0d2e Signed-off-by: Seth Howell Reviewed-on: https://review.gerrithub.io/430161 Tested-by: SPDK CI Jenkins Chandler-Test-Pool: SPDK Automated Test System Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- CHANGELOG.md | 12 +++ doc/jsonrpc.md | 20 ++--- include/spdk/nvmf.h | 20 +---- lib/event/subsystems/nvmf/conf.c | 86 +++++++++---------- lib/event/subsystems/nvmf/event_nvmf.h | 3 +- lib/event/subsystems/nvmf/nvmf_rpc.c | 41 ++++----- lib/nvmf/ctrlr_discovery.c | 2 +- lib/nvmf/nvmf.c | 45 +++------- lib/nvmf/nvmf_internal.h | 4 +- lib/nvmf/subsystem.c | 8 +- scripts/config_converter.py | 9 +- scripts/rpc.py | 9 ++ scripts/rpc/nvmf.py | 16 ++++ test/config_converter/spdk_config.json | 7 +- test/config_converter/spdk_config_virtio.json | 7 +- test/json_config/config_filter.py | 2 +- .../ctrlr_discovery.c/ctrlr_discovery_ut.c | 4 +- test/unit/lib/nvmf/subsystem.c/subsystem_ut.c | 8 +- 18 files changed, 136 insertions(+), 167 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb2443fc7f..9243f0b263 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,18 @@ ## v19.01: (Upcoming Release) +### NVMe-oF Target + +The `spdk_nvmf_tgt_opts` struct has been deprecated in favor of `spdk_nvmf_transport_opts`. +Users will no longer be able to specify target wide I/O parameters. `spdk_nvmf_tgt_listen` +will also no longer implicitly initialize a transport with the default target options (since +there are none). Instead, a user must manually instantiate the transport with `spdk_nvmf_transport_create` +prior to calling `spdk_nvmf_tgt_listen`. + +Related to the previous change, the rpc `set_nvmf_target_options` has been renamed to +`set_nvmf_target_max_subsystems` to indicate that this is the only target option available for the user to edit. +Usage of this rpc is still confined to the time prior to application subsystem initialization. + ## v18.10: ### nvme diff --git a/doc/jsonrpc.md b/doc/jsonrpc.md index 79d8452087..f6ec2cf1f1 100644 --- a/doc/jsonrpc.md +++ b/doc/jsonrpc.md @@ -3316,21 +3316,16 @@ Example response: } ~~~ -## set_nvmf_target_options {#rpc_set_nvmf_target_options} +## set_nvmf_target_max_subsystems {#rpc_set_nvmf_target_max_subsystems} -Set global parameters for the NVMe-oF target. This RPC may only be called before SPDK subsystems -have been initialized. +Set the maximum allowed subsystems for the NVMe-oF target. This RPC may only be called +before SPDK subsystems have been initialized. ### Parameters Name | Optional | Type | Description ----------------------- | -------- | ----------- | ----------- -max_queue_depth | Optional | number | Maximum number of outstanding I/Os per queue -max_qpairs_per_ctrlr | Optional | number | Maximum number of SQ and CQ per controller -in_capsule_data_size | Optional | number | Maximum number of in-capsule data size -max_io_size | Optional | number | Maximum I/O size (bytes) -max_subsystems | Optional | number | Maximum number of NVMe-oF subsystems -io_unit_size | Optional | number | I/O unit size (bytes) +max_subsystems | Required | number | Maximum number of NVMe-oF subsystems ### Example @@ -3339,13 +3334,8 @@ Example request: { "jsonrpc": "2.0", "id": 1, - "method": "set_nvmf_target_options", + "method": "set_nvmf_target_max_subsystems", "params": { - "in_capsule_data_size": 4096, - "io_unit_size": 131072, - "max_qpairs_per_ctrlr": 64, - "max_queue_depth": 128, - "max_io_size": 131072, "max_subsystems": 1024 } } diff --git a/include/spdk/nvmf.h b/include/spdk/nvmf.h index eda95f8a48..d4824080a5 100644 --- a/include/spdk/nvmf.h +++ b/include/spdk/nvmf.h @@ -63,15 +63,6 @@ struct spdk_nvmf_poll_group; struct spdk_json_write_ctx; struct spdk_nvmf_transport; -struct spdk_nvmf_tgt_opts { - uint16_t max_queue_depth; - uint16_t max_qpairs_per_ctrlr; - uint32_t in_capsule_data_size; - uint32_t max_io_size; - uint32_t max_subsystems; - uint32_t io_unit_size; -}; - struct spdk_nvmf_transport_opts { uint16_t max_queue_depth; uint16_t max_qpairs_per_ctrlr; @@ -81,21 +72,14 @@ struct spdk_nvmf_transport_opts { uint32_t max_aq_depth; }; -/** - * Initialize the default value of opts. - * - * \param opts Data structure where SPDK will initialize the default options. - */ -void spdk_nvmf_tgt_opts_init(struct spdk_nvmf_tgt_opts *opts); - /** * Construct an NVMe-oF target. * - * \param opts Options. + * \param max_subsystems the maximum number of subsystems allowed by the target. * * \return a pointer to a NVMe-oF target on success, or NULL on failure. */ -struct spdk_nvmf_tgt *spdk_nvmf_tgt_create(struct spdk_nvmf_tgt_opts *opts); +struct spdk_nvmf_tgt *spdk_nvmf_tgt_create(uint32_t max_subsystems); typedef void (spdk_nvmf_tgt_destroy_done_fn)(void *ctx, int status); diff --git a/lib/event/subsystems/nvmf/conf.c b/lib/event/subsystems/nvmf/conf.c index 986e81c9f8..cace0bea4c 100644 --- a/lib/event/subsystems/nvmf/conf.c +++ b/lib/event/subsystems/nvmf/conf.c @@ -43,8 +43,8 @@ #define SPDK_NVMF_MAX_NAMESPACES (1 << 14) -struct spdk_nvmf_tgt_opts *g_spdk_nvmf_tgt_opts = NULL; struct spdk_nvmf_tgt_conf *g_spdk_nvmf_tgt_conf = NULL; +uint32_t g_spdk_nvmf_tgt_max_subsystems = 0; static int spdk_add_nvmf_discovery_subsystem(void) @@ -64,38 +64,40 @@ spdk_add_nvmf_discovery_subsystem(void) } static void -spdk_nvmf_read_config_file_tgt_opts(struct spdk_conf_section *sp, - struct spdk_nvmf_tgt_opts *opts) +spdk_nvmf_read_config_file_tgt_max_subsystems(struct spdk_conf_section *sp, + int *deprecated_values) { - int max_queue_depth; - int max_queues_per_sess; - int in_capsule_data_size; - int max_io_size; - int io_unit_size; + int tgt_max_subsystems; + int deprecated; - max_queue_depth = spdk_conf_section_get_intval(sp, "MaxQueueDepth"); - if (max_queue_depth >= 0) { - opts->max_queue_depth = max_queue_depth; + tgt_max_subsystems = spdk_conf_section_get_intval(sp, "MaxSubsystems"); + if (tgt_max_subsystems >= 0) { + g_spdk_nvmf_tgt_max_subsystems = tgt_max_subsystems; } - max_queues_per_sess = spdk_conf_section_get_intval(sp, "MaxQueuesPerSession"); - if (max_queues_per_sess >= 0) { - opts->max_qpairs_per_ctrlr = max_queues_per_sess; + deprecated = spdk_conf_section_get_intval(sp, "MaxQueueDepth"); + if (deprecated >= 0) { + *deprecated_values = -1; } - in_capsule_data_size = spdk_conf_section_get_intval(sp, "InCapsuleDataSize"); - if (in_capsule_data_size >= 0) { - opts->in_capsule_data_size = in_capsule_data_size; + deprecated = spdk_conf_section_get_intval(sp, "MaxQueuesPerSession"); + if (deprecated >= 0) { + *deprecated_values = -1; } - max_io_size = spdk_conf_section_get_intval(sp, "MaxIOSize"); - if (max_io_size >= 0) { - opts->max_io_size = max_io_size; + deprecated = spdk_conf_section_get_intval(sp, "InCapsuleDataSize"); + if (deprecated >= 0) { + *deprecated_values = -1; } - io_unit_size = spdk_conf_section_get_intval(sp, "IOUnitSize"); - if (io_unit_size >= 0) { - opts->io_unit_size = io_unit_size; + deprecated = spdk_conf_section_get_intval(sp, "MaxIOSize"); + if (deprecated >= 0) { + *deprecated_values = -1; + } + + deprecated = spdk_conf_section_get_intval(sp, "IOUnitSize"); + if (deprecated >= 0) { + *deprecated_values = -1; } } @@ -111,26 +113,18 @@ spdk_nvmf_read_config_file_tgt_conf(struct spdk_conf_section *sp, } } -static struct spdk_nvmf_tgt_opts * -spdk_nvmf_parse_tgt_opts(void) +static int +spdk_nvmf_parse_tgt_max_subsystems(void) { - struct spdk_nvmf_tgt_opts *opts; struct spdk_conf_section *sp; - - opts = calloc(1, sizeof(*opts)); - if (!opts) { - SPDK_ERRLOG("calloc() failed for target options\n"); - return NULL; - } - - spdk_nvmf_tgt_opts_init(opts); + int deprecated_values = 0; sp = spdk_conf_find_section(NULL, "Nvmf"); if (sp != NULL) { - spdk_nvmf_read_config_file_tgt_opts(sp, opts); + spdk_nvmf_read_config_file_tgt_max_subsystems(sp, &deprecated_values); } - return opts; + return deprecated_values; } static struct spdk_nvmf_tgt_conf * @@ -160,12 +154,17 @@ static int spdk_nvmf_parse_nvmf_tgt(void) { int rc; + int using_deprecated_options; - if (!g_spdk_nvmf_tgt_opts) { - g_spdk_nvmf_tgt_opts = spdk_nvmf_parse_tgt_opts(); - if (!g_spdk_nvmf_tgt_opts) { - SPDK_ERRLOG("spdk_nvmf_parse_tgt_opts() failed\n"); - return -1; + if (!g_spdk_nvmf_tgt_max_subsystems) { + using_deprecated_options = spdk_nvmf_parse_tgt_max_subsystems(); + if (using_deprecated_options < 0) { + SPDK_ERRLOG("Deprecated options detected for the NVMe-oF target.\n" + "The following options are no longer controlled by the target\n" + "and should be set in the transport on a per-transport basis:\n" + "MaxQueueDepth, MaxQueuesPerSession, InCapsuleDataSize, MaxIOSize, IOUnitSize\n" + "This can be accomplished by setting the options through the create_nvmf_transport RPC.\n" + "You may also continue to configure these options in the conf file under each transport."); } } @@ -177,10 +176,9 @@ spdk_nvmf_parse_nvmf_tgt(void) } } - g_spdk_nvmf_tgt = spdk_nvmf_tgt_create(g_spdk_nvmf_tgt_opts); + g_spdk_nvmf_tgt = spdk_nvmf_tgt_create(g_spdk_nvmf_tgt_max_subsystems); - free(g_spdk_nvmf_tgt_opts); - g_spdk_nvmf_tgt_opts = NULL; + g_spdk_nvmf_tgt_max_subsystems = 0; if (!g_spdk_nvmf_tgt) { SPDK_ERRLOG("spdk_nvmf_tgt_create() failed\n"); diff --git a/lib/event/subsystems/nvmf/event_nvmf.h b/lib/event/subsystems/nvmf/event_nvmf.h index 50e5d75550..6c45cbeb18 100644 --- a/lib/event/subsystems/nvmf/event_nvmf.h +++ b/lib/event/subsystems/nvmf/event_nvmf.h @@ -55,9 +55,10 @@ struct spdk_nvmf_tgt_conf { enum spdk_nvmf_connect_sched conn_sched; }; -extern struct spdk_nvmf_tgt_opts *g_spdk_nvmf_tgt_opts; extern struct spdk_nvmf_tgt_conf *g_spdk_nvmf_tgt_conf; +extern uint32_t g_spdk_nvmf_tgt_max_subsystems; + extern struct spdk_nvmf_tgt *g_spdk_nvmf_tgt; typedef void (*spdk_nvmf_parse_conf_done_fn)(int status); diff --git a/lib/event/subsystems/nvmf/nvmf_rpc.c b/lib/event/subsystems/nvmf/nvmf_rpc.c index 3be213155b..cd76669b1f 100644 --- a/lib/event/subsystems/nvmf/nvmf_rpc.c +++ b/lib/event/subsystems/nvmf/nvmf_rpc.c @@ -1299,42 +1299,36 @@ SPDK_RPC_REGISTER("nvmf_subsystem_allow_any_host", nvmf_rpc_subsystem_allow_any_ SPDK_RPC_RUNTIME) static const struct spdk_json_object_decoder nvmf_rpc_subsystem_tgt_opts_decoder[] = { - {"max_queue_depth", offsetof(struct spdk_nvmf_tgt_opts, max_queue_depth), spdk_json_decode_uint16, true}, - {"max_qpairs_per_ctrlr", offsetof(struct spdk_nvmf_tgt_opts, max_qpairs_per_ctrlr), spdk_json_decode_uint16, true}, - {"in_capsule_data_size", offsetof(struct spdk_nvmf_tgt_opts, in_capsule_data_size), spdk_json_decode_uint32, true}, - {"max_io_size", offsetof(struct spdk_nvmf_tgt_opts, max_io_size), spdk_json_decode_uint32, true}, - {"max_subsystems", offsetof(struct spdk_nvmf_tgt_opts, max_subsystems), spdk_json_decode_uint32, true}, - {"io_unit_size", offsetof(struct spdk_nvmf_tgt_opts, io_unit_size), spdk_json_decode_uint32, true}, + {"max_subsystems", 0, spdk_json_decode_uint32, true} }; static void nvmf_rpc_subsystem_set_tgt_opts(struct spdk_jsonrpc_request *request, const struct spdk_json_val *params) { - struct spdk_nvmf_tgt_opts *opts; - struct spdk_json_write_ctx *w; + spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_REQUEST, + "This function has been deprecated in favor of set_nvmf_target_max_subsystems and create_nvmf_transport"); +} +SPDK_RPC_REGISTER("set_nvmf_target_options", nvmf_rpc_subsystem_set_tgt_opts, + SPDK_RPC_STARTUP | SPDK_RPC_RUNTIME) - if (g_spdk_nvmf_tgt_opts != NULL) { +static void +nvmf_rpc_subsystem_set_tgt_max_subsystems(struct spdk_jsonrpc_request *request, + const struct spdk_json_val *params) +{ + struct spdk_json_write_ctx *w; + uint32_t max_subsystems = 0; + + if (g_spdk_nvmf_tgt_max_subsystems != 0) { SPDK_ERRLOG("this RPC must not be called more than once.\n"); spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR, "Must not call more than once"); return; } - opts = calloc(1, sizeof(*opts)); - if (opts == NULL) { - SPDK_ERRLOG("malloc() failed for target options\n"); - spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR, - "Out of memory"); - return; - } - - spdk_nvmf_tgt_opts_init(opts); - if (params != NULL) { if (spdk_json_decode_object(params, nvmf_rpc_subsystem_tgt_opts_decoder, - SPDK_COUNTOF(nvmf_rpc_subsystem_tgt_opts_decoder), opts)) { - free(opts); + SPDK_COUNTOF(nvmf_rpc_subsystem_tgt_opts_decoder), &max_subsystems)) { SPDK_ERRLOG("spdk_json_decode_object() failed\n"); spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters"); @@ -1342,7 +1336,7 @@ nvmf_rpc_subsystem_set_tgt_opts(struct spdk_jsonrpc_request *request, } } - g_spdk_nvmf_tgt_opts = opts; + g_spdk_nvmf_tgt_max_subsystems = max_subsystems; w = spdk_jsonrpc_begin_result(request); if (w == NULL) { @@ -1352,7 +1346,8 @@ nvmf_rpc_subsystem_set_tgt_opts(struct spdk_jsonrpc_request *request, spdk_json_write_bool(w, true); spdk_jsonrpc_end_result(request, w); } -SPDK_RPC_REGISTER("set_nvmf_target_options", nvmf_rpc_subsystem_set_tgt_opts, SPDK_RPC_STARTUP) +SPDK_RPC_REGISTER("set_nvmf_target_max_subsystems", nvmf_rpc_subsystem_set_tgt_max_subsystems, + SPDK_RPC_STARTUP) static int decode_conn_sched(const struct spdk_json_val *val, void *out) { diff --git a/lib/nvmf/ctrlr_discovery.c b/lib/nvmf/ctrlr_discovery.c index 305a6076e5..6d1aed6d8a 100644 --- a/lib/nvmf/ctrlr_discovery.c +++ b/lib/nvmf/ctrlr_discovery.c @@ -69,7 +69,7 @@ nvmf_update_discovery_log(struct spdk_nvmf_tgt *tgt) return; } - for (sid = 0; sid < tgt->opts.max_subsystems; sid++) { + for (sid = 0; sid < tgt->max_subsystems; sid++) { subsystem = tgt->subsystems[sid]; if (subsystem == NULL) { continue; diff --git a/lib/nvmf/nvmf.c b/lib/nvmf/nvmf.c index 3338ed6a4c..080e8dfc63 100644 --- a/lib/nvmf/nvmf.c +++ b/lib/nvmf/nvmf.c @@ -49,12 +49,7 @@ SPDK_LOG_REGISTER_COMPONENT("nvmf", SPDK_LOG_NVMF) -#define SPDK_NVMF_DEFAULT_MAX_QUEUE_DEPTH 128 -#define SPDK_NVMF_DEFAULT_MAX_QPAIRS_PER_CTRLR 64 -#define SPDK_NVMF_DEFAULT_IN_CAPSULE_DATA_SIZE 4096 -#define SPDK_NVMF_DEFAULT_MAX_IO_SIZE 131072 #define SPDK_NVMF_DEFAULT_MAX_SUBSYSTEMS 1024 -#define SPDK_NVMF_DEFAULT_IO_UNIT_SIZE 131072 typedef void (*nvmf_qpair_disconnect_cpl)(void *ctx, int status); static void spdk_nvmf_tgt_destroy_poll_group(void *io_device, void *ctx_buf); @@ -91,17 +86,6 @@ spdk_nvmf_qpair_set_state(struct spdk_nvmf_qpair *qpair, qpair->state = state; } -void -spdk_nvmf_tgt_opts_init(struct spdk_nvmf_tgt_opts *opts) -{ - opts->max_queue_depth = SPDK_NVMF_DEFAULT_MAX_QUEUE_DEPTH; - opts->max_qpairs_per_ctrlr = SPDK_NVMF_DEFAULT_MAX_QPAIRS_PER_CTRLR; - opts->in_capsule_data_size = SPDK_NVMF_DEFAULT_IN_CAPSULE_DATA_SIZE; - opts->max_io_size = SPDK_NVMF_DEFAULT_MAX_IO_SIZE; - opts->max_subsystems = SPDK_NVMF_DEFAULT_MAX_SUBSYSTEMS; - opts->io_unit_size = SPDK_NVMF_DEFAULT_IO_UNIT_SIZE; -} - static int spdk_nvmf_poll_group_poll(void *ctx) { @@ -136,13 +120,13 @@ spdk_nvmf_tgt_create_poll_group(void *io_device, void *ctx_buf) spdk_nvmf_poll_group_add_transport(group, transport); } - group->num_sgroups = tgt->opts.max_subsystems; - group->sgroups = calloc(tgt->opts.max_subsystems, sizeof(struct spdk_nvmf_subsystem_poll_group)); + group->num_sgroups = tgt->max_subsystems; + group->sgroups = calloc(tgt->max_subsystems, sizeof(struct spdk_nvmf_subsystem_poll_group)); if (!group->sgroups) { return -ENOMEM; } - for (sid = 0; sid < tgt->opts.max_subsystems; sid++) { + for (sid = 0; sid < tgt->max_subsystems; sid++) { struct spdk_nvmf_subsystem *subsystem; subsystem = tgt->subsystems[sid]; @@ -233,7 +217,7 @@ spdk_nvmf_tgt_destroy_poll_group_qpairs(struct spdk_nvmf_poll_group *group) } struct spdk_nvmf_tgt * -spdk_nvmf_tgt_create(struct spdk_nvmf_tgt_opts *opts) +spdk_nvmf_tgt_create(uint32_t max_subsystems) { struct spdk_nvmf_tgt *tgt; @@ -242,10 +226,10 @@ spdk_nvmf_tgt_create(struct spdk_nvmf_tgt_opts *opts) return NULL; } - if (!opts) { - spdk_nvmf_tgt_opts_init(&tgt->opts); + if (!max_subsystems) { + tgt->max_subsystems = SPDK_NVMF_DEFAULT_MAX_SUBSYSTEMS; } else { - tgt->opts = *opts; + tgt->max_subsystems = max_subsystems; } tgt->discovery_genctr = 0; @@ -253,7 +237,7 @@ spdk_nvmf_tgt_create(struct spdk_nvmf_tgt_opts *opts) tgt->discovery_log_page_size = 0; TAILQ_INIT(&tgt->transports); - tgt->subsystems = calloc(tgt->opts.max_subsystems, sizeof(struct spdk_nvmf_subsystem *)); + tgt->subsystems = calloc(tgt->max_subsystems, sizeof(struct spdk_nvmf_subsystem *)); if (!tgt->subsystems) { free(tgt); return NULL; @@ -282,7 +266,7 @@ spdk_nvmf_tgt_destroy_cb(void *io_device) } if (tgt->subsystems) { - for (i = 0; i < tgt->opts.max_subsystems; i++) { + for (i = 0; i < tgt->max_subsystems; i++) { if (tgt->subsystems[i]) { spdk_nvmf_subsystem_destroy(tgt->subsystems[i]); } @@ -461,15 +445,10 @@ spdk_nvmf_tgt_write_config_json(struct spdk_json_write_ctx *w, struct spdk_nvmf_ struct spdk_nvmf_transport *transport; spdk_json_write_object_begin(w); - spdk_json_write_named_string(w, "method", "set_nvmf_target_options"); + spdk_json_write_named_string(w, "method", "set_nvmf_target_max_subsystems"); spdk_json_write_named_object_begin(w, "params"); - spdk_json_write_named_uint32(w, "max_queue_depth", tgt->opts.max_queue_depth); - spdk_json_write_named_uint32(w, "max_qpairs_per_ctrlr", tgt->opts.max_qpairs_per_ctrlr); - spdk_json_write_named_uint32(w, "in_capsule_data_size", tgt->opts.in_capsule_data_size); - spdk_json_write_named_uint32(w, "max_io_size", tgt->opts.max_io_size); - spdk_json_write_named_uint32(w, "max_subsystems", tgt->opts.max_subsystems); - spdk_json_write_named_uint32(w, "io_unit_size", tgt->opts.io_unit_size); + spdk_json_write_named_uint32(w, "max_subsystems", tgt->max_subsystems); spdk_json_write_object_end(w); spdk_json_write_object_end(w); @@ -605,7 +584,7 @@ spdk_nvmf_tgt_find_subsystem(struct spdk_nvmf_tgt *tgt, const char *subnqn) return NULL; } - for (sid = 0; sid < tgt->opts.max_subsystems; sid++) { + for (sid = 0; sid < tgt->max_subsystems; sid++) { subsystem = tgt->subsystems[sid]; if (subsystem == NULL) { continue; diff --git a/lib/nvmf/nvmf_internal.h b/lib/nvmf/nvmf_internal.h index 1f7be7ec03..e86c00588b 100644 --- a/lib/nvmf/nvmf_internal.h +++ b/lib/nvmf/nvmf_internal.h @@ -68,10 +68,10 @@ enum spdk_nvmf_qpair_state { typedef void (*spdk_nvmf_state_change_done)(void *cb_arg, int status); struct spdk_nvmf_tgt { - struct spdk_nvmf_tgt_opts opts; - uint64_t discovery_genctr; + uint32_t max_subsystems; + /* Array of subsystem pointers of size max_subsystems indexed by sid */ struct spdk_nvmf_subsystem **subsystems; diff --git a/lib/nvmf/subsystem.c b/lib/nvmf/subsystem.c index 9e28f3c6dc..b61755b41d 100644 --- a/lib/nvmf/subsystem.c +++ b/lib/nvmf/subsystem.c @@ -253,12 +253,12 @@ spdk_nvmf_subsystem_create(struct spdk_nvmf_tgt *tgt, } /* Find a free subsystem id (sid) */ - for (sid = 0; sid < tgt->opts.max_subsystems; sid++) { + for (sid = 0; sid < tgt->max_subsystems; sid++) { if (tgt->subsystems[sid] == NULL) { break; } } - if (sid >= tgt->opts.max_subsystems) { + if (sid >= tgt->max_subsystems) { return NULL; } @@ -559,7 +559,7 @@ spdk_nvmf_subsystem_get_first(struct spdk_nvmf_tgt *tgt) struct spdk_nvmf_subsystem *subsystem; uint32_t sid; - for (sid = 0; sid < tgt->opts.max_subsystems; sid++) { + for (sid = 0; sid < tgt->max_subsystems; sid++) { subsystem = tgt->subsystems[sid]; if (subsystem) { return subsystem; @@ -581,7 +581,7 @@ spdk_nvmf_subsystem_get_next(struct spdk_nvmf_subsystem *subsystem) tgt = subsystem->tgt; - for (sid = subsystem->id + 1; sid < tgt->opts.max_subsystems; sid++) { + for (sid = subsystem->id + 1; sid < tgt->max_subsystems; sid++) { subsystem = tgt->subsystems[sid]; if (subsystem) { return subsystem; diff --git a/scripts/config_converter.py b/scripts/config_converter.py index 1d64c60b15..6ec107729e 100755 --- a/scripts/config_converter.py +++ b/scripts/config_converter.py @@ -30,7 +30,7 @@ iscsi_dict["construct_target_node"] = [] nvmf_dict = OrderedDict() nvmf_dict["set_nvmf_target_config"] = [] -nvmf_dict["set_nvmf_target_options"] = [] +nvmf_dict["set_nvmf_target_max_subsystems"] = [] nvmf_dict["construct_nvmf_subsystem"] = [] @@ -291,11 +291,6 @@ def get_split_bdev_json(config, section): def get_nvmf_options_json(config, section): params = [ ["AcceptorPollRate", "acceptor_poll_rate", int, 10000], - ["MaxQueuesPerSession", "max_qpairs_per_ctrlr", int, 64], - ["MaxQueueDepth", "max_queue_depth", int, 128], - ["IncapsuleDataSize", "in_capsule_data_size", int, 4096], - ["MaxIOSize", "max_io_size", int, 131072], - ["IOUnitSize", "io_unit_size", int, 131072], ["MaxSubsystems", "max_subsystems", int, 1024] ] for option in config.options("Nvmf"): @@ -307,7 +302,7 @@ def get_nvmf_options_json(config, section): }) nvmf_json.append({ "params": to_json_params(params[1:7]), - "method": "set_nvmf_target_options" + "method": "set_nvmf_target_max_subsystems" }) return nvmf_json diff --git a/scripts/rpc.py b/scripts/rpc.py index 076ec15c1c..6151a85872 100755 --- a/scripts/rpc.py +++ b/scripts/rpc.py @@ -1277,6 +1277,15 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse p.add_argument('-u', '--io-unit-size', help='I/O unit size (bytes)', type=int) p.set_defaults(func=set_nvmf_target_options) + @call_cmd + def set_nvmf_target_max_subsystems(args): + rpc.nvmf.set_nvmf_target_max_subsystems(args.client, + max_subsystems=args.max_subsystems) + + p = subparsers.add_parser('set_nvmf_target_max_subsystems', help='Set the maximum number of NVMf target subsystems') + p.add_argument('-x', '--max-subsystems', help='Max number of NVMf subsystems', type=int, required=True) + p.set_defaults(func=set_nvmf_target_max_subsystems) + @call_cmd def set_nvmf_target_config(args): rpc.nvmf.set_nvmf_target_config(args.client, diff --git a/scripts/rpc/nvmf.py b/scripts/rpc/nvmf.py index 9e63c1fe6c..0cf8837776 100644 --- a/scripts/rpc/nvmf.py +++ b/scripts/rpc/nvmf.py @@ -37,6 +37,22 @@ def set_nvmf_target_options(client, return client.call('set_nvmf_target_options', params) +def set_nvmf_target_max_subsystems(client, + max_subsystems=None): + """Set NVMe-oF target options. + + Args: + max_subsystems: Maximum number of NVMe-oF subsystems (e.g. 1024) + + Returns: + True or False + """ + params = {} + + params['max_subsystems'] = max_subsystems + return client.call('set_nvmf_target_max_subsystems', params) + + def set_nvmf_target_config(client, acceptor_poll_rate=None, conn_sched=None): diff --git a/test/config_converter/spdk_config.json b/test/config_converter/spdk_config.json index 4b4ba57289..1fcdb5a1e4 100644 --- a/test/config_converter/spdk_config.json +++ b/test/config_converter/spdk_config.json @@ -182,14 +182,9 @@ }, { "params": { - "in_capsule_data_size": 4096, - "io_unit_size": 131072, - "max_qpairs_per_ctrlr": 4, - "max_queue_depth": 128, - "max_io_size": 131072, "max_subsystems": 1024 }, - "method": "set_nvmf_target_options" + "method": "set_nvmf_target_max_subsystems" }, { "params": { diff --git a/test/config_converter/spdk_config_virtio.json b/test/config_converter/spdk_config_virtio.json index 00391f0bb0..d0ec934411 100644 --- a/test/config_converter/spdk_config_virtio.json +++ b/test/config_converter/spdk_config_virtio.json @@ -88,14 +88,9 @@ }, { "params": { - "in_capsule_data_size": 4096, - "io_unit_size": 131072, - "max_qpairs_per_ctrlr": 64, - "max_queue_depth": 128, - "max_io_size": 131072, "max_subsystems": 1024 }, - "method": "set_nvmf_target_options" + "method": "set_nvmf_target_max_subsystems" } ] }, diff --git a/test/json_config/config_filter.py b/test/json_config/config_filter.py index 59e96f9471..f797a66d2e 100755 --- a/test/json_config/config_filter.py +++ b/test/json_config/config_filter.py @@ -25,7 +25,7 @@ def filter_methods(do_remove_global_rpcs): global_rpcs = [ 'set_iscsi_options', 'set_nvmf_target_config', - 'set_nvmf_target_options', + 'set_nvmf_target_max_subsystems', 'nvmf_create_transport', 'set_bdev_options', 'set_bdev_nvme_options', diff --git a/test/unit/lib/nvmf/ctrlr_discovery.c/ctrlr_discovery_ut.c b/test/unit/lib/nvmf/ctrlr_discovery.c/ctrlr_discovery_ut.c index f86bdf2bd1..88fceac344 100644 --- a/test/unit/lib/nvmf/ctrlr_discovery.c/ctrlr_discovery_ut.c +++ b/test/unit/lib/nvmf/ctrlr_discovery.c/ctrlr_discovery_ut.c @@ -218,8 +218,8 @@ test_discovery_log(void) struct spdk_nvmf_discovery_log_page_entry *entry; struct spdk_nvme_transport_id trid = {}; - tgt.opts.max_subsystems = 1024; - tgt.subsystems = calloc(tgt.opts.max_subsystems, sizeof(struct spdk_nvmf_subsystem *)); + tgt.max_subsystems = 1024; + tgt.subsystems = calloc(tgt.max_subsystems, sizeof(struct spdk_nvmf_subsystem *)); SPDK_CU_ASSERT_FATAL(tgt.subsystems != NULL); /* Add one subsystem and verify that the discovery log contains it */ diff --git a/test/unit/lib/nvmf/subsystem.c/subsystem_ut.c b/test/unit/lib/nvmf/subsystem.c/subsystem_ut.c index 1b92efd269..bd5de99791 100644 --- a/test/unit/lib/nvmf/subsystem.c/subsystem_ut.c +++ b/test/unit/lib/nvmf/subsystem.c/subsystem_ut.c @@ -253,8 +253,8 @@ test_spdk_nvmf_subsystem_add_ns(void) struct spdk_nvmf_ns_opts ns_opts; uint32_t nsid; - tgt.opts.max_subsystems = 1024; - tgt.subsystems = calloc(tgt.opts.max_subsystems, sizeof(struct spdk_nvmf_subsystem *)); + tgt.max_subsystems = 1024; + tgt.subsystems = calloc(tgt.max_subsystems, sizeof(struct spdk_nvmf_subsystem *)); SPDK_CU_ASSERT_FATAL(tgt.subsystems != NULL); /* Allow NSID to be assigned automatically */ @@ -304,8 +304,8 @@ nvmf_test_create_subsystem(void) char nqn[256]; struct spdk_nvmf_subsystem *subsystem; - tgt.opts.max_subsystems = 1024; - tgt.subsystems = calloc(tgt.opts.max_subsystems, sizeof(struct spdk_nvmf_subsystem *)); + tgt.max_subsystems = 1024; + tgt.subsystems = calloc(tgt.max_subsystems, sizeof(struct spdk_nvmf_subsystem *)); SPDK_CU_ASSERT_FATAL(tgt.subsystems != NULL); snprintf(nqn, sizeof(nqn), "nqn.2016-06.io.spdk:subsystem1");