From 1d9453641769e4c78d93415b177a1aa0d20d557f Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Wed, 18 Apr 2018 14:28:38 -0700 Subject: [PATCH] nvmf: Bound the maximum number of namespaces that can be configured Make the bound enormous, but bound it so that we don't run out of memory. Change-Id: I014b3df3be92ae8bd85fea95f514225adc3eefe2 Signed-off-by: Ben Walker Reviewed-on: https://review.gerrithub.io/408247 Reviewed-by: Daniel Verkamp Reviewed-by: Jim Harris Tested-by: SPDK Automated Test System --- lib/event/subsystems/nvmf/conf.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/event/subsystems/nvmf/conf.c b/lib/event/subsystems/nvmf/conf.c index 678b5fcd4..ca53e0a5c 100644 --- a/lib/event/subsystems/nvmf/conf.c +++ b/lib/event/subsystems/nvmf/conf.c @@ -43,6 +43,8 @@ #define ACCEPT_TIMEOUT_US 10000 /* 10ms */ +#define SPDK_NVMF_MAX_NAMESPACES (1 << 14) + struct spdk_nvmf_tgt_conf g_spdk_nvmf_tgt_conf; static int @@ -162,6 +164,8 @@ spdk_nvmf_parse_subsystem(struct spdk_conf_section *sp) if (num_ns < 1) { num_ns = 0; + } else if (num_ns > SPDK_NVMF_MAX_NAMESPACES) { + num_ns = SPDK_NVMF_MAX_NAMESPACES; } /* Mode is no longer a valid parameter, but print out a nice