From 6546fd10f826fa46d1e228bd6a5b5b679b1378b3 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Tue, 12 Jun 2018 10:11:45 -0700 Subject: [PATCH] nvmf/rpc: add max_namespaces to get_nvmf_subsystems This is one of the construct_nvmf_subsystems parameters, so we need a public API to retrieve it for informational purposes and for the JSON-RPC configuration dump. Change-Id: I8a7cafa487209311e964ea9ff1b8e09ee8b23c07 Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/414864 Tested-by: SPDK Automated Test System Reviewed-by: Pawel Wodkowski Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- include/spdk/nvmf.h | 9 +++++++++ lib/event/subsystems/nvmf/nvmf_rpc.c | 7 +++++++ lib/nvmf/subsystem.c | 6 ++++++ 3 files changed, 22 insertions(+) diff --git a/include/spdk/nvmf.h b/include/spdk/nvmf.h index 191436430..0706fd25e 100644 --- a/include/spdk/nvmf.h +++ b/include/spdk/nvmf.h @@ -566,6 +566,15 @@ struct spdk_nvmf_ns *spdk_nvmf_subsystem_get_next_ns(struct spdk_nvmf_subsystem struct spdk_nvmf_ns *spdk_nvmf_subsystem_get_ns(struct spdk_nvmf_subsystem *subsystem, uint32_t nsid); +/** + * Get the maximum number of namespaces allowed in a subsystem. + * + * \param subsystem Subsystem to query. + * + * \return Maximum number of namespaces allowed in the subsystem, or 0 for unlimited. + */ +uint32_t spdk_nvmf_subsystem_get_max_namespaces(const struct spdk_nvmf_subsystem *subsystem); + /** * Get a namespace's NSID. * diff --git a/lib/event/subsystems/nvmf/nvmf_rpc.c b/lib/event/subsystems/nvmf/nvmf_rpc.c index b4a72009c..165a63bdf 100644 --- a/lib/event/subsystems/nvmf/nvmf_rpc.c +++ b/lib/event/subsystems/nvmf/nvmf_rpc.c @@ -251,9 +251,16 @@ dump_nvmf_subsystem(struct spdk_json_write_ctx *w, struct spdk_nvmf_subsystem *s if (spdk_nvmf_subsystem_get_type(subsystem) == SPDK_NVMF_SUBTYPE_NVME) { struct spdk_nvmf_ns *ns; struct spdk_nvmf_ns_opts ns_opts; + uint32_t max_namespaces; spdk_json_write_name(w, "serial_number"); spdk_json_write_string(w, spdk_nvmf_subsystem_get_sn(subsystem)); + + max_namespaces = spdk_nvmf_subsystem_get_max_namespaces(subsystem); + if (max_namespaces != 0) { + spdk_json_write_named_uint32(w, "max_namespaces", max_namespaces); + } + spdk_json_write_name(w, "namespaces"); spdk_json_write_array_begin(w); for (ns = spdk_nvmf_subsystem_get_first_ns(subsystem); ns != NULL; diff --git a/lib/nvmf/subsystem.c b/lib/nvmf/subsystem.c index 3697c40d3..2751d268f 100644 --- a/lib/nvmf/subsystem.c +++ b/lib/nvmf/subsystem.c @@ -1245,3 +1245,9 @@ spdk_nvmf_subsystem_get_ctrlr(struct spdk_nvmf_subsystem *subsystem, uint16_t cn return NULL; } + +uint32_t +spdk_nvmf_subsystem_get_max_namespaces(const struct spdk_nvmf_subsystem *subsystem) +{ + return subsystem->max_allowed_nsid; +}