From 9f860c310f429e1b1d25c63cae658add84ebcb18 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Thu, 24 Feb 2022 08:17:55 +0000 Subject: [PATCH] bdev/nvme: cycle through discovery paths on ctrlr failure Also cycle through the discovery paths if the initial connect_async() operation fails. Signed-off-by: Jim Harris Change-Id: I50f36949d9bba0e3bff81505712076f1a1a7aad5 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11773 Tested-by: SPDK CI Jenkins Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Reviewed-by: Ben Walker Reviewed-by: Aleksey Marchuk Reviewed-by: Shuhei Matsumoto --- module/bdev/nvme/bdev_nvme.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/module/bdev/nvme/bdev_nvme.c b/module/bdev/nvme/bdev_nvme.c index cc05b6e21..fb92239e9 100644 --- a/module/bdev/nvme/bdev_nvme.c +++ b/module/bdev/nvme/bdev_nvme.c @@ -4665,12 +4665,12 @@ discovery_poller(void *arg) } else if (ctx->probe_ctx == NULL && ctx->ctrlr == NULL) { assert(ctx->entry_ctx_in_use == NULL); ctx->entry_ctx_in_use = TAILQ_FIRST(&ctx->discovery_entry_ctxs); + TAILQ_REMOVE(&ctx->discovery_entry_ctxs, ctx->entry_ctx_in_use, tailq); trid = &ctx->entry_ctx_in_use->trid; ctx->probe_ctx = spdk_nvme_connect_async(trid, &ctx->drv_opts, discovery_attach_cb); - if (ctx->probe_ctx) { - TAILQ_REMOVE(&ctx->discovery_entry_ctxs, ctx->entry_ctx_in_use, tailq); - } else { + if (!ctx->probe_ctx) { DISCOVERY_ERRLOG(ctx, "could not start discovery connect\n"); + TAILQ_INSERT_TAIL(&ctx->discovery_entry_ctxs, ctx->entry_ctx_in_use, tailq); ctx->entry_ctx_in_use = NULL; } } else if (ctx->probe_ctx) { @@ -4683,7 +4683,17 @@ discovery_poller(void *arg) } } } else { - spdk_nvme_ctrlr_process_admin_completions(ctx->ctrlr); + rc = spdk_nvme_ctrlr_process_admin_completions(ctx->ctrlr); + if (rc < 0) { + TAILQ_INSERT_TAIL(&ctx->discovery_entry_ctxs, ctx->entry_ctx_in_use, tailq); + ctx->entry_ctx_in_use = NULL; + + rc = spdk_nvme_detach_async(ctx->ctrlr, &ctx->detach_ctx); + if (rc != 0) { + DISCOVERY_ERRLOG(ctx, "could not detach discovery ctrlr\n"); + ctx->ctrlr = NULL; + } + } } return SPDK_POLLER_BUSY;