From 9633d482a71f98e21d325c98b83d7b2b5fc8c745 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Wed, 21 Sep 2022 00:22:32 +0000 Subject: [PATCH] nvmf: emit add_listeners RPCs after add_ns RPCs When emitting the JSON-RPC text for saving the current configuration, add the listeners last. This is usually the preferred order when configuring a new subsystem - it is better to have all of the namespaces and hosts added to the subsystem before adding the listener to allow hosts to connect to it. We support namespace hotplug but there's no need to unnecessarily generate hotplug events if we can avoid it. Signed-off-by: Jim Harris Change-Id: I79e8a0a496eeb128efbb7e314ac835b6110d3cc8 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14586 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Aleksey Marchuk Reviewed-by: Tomasz Zawadzki --- lib/nvmf/nvmf.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/lib/nvmf/nvmf.c b/lib/nvmf/nvmf.c index 7dd4f3d2a..469221954 100644 --- a/lib/nvmf/nvmf.c +++ b/lib/nvmf/nvmf.c @@ -479,26 +479,6 @@ nvmf_write_subsystem_config_json(struct spdk_json_write_ctx *w, /* } */ spdk_json_write_object_end(w); - for (listener = spdk_nvmf_subsystem_get_first_listener(subsystem); listener != NULL; - listener = spdk_nvmf_subsystem_get_next_listener(subsystem, listener)) { - trid = spdk_nvmf_subsystem_listener_get_trid(listener); - - spdk_json_write_object_begin(w); - spdk_json_write_named_string(w, "method", "nvmf_subsystem_add_listener"); - - /* "params" : { */ - spdk_json_write_named_object_begin(w, "params"); - - spdk_json_write_named_string(w, "nqn", spdk_nvmf_subsystem_get_nqn(subsystem)); - nvmf_transport_listen_dump_opts(listener->transport, trid, w); - - /* } "params" */ - spdk_json_write_object_end(w); - - /* } */ - spdk_json_write_object_end(w); - } - for (host = spdk_nvmf_subsystem_get_first_host(subsystem); host != NULL; host = spdk_nvmf_subsystem_get_next_host(subsystem, host)) { @@ -565,6 +545,27 @@ nvmf_write_subsystem_config_json(struct spdk_json_write_ctx *w, /* } */ spdk_json_write_object_end(w); } + + for (listener = spdk_nvmf_subsystem_get_first_listener(subsystem); listener != NULL; + listener = spdk_nvmf_subsystem_get_next_listener(subsystem, listener)) { + trid = spdk_nvmf_subsystem_listener_get_trid(listener); + + spdk_json_write_object_begin(w); + spdk_json_write_named_string(w, "method", "nvmf_subsystem_add_listener"); + + /* "params" : { */ + spdk_json_write_named_object_begin(w, "params"); + + spdk_json_write_named_string(w, "nqn", spdk_nvmf_subsystem_get_nqn(subsystem)); + nvmf_transport_listen_dump_opts(listener->transport, trid, w); + + /* } "params" */ + spdk_json_write_object_end(w); + + /* } */ + spdk_json_write_object_end(w); + } + } void