Commit 5e98dfd1 authored by suman chakraborty's avatar suman chakraborty Committed by Jim Harris
Browse files

nvmf: add capability to add namespaces dynamically during active connection



1) The user should provide MaxNamespaces during the construction of the subsystem
2) The namespace which is added should have nsid less than or equal to MaxNamespaces
3) If the user does not provides MaxNamespaces then the exsisting behaviour continues where the nisd can grow dynamically when it is not connected.

Change-Id: I54769d9669575a5f6bf56fe5a262191ac51c474d
Signed-off-by: default avatarsuman chakraborty <suman.chakraborty@wdc.com>
Reviewed-on: https://review.gerrithub.io/405375


Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 3709dfd6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -244,6 +244,7 @@ hosts | Optional | array | Array of strings containing a
allow_any_host          | Optional | boolean     | Allow any host (`true`) or enforce allowed host whitelist (`false`). Default: `false`.
serial_number           | Required | string      | Serial number of virtual controller
namespaces              | Optional | array       | Array of @ref rpc_construct_nvmf_subsystem_namespace objects. Default: No namespaces.
MaxNamespaces           | Optional | number      | Maximum number of namespaces that can be attached to the subsystem. Default: 0 (Unlimited)

### listen_address {#rpc_construct_nvmf_subsystem_listen_address}

+6 −3
Original line number Diff line number Diff line
@@ -116,6 +116,8 @@
#   are allowed to connect.
# - Between 0 and 255 Namespace directives are allowed. These define the
#   namespaces accessible from this subsystem.
#   The user must specify MaxNamespaces to allow for adding namespaces
#   during active connection. By default it is 0
#   The user must specify a bdev name for each namespace, and may optionally
#   specify a namespace ID. If nsid is omitted, the namespace will be
#   assigned the next available NSID. The NSID must be unique within the
@@ -130,6 +132,7 @@
  AllowAnyHost No
  Host nqn.2016-06.io.spdk:init
  SN SPDK00000000000001
  MaxNamespaces 20
  Namespace Nvme0n1 1
  Namespace Nvme1n1 2

+7 −1
Original line number Diff line number Diff line
@@ -138,10 +138,16 @@ spdk_nvmf_parse_subsystem(struct spdk_conf_section *sp)
	bool allow_any_host;
	const char *sn;
	struct spdk_nvmf_subsystem *subsystem;
	int num_ns;

	nqn = spdk_conf_section_get_val(sp, "NQN");
	mode = spdk_conf_section_get_val(sp, "Mode");
	lcore = spdk_conf_section_get_intval(sp, "Core");
	num_ns = spdk_conf_section_get_intval(sp, "MaxNamespaces");

	if (num_ns < 1) {
		num_ns = 0;
	}

	/* Mode is no longer a valid parameter, but print out a nice
	 * message if it exists to inform users.
@@ -173,7 +179,7 @@ spdk_nvmf_parse_subsystem(struct spdk_conf_section *sp)
		return -1;
	}

	subsystem = spdk_nvmf_subsystem_create(g_spdk_nvmf_tgt, nqn, SPDK_NVMF_SUBTYPE_NVME, 0);
	subsystem = spdk_nvmf_subsystem_create(g_spdk_nvmf_tgt, nqn, SPDK_NVMF_SUBTYPE_NVME, num_ns);
	if (subsystem == NULL) {
		goto done;
	}
+4 −1
Original line number Diff line number Diff line
@@ -532,6 +532,7 @@ struct rpc_subsystem {
	char *pci_address;
	char *serial_number;
	struct rpc_namespaces namespaces;
	uint32_t num_ns;
};

static void
@@ -570,6 +571,7 @@ static const struct spdk_json_object_decoder rpc_subsystem_decoders[] = {
	{"allow_any_host", offsetof(struct rpc_subsystem, allow_any_host), spdk_json_decode_bool, true},
	{"serial_number", offsetof(struct rpc_subsystem, serial_number), spdk_json_decode_string, true},
	{"namespaces", offsetof(struct rpc_subsystem, namespaces), decode_rpc_namespaces, true},
	{"max_namespaces", offsetof(struct rpc_subsystem, num_ns), spdk_json_decode_uint32, true},
};

static void
@@ -613,7 +615,8 @@ spdk_rpc_construct_nvmf_subsystem(struct spdk_jsonrpc_request *request,
		SPDK_NOTICELOG("Ignoring it and continuing.\n");
	}

	subsystem = spdk_nvmf_subsystem_create(g_spdk_nvmf_tgt, req.nqn, SPDK_NVMF_SUBTYPE_NVME, 0);
	subsystem = spdk_nvmf_subsystem_create(g_spdk_nvmf_tgt, req.nqn, SPDK_NVMF_SUBTYPE_NVME,
					       req.num_ns);
	if (!subsystem) {
		goto invalid;
	}
+2 −0
Original line number Diff line number Diff line
@@ -204,6 +204,8 @@ struct spdk_nvmf_subsystem {
	/* Array of pointers to namespaces of size max_nsid indexed by nsid - 1 */
	struct spdk_nvmf_ns			**ns;
	uint32_t				max_nsid;
	/* This is the maximum allowed nsid to a subsystem */
	uint32_t				max_allowed_nsid;
	uint32_t				num_allocated_nsid;

	TAILQ_HEAD(, spdk_nvmf_ctrlr)		ctrlrs;
Loading