From 59746336cb57293aec54691e15366af0e2a0fb2f Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Mon, 4 Mar 2019 23:05:40 -0500 Subject: [PATCH] nvme: return error if the controller with probe context got errors Change-Id: I72b2ab93d15a82c20d90e787248248b15bc197c7 Signed-off-by: Changpeng Liu Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/447021 Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Shuhei Matsumoto --- include/spdk/nvme.h | 9 +++++---- lib/nvme/nvme.c | 18 ++++++++++++------ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/include/spdk/nvme.h b/include/spdk/nvme.h index 8c6f4c2ad..0e134ea63 100644 --- a/include/spdk/nvme.h +++ b/include/spdk/nvme.h @@ -612,12 +612,13 @@ struct spdk_nvme_probe_ctx *spdk_nvme_probe_async(const struct spdk_nvme_transpo * * \param probe_ctx Context used to track probe actions. * - * \return true if all probe operations are complete; the probe_ctx + * \return 0 if all probe operations are complete; the probe_ctx * is also freed and no longer valid. - * \return false if there are still pending probe operations; user must call - * spdk_nvme_probe_poll_async again to continue progress. + * \return -EAGAIN if there are still pending probe operations; user must call + * spdk_nvme_probe_poll_async again to continue progress. + * \return value other than 0 and -EAGAIN probe error with one controller. */ -bool spdk_nvme_probe_poll_async(struct spdk_nvme_probe_ctx *probe_ctx); +int spdk_nvme_probe_poll_async(struct spdk_nvme_probe_ctx *probe_ctx); /** * Detach specified device returned by spdk_nvme_probe()'s attach_cb from the diff --git a/lib/nvme/nvme.c b/lib/nvme/nvme.c index a148c9bd2..6d042932a 100644 --- a/lib/nvme/nvme.c +++ b/lib/nvme/nvme.c @@ -1092,28 +1092,34 @@ spdk_nvme_probe_async(const struct spdk_nvme_transport_id *trid, return probe_ctx; } -bool +int spdk_nvme_probe_poll_async(struct spdk_nvme_probe_ctx *probe_ctx) { + int rc = 0; struct spdk_nvme_ctrlr *ctrlr, *ctrlr_tmp; if (!spdk_process_is_primary() && probe_ctx->trid.trtype == SPDK_NVME_TRANSPORT_PCIE) { free(probe_ctx); - return true; + return 0; } TAILQ_FOREACH_SAFE(ctrlr, &probe_ctx->init_ctrlrs, tailq, ctrlr_tmp) { - nvme_ctrlr_poll_internal(ctrlr, probe_ctx); + rc = nvme_ctrlr_poll_internal(ctrlr, probe_ctx); + if (rc != 0) { + rc = -EIO; + break; + } } - if (TAILQ_EMPTY(&probe_ctx->init_ctrlrs)) { + if (rc != 0 || TAILQ_EMPTY(&probe_ctx->init_ctrlrs)) { nvme_robust_mutex_lock(&g_spdk_nvme_driver->lock); g_spdk_nvme_driver->initialized = true; nvme_robust_mutex_unlock(&g_spdk_nvme_driver->lock); free(probe_ctx); - return true; + return rc; } - return false; + + return -EAGAIN; } SPDK_LOG_REGISTER_COMPONENT("nvme", SPDK_LOG_NVME)