lib/nvme: move common connect code into transport shim
This gets rid of some duplicate lines of code. Change-Id: I24d4864921f6030672f3640b33f88f37a9e8175a Signed-off-by: Seth Howell <seth.howell@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1136 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> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
parent
d559562eaf
commit
f146bbe42d
@ -362,7 +362,6 @@ spdk_nvme_ctrlr_alloc_io_qpair(struct spdk_nvme_ctrlr *ctrlr,
|
||||
nvme_robust_mutex_unlock(&ctrlr->ctrlr_lock);
|
||||
return NULL;
|
||||
}
|
||||
nvme_qpair_set_state(qpair, NVME_QPAIR_CONNECTED);
|
||||
spdk_bit_array_clear(ctrlr->free_io_qids, qid);
|
||||
TAILQ_INSERT_TAIL(&ctrlr->active_io_qpairs, qpair, tailq);
|
||||
|
||||
@ -415,12 +414,9 @@ spdk_nvme_ctrlr_reconnect_io_qpair(struct spdk_nvme_qpair *qpair)
|
||||
|
||||
rc = nvme_transport_ctrlr_connect_qpair(ctrlr, qpair);
|
||||
if (rc) {
|
||||
nvme_qpair_set_state(qpair, NVME_QPAIR_DISABLED);
|
||||
rc = -EAGAIN;
|
||||
goto out;
|
||||
}
|
||||
qpair->transport_failure_reason = SPDK_NVME_QPAIR_FAILURE_NONE;
|
||||
nvme_qpair_set_state(qpair, NVME_QPAIR_CONNECTED);
|
||||
|
||||
out:
|
||||
nvme_robust_mutex_unlock(&ctrlr->ctrlr_lock);
|
||||
@ -1112,12 +1108,9 @@ spdk_nvme_ctrlr_reset(struct spdk_nvme_ctrlr *ctrlr)
|
||||
nvme_transport_ctrlr_disconnect_qpair(ctrlr, ctrlr->adminq);
|
||||
if (nvme_transport_ctrlr_connect_qpair(ctrlr, ctrlr->adminq) != 0) {
|
||||
SPDK_ERRLOG("Controller reinitialization failed.\n");
|
||||
nvme_qpair_set_state(ctrlr->adminq, NVME_QPAIR_DISABLED);
|
||||
rc = -1;
|
||||
goto out;
|
||||
}
|
||||
ctrlr->adminq->transport_failure_reason = SPDK_NVME_QPAIR_FAILURE_NONE;
|
||||
nvme_qpair_set_state(ctrlr->adminq, NVME_QPAIR_CONNECTED);
|
||||
|
||||
/* Doorbell buffer config is invalid during reset */
|
||||
nvme_ctrlr_free_doorbell_buffer(ctrlr);
|
||||
@ -1146,12 +1139,9 @@ spdk_nvme_ctrlr_reset(struct spdk_nvme_ctrlr *ctrlr)
|
||||
TAILQ_FOREACH(qpair, &ctrlr->active_io_qpairs, tailq) {
|
||||
if (nvme_transport_ctrlr_connect_qpair(ctrlr, qpair) != 0) {
|
||||
qpair->transport_failure_reason = SPDK_NVME_QPAIR_FAILURE_LOCAL;
|
||||
nvme_qpair_set_state(qpair, NVME_QPAIR_DISABLED);
|
||||
rc = -1;
|
||||
continue;
|
||||
}
|
||||
qpair->transport_failure_reason = SPDK_NVME_QPAIR_FAILURE_NONE;
|
||||
nvme_qpair_set_state(qpair, NVME_QPAIR_CONNECTED);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1200,7 +1200,6 @@ nvme_rdma_ctrlr_connect_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_qp
|
||||
rc = nvme_fabric_qpair_connect(&rqpair->qpair, rqpair->num_entries);
|
||||
if (rc < 0) {
|
||||
rqpair->qpair.transport_failure_reason = SPDK_NVME_QPAIR_FAILURE_UNKNOWN;
|
||||
nvme_qpair_set_state(&rqpair->qpair, NVME_QPAIR_DISABLED);
|
||||
SPDK_ERRLOG("Failed to send an NVMe-oF Fabric CONNECT command\n");
|
||||
return -1;
|
||||
}
|
||||
|
@ -1537,7 +1537,6 @@ nvme_tcp_ctrlr_connect_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_qpa
|
||||
|
||||
rc = nvme_fabric_qpair_connect(&tqpair->qpair, tqpair->num_entries);
|
||||
if (rc < 0) {
|
||||
nvme_qpair_set_state(&tqpair->qpair, NVME_QPAIR_DISABLED);
|
||||
SPDK_ERRLOG("Failed to send an NVMe-oF Fabric CONNECT command\n");
|
||||
return -1;
|
||||
}
|
||||
|
@ -267,13 +267,22 @@ int
|
||||
nvme_transport_ctrlr_connect_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_qpair *qpair)
|
||||
{
|
||||
const struct spdk_nvme_transport *transport = nvme_get_transport(ctrlr->trid.trstring);
|
||||
int rc;
|
||||
|
||||
assert(transport != NULL);
|
||||
if (!nvme_qpair_is_admin_queue(qpair)) {
|
||||
qpair->transport = transport;
|
||||
}
|
||||
nvme_qpair_set_state(qpair, NVME_QPAIR_CONNECTING);
|
||||
return transport->ops.ctrlr_connect_qpair(ctrlr, qpair);
|
||||
rc = transport->ops.ctrlr_connect_qpair(ctrlr, qpair);
|
||||
if (rc == 0) {
|
||||
nvme_qpair_set_state(qpair, NVME_QPAIR_CONNECTED);
|
||||
qpair->transport_failure_reason = SPDK_NVME_QPAIR_FAILURE_NONE;
|
||||
} else {
|
||||
nvme_qpair_set_state(qpair, NVME_QPAIR_DISABLED);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user