From 43d17a844c11d622647612c338b37451454d06c0 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Fri, 25 Feb 2022 02:00:44 +0000 Subject: [PATCH] bdev/nvme: handle detach first in discovery_poller This will be helpful in later patches, when we handle detach not just at discovery service stop, but also when a discovery controller is disconnected. Signed-off-by: Jim Harris Change-Id: Ie62d62f73b328c6e058f6480c61fbdf91e854e2a Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11767 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Changpeng Liu Reviewed-by: Shuhei Matsumoto --- module/bdev/nvme/bdev_nvme.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/module/bdev/nvme/bdev_nvme.c b/module/bdev/nvme/bdev_nvme.c index 685145780..8303e3925 100644 --- a/module/bdev/nvme/bdev_nvme.c +++ b/module/bdev/nvme/bdev_nvme.c @@ -4456,17 +4456,7 @@ discovery_poller(void *arg) struct discovery_ctx *ctx = arg; int rc; - if (ctx->probe_ctx) { - rc = spdk_nvme_probe_poll_async(ctx->probe_ctx); - if (rc != -EAGAIN) { - DISCOVERY_DEBUGLOG(ctx, "discovery ctrlr connected\n"); - ctx->rc = rc; - spdk_thread_send_msg(ctx->calling_thread, start_discovery_done, ctx); - if (rc == 0) { - get_discovery_log_page(ctx); - } - } - } else if (ctx->detach) { + if (ctx->detach) { bool detach_done = false; if (ctx->detach_ctx == NULL) { @@ -4487,6 +4477,16 @@ discovery_poller(void *arg) ctx->stop_cb_fn(ctx->cb_ctx); free_discovery_ctx(ctx); } + } else if (ctx->probe_ctx) { + rc = spdk_nvme_probe_poll_async(ctx->probe_ctx); + if (rc != -EAGAIN) { + DISCOVERY_DEBUGLOG(ctx, "discovery ctrlr connected\n"); + ctx->rc = rc; + spdk_thread_send_msg(ctx->calling_thread, start_discovery_done, ctx); + if (rc == 0) { + get_discovery_log_page(ctx); + } + } } else { spdk_nvme_ctrlr_process_admin_completions(ctx->ctrlr); }