bdev/nvme: Switch to spdk_nvme_ctrlr_reset_async

In bdev_nvme_reset_ctrlr(), get a controller reset context and start
a poller that calls spdk_nvme_ctrlr_reset_poll_async() to perform the
controller reset asynchronously.

Signed-off-by: Jonathan Teh <jonathan.teh@mayadata.io>
Change-Id: I1e3ae42291c3b43b69c99ca56997dc1965c3ac59
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8454
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
Jonathan Teh 2021-06-15 18:39:21 +01:00 committed by Tomasz Zawadzki
parent ac24039da3
commit 3c6b670df4
3 changed files with 61 additions and 6 deletions

View File

@ -573,6 +573,30 @@ bdev_nvme_reset_create_qpair(struct spdk_io_channel_iter *i)
spdk_for_each_channel_continue(i, rc);
}
static int
bdev_nvme_ctrlr_reset_poll(void *arg)
{
struct nvme_ctrlr *nvme_ctrlr = arg;
int rc;
rc = spdk_nvme_ctrlr_reset_poll_async(nvme_ctrlr->reset_ctx);
if (rc == -EAGAIN) {
return SPDK_POLLER_BUSY;
}
spdk_poller_unregister(&nvme_ctrlr->reset_poller);
if (rc == 0) {
/* Recreate all of the I/O queue pairs */
spdk_for_each_channel(nvme_ctrlr,
bdev_nvme_reset_create_qpair,
NULL,
bdev_nvme_reset_create_qpairs_done);
} else {
bdev_nvme_reset_complete(nvme_ctrlr, rc);
}
return SPDK_POLLER_BUSY;
}
static void
bdev_nvme_reset_ctrlr(struct spdk_io_channel_iter *i, int status)
{
@ -584,16 +608,15 @@ bdev_nvme_reset_ctrlr(struct spdk_io_channel_iter *i, int status)
goto err;
}
rc = spdk_nvme_ctrlr_reset(nvme_ctrlr->ctrlr);
rc = spdk_nvme_ctrlr_reset_async(nvme_ctrlr->ctrlr, &nvme_ctrlr->reset_ctx);
if (rc != 0) {
SPDK_ERRLOG("Create controller reset context failed\n");
goto err;
}
assert(nvme_ctrlr->reset_poller == NULL);
nvme_ctrlr->reset_poller = SPDK_POLLER_REGISTER(bdev_nvme_ctrlr_reset_poll,
nvme_ctrlr, 0);
/* Recreate all of the I/O queue pairs */
spdk_for_each_channel(nvme_ctrlr,
bdev_nvme_reset_create_qpair,
NULL,
bdev_nvme_reset_create_qpairs_done);
return;
err:

View File

@ -133,6 +133,8 @@ struct nvme_ctrlr {
bdev_nvme_reset_cb reset_cb_fn;
void *reset_cb_arg;
struct spdk_nvme_ctrlr_reset_ctx *reset_ctx;
struct spdk_poller *reset_poller;
/** linked list pointer for device list */
TAILQ_ENTRY(nvme_ctrlr) tailq;

View File

@ -274,6 +274,10 @@ struct spdk_nvme_probe_ctx {
struct spdk_nvme_ctrlr *init_ctrlr;
};
struct spdk_nvme_ctrlr_reset_ctx {
struct spdk_nvme_ctrlr *ctrlr;
};
static TAILQ_HEAD(, spdk_nvme_ctrlr) g_ut_init_ctrlrs = TAILQ_HEAD_INITIALIZER(g_ut_init_ctrlrs);
static TAILQ_HEAD(, spdk_nvme_ctrlr) g_ut_attached_ctrlrs = TAILQ_HEAD_INITIALIZER(
g_ut_attached_ctrlrs);
@ -673,6 +677,32 @@ spdk_nvme_ctrlr_reset(struct spdk_nvme_ctrlr *ctrlr)
return 0;
}
int
spdk_nvme_ctrlr_reset_poll_async(struct spdk_nvme_ctrlr_reset_ctx *ctrlr_reset_ctx)
{
struct spdk_nvme_ctrlr *ctrlr = ctrlr_reset_ctx->ctrlr;
free(ctrlr_reset_ctx);
return spdk_nvme_ctrlr_reset(ctrlr);
}
int
spdk_nvme_ctrlr_reset_async(struct spdk_nvme_ctrlr *ctrlr,
struct spdk_nvme_ctrlr_reset_ctx **reset_ctx)
{
struct spdk_nvme_ctrlr_reset_ctx *ctrlr_reset_ctx;
ctrlr_reset_ctx = calloc(1, sizeof(*ctrlr_reset_ctx));
if (!ctrlr_reset_ctx) {
return -ENOMEM;
}
ctrlr_reset_ctx->ctrlr = ctrlr;
*reset_ctx = ctrlr_reset_ctx;
return 0;
}
void
spdk_nvme_ctrlr_fail(struct spdk_nvme_ctrlr *ctrlr)
{