nvme: small code cleanup for nvme_transport_ctrlr_scan

The identify data is only valid if spdk_nvme_connect()
was used with Discovery Controller, so move this code
into the section where it belongs to.

Change-Id: I1897f38277eafc192552a09556a568e9152bb72d
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448500
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Changpeng Liu 2019-03-20 21:25:51 +08:00 committed by Ben Walker
parent fc43fbba04
commit 6129e78d26
2 changed files with 28 additions and 32 deletions

View File

@ -1381,22 +1381,22 @@ nvme_rdma_ctrlr_scan(struct spdk_nvme_probe_ctx *probe_ctx,
return -1;
}
/* get the cdata info */
rc = nvme_ctrlr_cmd_identify(discovery_ctrlr, SPDK_NVME_IDENTIFY_CTRLR, 0, 0,
&discovery_ctrlr->cdata, sizeof(discovery_ctrlr->cdata),
nvme_completion_poll_cb, &status);
if (rc != 0) {
SPDK_ERRLOG("Failed to identify cdata\n");
return rc;
}
if (spdk_nvme_wait_for_completion(discovery_ctrlr->adminq, &status)) {
SPDK_ERRLOG("nvme_identify_controller failed!\n");
return -ENXIO;
}
/* Direct attach through spdk_nvme_connect() API */
if (direct_connect == true) {
/* get the cdata info */
rc = nvme_ctrlr_cmd_identify(discovery_ctrlr, SPDK_NVME_IDENTIFY_CTRLR, 0, 0,
&discovery_ctrlr->cdata, sizeof(discovery_ctrlr->cdata),
nvme_completion_poll_cb, &status);
if (rc != 0) {
SPDK_ERRLOG("Failed to identify cdata\n");
return rc;
}
if (spdk_nvme_wait_for_completion(discovery_ctrlr->adminq, &status)) {
SPDK_ERRLOG("nvme_identify_controller failed!\n");
return -ENXIO;
}
/* Set the ready state to skip the normal init process */
discovery_ctrlr->state = NVME_CTRLR_STATE_READY;
nvme_ctrlr_connected(probe_ctx, discovery_ctrlr);

View File

@ -299,26 +299,22 @@ nvme_tcp_ctrlr_scan(struct spdk_nvme_probe_ctx *probe_ctx,
return -1;
}
/* get the cdata info */
status.done = false;
rc = nvme_ctrlr_cmd_identify(discovery_ctrlr, SPDK_NVME_IDENTIFY_CTRLR, 0, 0,
&discovery_ctrlr->cdata, sizeof(discovery_ctrlr->cdata),
nvme_completion_poll_cb, &status);
if (rc != 0) {
SPDK_ERRLOG("Failed to identify cdata\n");
return rc;
}
while (status.done == false) {
spdk_nvme_qpair_process_completions(discovery_ctrlr->adminq, 0);
}
if (spdk_nvme_cpl_is_error(&status.cpl)) {
SPDK_ERRLOG("nvme_identify_controller failed!\n");
return -ENXIO;
}
/* Direct attach through spdk_nvme_connect() API */
if (direct_connect == true) {
/* get the cdata info */
status.done = false;
rc = nvme_ctrlr_cmd_identify(discovery_ctrlr, SPDK_NVME_IDENTIFY_CTRLR, 0, 0,
&discovery_ctrlr->cdata, sizeof(discovery_ctrlr->cdata),
nvme_completion_poll_cb, &status);
if (rc != 0) {
SPDK_ERRLOG("Failed to identify cdata\n");
return rc;
}
if (spdk_nvme_wait_for_completion(discovery_ctrlr->adminq, &status)) {
SPDK_ERRLOG("nvme_identify_controller failed!\n");
return -ENXIO;
}
/* Set the ready state to skip the normal init process */
discovery_ctrlr->state = NVME_CTRLR_STATE_READY;
nvme_ctrlr_connected(probe_ctx, discovery_ctrlr);