nvmf: add hosts after creating subsystem
Remove the array of allowed hosts from the parameters of spdk_nvmf_construct_subsystem() and add the hosts individually now that we have the capability to add them after subsystem creation. Change-Id: I8b05e44d6a254f8d5848975e4bcfb7847e2cf4f3 Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-on: https://review.gerrithub.io/403377 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
333e9299b1
commit
72d72f503c
@ -41,7 +41,6 @@
|
|||||||
#include "spdk/string.h"
|
#include "spdk/string.h"
|
||||||
#include "spdk/util.h"
|
#include "spdk/util.h"
|
||||||
|
|
||||||
#define MAX_HOSTS 255
|
|
||||||
#define MAX_NAMESPACES 255
|
#define MAX_NAMESPACES 255
|
||||||
|
|
||||||
#define ACCEPT_TIMEOUT_US 10000 /* 10ms */
|
#define ACCEPT_TIMEOUT_US 10000 /* 10ms */
|
||||||
@ -146,8 +145,6 @@ spdk_nvmf_parse_subsystem(struct spdk_conf_section *sp)
|
|||||||
size_t i;
|
size_t i;
|
||||||
int ret;
|
int ret;
|
||||||
int lcore;
|
int lcore;
|
||||||
int num_hosts;
|
|
||||||
char *hosts[MAX_HOSTS];
|
|
||||||
bool allow_any_host;
|
bool allow_any_host;
|
||||||
const char *sn;
|
const char *sn;
|
||||||
struct spdk_nvmf_subsystem *subsystem;
|
struct spdk_nvmf_subsystem *subsystem;
|
||||||
@ -180,21 +177,9 @@ spdk_nvmf_parse_subsystem(struct spdk_conf_section *sp)
|
|||||||
SPDK_NOTICELOG("Please remove Core from your configuration file. Ignoring it and continuing.\n");
|
SPDK_NOTICELOG("Please remove Core from your configuration file. Ignoring it and continuing.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse Host sections */
|
|
||||||
for (i = 0; i < MAX_HOSTS; i++) {
|
|
||||||
hosts[i] = spdk_conf_section_get_nval(sp, "Host", i);
|
|
||||||
if (!hosts[i]) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
num_hosts = i;
|
|
||||||
|
|
||||||
allow_any_host = spdk_conf_section_get_boolval(sp, "AllowAnyHost", false);
|
|
||||||
|
|
||||||
sn = spdk_conf_section_get_val(sp, "SN");
|
sn = spdk_conf_section_get_val(sp, "SN");
|
||||||
|
|
||||||
subsystem = spdk_nvmf_construct_subsystem(nqn,
|
subsystem = spdk_nvmf_construct_subsystem(nqn,
|
||||||
num_hosts, hosts, allow_any_host,
|
|
||||||
sn);
|
sn);
|
||||||
|
|
||||||
if (subsystem == NULL) {
|
if (subsystem == NULL) {
|
||||||
@ -304,6 +289,20 @@ spdk_nvmf_parse_subsystem(struct spdk_conf_section *sp)
|
|||||||
spdk_nvmf_subsystem_add_listener(subsystem, &trid);
|
spdk_nvmf_subsystem_add_listener(subsystem, &trid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Parse Host sections */
|
||||||
|
for (i = 0; ; i++) {
|
||||||
|
const char *host = spdk_conf_section_get_nval(sp, "Host", i);
|
||||||
|
|
||||||
|
if (!host) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
spdk_nvmf_subsystem_add_host(subsystem, host);
|
||||||
|
}
|
||||||
|
|
||||||
|
allow_any_host = spdk_conf_section_get_boolval(sp, "AllowAnyHost", false);
|
||||||
|
spdk_nvmf_subsystem_set_allow_any_host(subsystem, allow_any_host);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
return (subsystem != NULL);
|
return (subsystem != NULL);
|
||||||
}
|
}
|
||||||
@ -349,34 +348,21 @@ spdk_nvmf_parse_conf(void)
|
|||||||
|
|
||||||
struct spdk_nvmf_subsystem *
|
struct spdk_nvmf_subsystem *
|
||||||
spdk_nvmf_construct_subsystem(const char *name,
|
spdk_nvmf_construct_subsystem(const char *name,
|
||||||
int num_hosts, char *hosts[], bool allow_any_host,
|
|
||||||
const char *sn)
|
const char *sn)
|
||||||
{
|
{
|
||||||
struct spdk_nvmf_subsystem *subsystem;
|
struct spdk_nvmf_subsystem *subsystem;
|
||||||
int i;
|
|
||||||
|
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
SPDK_ERRLOG("No NQN specified for subsystem\n");
|
SPDK_ERRLOG("No NQN specified for subsystem\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num_hosts > MAX_HOSTS) {
|
|
||||||
SPDK_ERRLOG("invalid hosts number\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
subsystem = nvmf_tgt_create_subsystem(name, SPDK_NVMF_SUBTYPE_NVME, 0);
|
subsystem = nvmf_tgt_create_subsystem(name, SPDK_NVMF_SUBTYPE_NVME, 0);
|
||||||
if (subsystem == NULL) {
|
if (subsystem == NULL) {
|
||||||
SPDK_ERRLOG("Subsystem creation failed\n");
|
SPDK_ERRLOG("Subsystem creation failed\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse Host sections */
|
|
||||||
for (i = 0; i < num_hosts; i++) {
|
|
||||||
spdk_nvmf_subsystem_add_host(subsystem, hosts[i]);
|
|
||||||
}
|
|
||||||
spdk_nvmf_subsystem_set_allow_any_host(subsystem, allow_any_host);
|
|
||||||
|
|
||||||
if (sn == NULL) {
|
if (sn == NULL) {
|
||||||
SPDK_ERRLOG("Subsystem %s: missing serial number\n", name);
|
SPDK_ERRLOG("Subsystem %s: missing serial number\n", name);
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -78,7 +78,6 @@ struct spdk_nvmf_subsystem *nvmf_tgt_create_subsystem(const char *name,
|
|||||||
enum spdk_nvmf_subtype subtype, uint32_t num_ns);
|
enum spdk_nvmf_subtype subtype, uint32_t num_ns);
|
||||||
|
|
||||||
struct spdk_nvmf_subsystem *spdk_nvmf_construct_subsystem(const char *name,
|
struct spdk_nvmf_subsystem *spdk_nvmf_construct_subsystem(const char *name,
|
||||||
int num_hosts, char *hosts[], bool allow_any_host,
|
|
||||||
const char *sn);
|
const char *sn);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -606,12 +606,17 @@ spdk_rpc_construct_nvmf_subsystem(struct spdk_jsonrpc_request *request,
|
|||||||
}
|
}
|
||||||
|
|
||||||
subsystem = spdk_nvmf_construct_subsystem(req.nqn,
|
subsystem = spdk_nvmf_construct_subsystem(req.nqn,
|
||||||
req.hosts.num_hosts, req.hosts.hosts, req.allow_any_host,
|
|
||||||
req.serial_number);
|
req.serial_number);
|
||||||
if (!subsystem) {
|
if (!subsystem) {
|
||||||
goto invalid;
|
goto invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < req.hosts.num_hosts; i++) {
|
||||||
|
spdk_nvmf_subsystem_add_host(subsystem, req.hosts.hosts[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
spdk_nvmf_subsystem_set_allow_any_host(subsystem, req.allow_any_host);
|
||||||
|
|
||||||
for (i = 0; i < req.listen_addresses.num_listen_address; i++) {
|
for (i = 0; i < req.listen_addresses.num_listen_address; i++) {
|
||||||
struct rpc_listen_address *addr = &req.listen_addresses.addresses[i];
|
struct rpc_listen_address *addr = &req.listen_addresses.addresses[i];
|
||||||
struct spdk_nvme_transport_id trid = {0};
|
struct spdk_nvme_transport_id trid = {0};
|
||||||
|
Loading…
Reference in New Issue
Block a user