From f5d88e46e22d99d3f7ccbe7fa016f9a168ed02a1 Mon Sep 17 00:00:00 2001 From: Seth Howell Date: Thu, 26 Sep 2019 12:55:30 -0700 Subject: [PATCH] nvme: always set ctrlr->is_failed through API Use the standard API function to fail the controller in all cases. This patch, and the several following patches are aimed at creating a mechanism for reporting up to the application layer that a controller is failed and or removed. To do this, I use the reset_cb to inform the upper layer that the controller is failed. This also requires changes to how we handle a controller reset to pave the way for doing optional reset retries in the libraries. Change-Id: I06dfce08326c23472a1caa8f6efbac2fd1a720f2 Signed-off-by: Seth Howell Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/469635 Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- lib/nvme/nvme_qpair.c | 2 +- test/unit/lib/nvme/nvme_qpair.c/nvme_qpair_ut.c | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/nvme/nvme_qpair.c b/lib/nvme/nvme_qpair.c index a024b3344..5a2c946fe 100644 --- a/lib/nvme/nvme_qpair.c +++ b/lib/nvme/nvme_qpair.c @@ -454,7 +454,7 @@ spdk_nvme_qpair_process_completions(struct spdk_nvme_qpair *qpair, uint32_t max_ ret = nvme_transport_qpair_process_completions(qpair, max_completions); if (ret < 0) { SPDK_ERRLOG("CQ error, abort requests after transport retry counter exceeded\n"); - qpair->ctrlr->is_failed = true; + nvme_ctrlr_fail(qpair->ctrlr, false); } qpair->in_completion_context = 0; if (qpair->delete_after_completion_context) { diff --git a/test/unit/lib/nvme/nvme_qpair.c/nvme_qpair_ut.c b/test/unit/lib/nvme/nvme_qpair.c/nvme_qpair_ut.c index 48a3a76e9..3adcc76b5 100644 --- a/test/unit/lib/nvme/nvme_qpair.c/nvme_qpair_ut.c +++ b/test/unit/lib/nvme/nvme_qpair.c/nvme_qpair_ut.c @@ -48,6 +48,15 @@ struct nvme_driver _g_nvme_driver = { .lock = PTHREAD_MUTEX_INITIALIZER, }; +void +nvme_ctrlr_fail(struct spdk_nvme_ctrlr *ctrlr, bool hot_remove) +{ + if (hot_remove) { + ctrlr->is_removed = true; + } + ctrlr->is_failed = true; +} + void nvme_transport_qpair_abort_reqs(struct spdk_nvme_qpair *qpair, uint32_t dnr) {