nvme: save last transport_failure_reason in transport

If a reconnect fails, we restore the original
transport_failure_reason after we're done with
the failed reconnect.  Save the original reason
in the qpair itself rather than a local variable,
to facilitate upcoming changes where connect will
be asynchronous.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I20ff43fc687a379aa5c930e17cf3ff8d730320be
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8116
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: <dongx.yi@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Jim Harris 2021-05-28 06:26:24 +00:00 committed by Ben Walker
parent 43b4883217
commit b333f00627
2 changed files with 3 additions and 3 deletions

View File

@ -455,6 +455,7 @@ struct spdk_nvme_qpair {
const struct spdk_nvme_transport *transport;
uint8_t transport_failure_reason: 2;
uint8_t last_transport_failure_reason: 2;
};
struct spdk_nvme_poll_group {

View File

@ -347,7 +347,6 @@ 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);
uint8_t transport_failure_reason;
int rc;
assert(transport != NULL);
@ -355,7 +354,7 @@ nvme_transport_ctrlr_connect_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nv
qpair->transport = transport;
}
transport_failure_reason = qpair->transport_failure_reason;
qpair->last_transport_failure_reason = qpair->transport_failure_reason;
qpair->transport_failure_reason = SPDK_NVME_QPAIR_FAILURE_NONE;
nvme_qpair_set_state(qpair, NVME_QPAIR_CONNECTING);
@ -376,7 +375,7 @@ nvme_transport_ctrlr_connect_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nv
err:
/* If the qpair was unable to reconnect, restore the original failure reason. */
qpair->transport_failure_reason = transport_failure_reason;
qpair->transport_failure_reason = qpair->last_transport_failure_reason;
nvme_transport_ctrlr_disconnect_qpair(ctrlr, qpair);
nvme_qpair_set_state(qpair, NVME_QPAIR_DISCONNECTED);
return rc;