bdev/nvme: add detach step to discovery_poller

If a discovery controller fails at some point, we
will want to detach it.  This can happen separately
from detaching the controller because we are stopping
the discovery service.  So break out the ctrlr
detach operation into a separate phase of the
discovery_poller.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ia601b767d32bda1c8899d3a95029781c0aeee136
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11772
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
This commit is contained in:
Jim Harris 2022-02-25 02:16:50 +00:00
parent 7dfe90df60
commit 68e5f0ae00

View File

@ -4644,29 +4644,24 @@ discovery_poller(void *arg)
struct spdk_nvme_transport_id *trid;
int rc;
if (ctx->stop) {
bool detach_done = false;
if (ctx->ctrlr == NULL) {
detach_done = true;
} else if (ctx->detach_ctx == NULL) {
if (ctx->detach_ctx) {
rc = spdk_nvme_detach_poll_async(ctx->detach_ctx);
if (rc != -EAGAIN) {
ctx->detach_ctx = NULL;
ctx->ctrlr = NULL;
}
} else if (ctx->stop) {
if (ctx->ctrlr != NULL) {
rc = spdk_nvme_detach_async(ctx->ctrlr, &ctx->detach_ctx);
if (rc != 0) {
DISCOVERY_ERRLOG(ctx, "could not detach discovery ctrlr\n");
detach_done = true;
}
} else {
rc = spdk_nvme_detach_poll_async(ctx->detach_ctx);
if (rc != -EAGAIN) {
detach_done = true;
if (rc == 0) {
return SPDK_POLLER_BUSY;
}
DISCOVERY_ERRLOG(ctx, "could not detach discovery ctrlr\n");
}
if (detach_done) {
spdk_poller_unregister(&ctx->poller);
TAILQ_REMOVE(&g_discovery_ctxs, ctx, tailq);
ctx->stop_cb_fn(ctx->cb_ctx);
free_discovery_ctx(ctx);
}
spdk_poller_unregister(&ctx->poller);
TAILQ_REMOVE(&g_discovery_ctxs, ctx, tailq);
ctx->stop_cb_fn(ctx->cb_ctx);
free_discovery_ctx(ctx);
} 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);