From 3608464f04812dc089577214415f5ee6541a61de Mon Sep 17 00:00:00 2001 From: Ziye Yang Date: Sat, 12 Jan 2019 02:04:52 +0800 Subject: [PATCH] nvme: fix the aer request sent to disabled controller The purpose this patch is to fix the following issue: https://github.com/spdk/spdk/issues/568. The root cause of issue is in nvme_rdma_fail_qpair since we want to recycle all outstanding rdma_reqs. There is an aer req, the callback of which is: nvme_ctrlr_async_event_cb. In this function, we will call nvme_ctrlr_construct_and_submit_aer again, however the nvme controller is already in shutdown state. (The ctrlr->vcprop.cc.bits.en is set to 0). Change-Id: I422f0fe5faf472e9a1cb6bbd174e806e6405b95c Signed-off-by: Ziye Yang Reviewed-on: https://review.gerrithub.io/c/440014 Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- lib/nvme/nvme_ctrlr.c | 7 +++++++ lib/nvme/nvme_internal.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/lib/nvme/nvme_ctrlr.c b/lib/nvme/nvme_ctrlr.c index b404c7f4e..39a6ac3b5 100644 --- a/lib/nvme/nvme_ctrlr.c +++ b/lib/nvme/nvme_ctrlr.c @@ -535,6 +535,7 @@ nvme_ctrlr_shutdown(struct spdk_nvme_ctrlr *ctrlr) if (csts.bits.shst == SPDK_NVME_SHST_COMPLETE) { SPDK_DEBUGLOG(SPDK_LOG_NVME, "shutdown complete in %u milliseconds\n", ms_waited); + ctrlr->is_shutdown = true; return; } @@ -1520,6 +1521,11 @@ nvme_ctrlr_async_event_cb(void *arg, const struct spdk_nvme_cpl *cpl) active_proc->aer_cb_fn(active_proc->aer_cb_arg, cpl); } + /* If the ctrlr is already shutdown, we should not send aer again */ + if (ctrlr->is_shutdown) { + return; + } + /* * Repost another asynchronous event request to replace the one * that just completed. @@ -2198,6 +2204,7 @@ nvme_ctrlr_construct(struct spdk_nvme_ctrlr *ctrlr) ctrlr->free_io_qids = NULL; ctrlr->is_resetting = false; ctrlr->is_failed = false; + ctrlr->is_shutdown = false; TAILQ_INIT(&ctrlr->active_io_qpairs); STAILQ_INIT(&ctrlr->queued_aborts); diff --git a/lib/nvme/nvme_internal.h b/lib/nvme/nvme_internal.h index 41522948a..92d4753e9 100644 --- a/lib/nvme/nvme_internal.h +++ b/lib/nvme/nvme_internal.h @@ -602,6 +602,8 @@ struct spdk_nvme_ctrlr { bool is_failed; + bool is_shutdown; + bool timeout_enabled; uint16_t max_sges;