bdev/nvme: extract stopping discovery to a function
For now, it's only called from a single location, bdev_nvme_stop_discovery, but it'll make it possible to stop the discovery from other places. Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com> Change-Id: I3ba447f30fd8ed23c392d008b3d03cdad30cdb33 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12681 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: Aleksey Marchuk <alexeymar@nvidia.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
parent
623105bb09
commit
3c61b8ca6d
@ -4858,6 +4858,33 @@ build_trid_from_log_page_entry(struct spdk_nvme_transport_id *trid,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
stop_discovery(struct discovery_ctx *ctx, spdk_bdev_nvme_stop_discovery_fn cb_fn, void *cb_ctx)
|
||||||
|
{
|
||||||
|
ctx->stop = true;
|
||||||
|
ctx->stop_cb_fn = cb_fn;
|
||||||
|
ctx->cb_ctx = cb_ctx;
|
||||||
|
|
||||||
|
while (!TAILQ_EMPTY(&ctx->nvm_entry_ctxs)) {
|
||||||
|
struct discovery_entry_ctx *entry_ctx;
|
||||||
|
struct nvme_path_id path = {};
|
||||||
|
|
||||||
|
entry_ctx = TAILQ_FIRST(&ctx->nvm_entry_ctxs);
|
||||||
|
path.trid = entry_ctx->trid;
|
||||||
|
bdev_nvme_delete(entry_ctx->name, &path);
|
||||||
|
TAILQ_REMOVE(&ctx->nvm_entry_ctxs, entry_ctx, tailq);
|
||||||
|
free(entry_ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!TAILQ_EMPTY(&ctx->discovery_entry_ctxs)) {
|
||||||
|
struct discovery_entry_ctx *entry_ctx;
|
||||||
|
|
||||||
|
entry_ctx = TAILQ_FIRST(&ctx->discovery_entry_ctxs);
|
||||||
|
TAILQ_REMOVE(&ctx->discovery_entry_ctxs, entry_ctx, tailq);
|
||||||
|
free(entry_ctx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
discovery_remove_controllers(struct discovery_ctx *ctx)
|
discovery_remove_controllers(struct discovery_ctx *ctx)
|
||||||
{
|
{
|
||||||
@ -5242,26 +5269,7 @@ bdev_nvme_stop_discovery(const char *name, spdk_bdev_nvme_stop_discovery_fn cb_f
|
|||||||
if (ctx->stop) {
|
if (ctx->stop) {
|
||||||
return -EALREADY;
|
return -EALREADY;
|
||||||
}
|
}
|
||||||
ctx->stop = true;
|
stop_discovery(ctx, cb_fn, cb_ctx);
|
||||||
ctx->stop_cb_fn = cb_fn;
|
|
||||||
ctx->cb_ctx = cb_ctx;
|
|
||||||
while (!TAILQ_EMPTY(&ctx->nvm_entry_ctxs)) {
|
|
||||||
struct discovery_entry_ctx *entry_ctx;
|
|
||||||
struct nvme_path_id path = {};
|
|
||||||
|
|
||||||
entry_ctx = TAILQ_FIRST(&ctx->nvm_entry_ctxs);
|
|
||||||
path.trid = entry_ctx->trid;
|
|
||||||
bdev_nvme_delete(entry_ctx->name, &path);
|
|
||||||
TAILQ_REMOVE(&ctx->nvm_entry_ctxs, entry_ctx, tailq);
|
|
||||||
free(entry_ctx);
|
|
||||||
}
|
|
||||||
while (!TAILQ_EMPTY(&ctx->discovery_entry_ctxs)) {
|
|
||||||
struct discovery_entry_ctx *entry_ctx;
|
|
||||||
|
|
||||||
entry_ctx = TAILQ_FIRST(&ctx->discovery_entry_ctxs);
|
|
||||||
TAILQ_REMOVE(&ctx->discovery_entry_ctxs, entry_ctx, tailq);
|
|
||||||
free(entry_ctx);
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user