Commit 02f088bb authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

nvmf: dynamically allocate ns array



This allows the user to configure an arbitrarily large number of
namespaces instead of the current hard-coded limit of 16.

Change-Id: I3a29b0de10eafd682b12c54e12411d1f9d41ce85
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/375636


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent db24ff75
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -117,7 +117,7 @@ spdk_add_nvmf_discovery_subsystem(void)
{
	struct nvmf_tgt_subsystem *app_subsys;

	app_subsys = nvmf_tgt_create_subsystem(SPDK_NVMF_DISCOVERY_NQN, SPDK_NVMF_SUBTYPE_DISCOVERY,
	app_subsys = nvmf_tgt_create_subsystem(SPDK_NVMF_DISCOVERY_NQN, SPDK_NVMF_SUBTYPE_DISCOVERY, 0,
					       g_spdk_nvmf_tgt_conf.acceptor_lcore);
	if (app_subsys == NULL) {
		SPDK_ERRLOG("Failed creating discovery nvmf library subsystem\n");
@@ -392,7 +392,7 @@ spdk_nvmf_construct_subsystem(const char *name, int32_t lcore,
	lcore = spdk_nvmf_allocate_lcore(mask, lcore);
	g_last_core = lcore;

	app_subsys = nvmf_tgt_create_subsystem(name, SPDK_NVMF_SUBTYPE_NVME, lcore);
	app_subsys = nvmf_tgt_create_subsystem(name, SPDK_NVMF_SUBTYPE_NVME, num_devs, lcore);
	if (app_subsys == NULL) {
		SPDK_ERRLOG("Subsystem creation failed\n");
		return -1;
+2 −2
Original line number Diff line number Diff line
@@ -185,7 +185,7 @@ nvmf_tgt_start_subsystem(struct nvmf_tgt_subsystem *app_subsys)
}

struct nvmf_tgt_subsystem *
nvmf_tgt_create_subsystem(const char *name, enum spdk_nvmf_subtype subtype,
nvmf_tgt_create_subsystem(const char *name, enum spdk_nvmf_subtype subtype, uint32_t num_ns,
			  uint32_t lcore)
{
	struct spdk_nvmf_subsystem *subsystem;
@@ -202,7 +202,7 @@ nvmf_tgt_create_subsystem(const char *name, enum spdk_nvmf_subtype subtype,
		return NULL;
	}

	subsystem = spdk_nvmf_create_subsystem(g_tgt, name, subtype, app_subsys, connect_cb,
	subsystem = spdk_nvmf_create_subsystem(g_tgt, name, subtype, num_ns, app_subsys, connect_cb,
					       disconnect_cb);
	if (subsystem == NULL) {
		SPDK_ERRLOG("Subsystem creation failed\n");
+1 −1
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ int spdk_nvmf_parse_conf(void);
void nvmf_tgt_start_subsystem(struct nvmf_tgt_subsystem *subsystem);

struct nvmf_tgt_subsystem *nvmf_tgt_create_subsystem(const char *name,
		enum spdk_nvmf_subtype subtype,
		enum spdk_nvmf_subtype subtype, uint32_t num_ns,
		uint32_t lcore);

int
+1 −2
Original line number Diff line number Diff line
@@ -45,8 +45,6 @@
#include "spdk/nvmf_spec.h"
#include "spdk/queue.h"

#define MAX_VIRTUAL_NAMESPACE 16

struct spdk_nvmf_tgt;

struct spdk_nvmf_tgt_opts {
@@ -113,6 +111,7 @@ struct spdk_nvmf_listen_addr {
struct spdk_nvmf_subsystem *spdk_nvmf_create_subsystem(struct spdk_nvmf_tgt *tgt,
		const char *nqn,
		enum spdk_nvmf_subtype type,
		uint32_t num_ns,
		void *cb_ctx,
		spdk_nvmf_subsystem_connect_fn connect_cb,
		spdk_nvmf_subsystem_disconnect_fn disconnect_cb);
+3 −1
Original line number Diff line number Diff line
@@ -90,8 +90,10 @@ struct spdk_nvmf_subsystem {

	char sn[SPDK_NVME_CTRLR_SN_LEN + 1];

	struct spdk_nvmf_ns			ns[MAX_VIRTUAL_NAMESPACE];
	/* Array of namespaces of size max_nsid indexed by nsid - 1 */
	struct spdk_nvmf_ns			*ns;
	uint32_t 				max_nsid;
	uint32_t				num_allocated_nsid;

	void					*cb_ctx;
	spdk_nvmf_subsystem_connect_fn		connect_cb;
Loading