From b333f00627d3344695c8ad3ec03978a8504f96aa Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Fri, 28 May 2021 06:26:24 +0000 Subject: [PATCH] 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 Change-Id: I20ff43fc687a379aa5c930e17cf3ff8d730320be Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8116 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Changpeng Liu Reviewed-by: Reviewed-by: Aleksey Marchuk Reviewed-by: Ben Walker Reviewed-by: Shuhei Matsumoto --- lib/nvme/nvme_internal.h | 1 + lib/nvme/nvme_transport.c | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/nvme/nvme_internal.h b/lib/nvme/nvme_internal.h index b23a9fc915..ebedac38f2 100644 --- a/lib/nvme/nvme_internal.h +++ b/lib/nvme/nvme_internal.h @@ -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 { diff --git a/lib/nvme/nvme_transport.c b/lib/nvme/nvme_transport.c index 7037d41913..f2bb19d9da 100644 --- a/lib/nvme/nvme_transport.c +++ b/lib/nvme/nvme_transport.c @@ -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;