nvmf: Only present subsystem if it is ready
We do not want to present those subsystems which are not ready. Change-Id: I7f5c171fbac4c31d839421e37e93e62569c0e87a Signed-off-by: Ziye Yang <optimistyzy@gmail.com> Reviewed-on: https://review.gerrithub.io/c/437222 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Seth Howell <seth.howell5141@gmail.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
19feb4e181
commit
f31096782c
@ -358,6 +358,13 @@ spdk_nvmf_ctrlr_connect(struct spdk_nvmf_request *req)
|
||||
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
|
||||
}
|
||||
|
||||
if (subsystem->state != SPDK_NVMF_SUBSYSTEM_ACTIVE) {
|
||||
SPDK_ERRLOG("Subsystem '%s' is not ready\n", subnqn);
|
||||
rsp->status.sct = SPDK_NVME_SCT_COMMAND_SPECIFIC;
|
||||
rsp->status.sc = SPDK_NVMF_FABRIC_SC_CONTROLLER_BUSY;
|
||||
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
|
||||
}
|
||||
|
||||
/* Ensure that hostnqn is null terminated */
|
||||
end = memchr(data->hostnqn, '\0', SPDK_NVMF_NQN_MAX_LEN + 1);
|
||||
if (!end) {
|
||||
|
@ -71,7 +71,9 @@ nvmf_update_discovery_log(struct spdk_nvmf_tgt *tgt)
|
||||
|
||||
for (sid = 0; sid < tgt->max_subsystems; sid++) {
|
||||
subsystem = tgt->subsystems[sid];
|
||||
if (subsystem == NULL) {
|
||||
if ((subsystem == NULL) ||
|
||||
(subsystem->state == SPDK_NVMF_SUBSYSTEM_INACTIVE) ||
|
||||
(subsystem->state == SPDK_NVMF_SUBSYSTEM_DEACTIVATING)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -308,6 +308,7 @@ test_connect(void)
|
||||
TAILQ_INIT(&subsystem.ctrlrs);
|
||||
subsystem.tgt = &tgt;
|
||||
subsystem.subtype = SPDK_NVMF_SUBTYPE_NVME;
|
||||
subsystem.state = SPDK_NVMF_SUBSYSTEM_ACTIVE;
|
||||
snprintf(subsystem.subnqn, sizeof(subsystem.subnqn), "%s", subnqn);
|
||||
|
||||
memset(&cmd, 0, sizeof(cmd));
|
||||
@ -483,6 +484,7 @@ test_connect(void)
|
||||
/* I/O connect to discovery controller */
|
||||
memset(&rsp, 0, sizeof(rsp));
|
||||
subsystem.subtype = SPDK_NVMF_SUBTYPE_DISCOVERY;
|
||||
subsystem.state = SPDK_NVMF_SUBSYSTEM_ACTIVE;
|
||||
rc = spdk_nvmf_ctrlr_connect(&req);
|
||||
poll_threads();
|
||||
CU_ASSERT(rc == SPDK_NVMF_REQUEST_EXEC_STATUS_ASYNCHRONOUS);
|
||||
|
@ -239,6 +239,7 @@ test_discovery_log(void)
|
||||
snprintf(trid.traddr, sizeof(trid.traddr), "1234");
|
||||
snprintf(trid.trsvcid, sizeof(trid.trsvcid), "5678");
|
||||
SPDK_CU_ASSERT_FATAL(spdk_nvmf_subsystem_add_listener(subsystem, &trid) == 0);
|
||||
subsystem->state = SPDK_NVMF_SUBSYSTEM_ACTIVE;
|
||||
|
||||
/* Get only genctr (first field in the header) */
|
||||
memset(buffer, 0xCC, sizeof(buffer));
|
||||
@ -280,6 +281,7 @@ test_discovery_log(void)
|
||||
offsetof(struct spdk_nvmf_discovery_log_page, entries[0]),
|
||||
sizeof(*entry));
|
||||
CU_ASSERT(entry->trtype == 42);
|
||||
subsystem->state = SPDK_NVMF_SUBSYSTEM_INACTIVE;
|
||||
spdk_nvmf_subsystem_destroy(subsystem);
|
||||
free(tgt.subsystems);
|
||||
free(tgt.discovery_log_page);
|
||||
|
Loading…
x
Reference in New Issue
Block a user