bdev/nvme: Use new APIs in a reset ctrlr sequence
Replace the spdk_nvme_ctrlr_reset_async() and spdk_nvme_reset_poll_async() calls by the spdk_nvme_ctrlr_disconnect(), spdk_nvme_ctrlr_reconnect_async(), and spdk_nvme_ctrlr_reconnect_poll_async() calls in a reset ctrlr sequence. spdk_nvme_ctrlr_disconnect() can fail if ctrlr is already resetting or removed. But both cases are not possible. reset is controlled and the callback to the hot remove is called when the ctrlr is hot removed. So we assume spdk_nvme_ctrlr_disconnect() always succeed. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: I1299e198597b2a2110f80b9a868e2dae015682ee Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10092 Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
7a0a2800e0
commit
8afa746b4d
@ -1289,7 +1289,7 @@ 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);
|
||||
rc = spdk_nvme_ctrlr_reconnect_poll_async(nvme_ctrlr->ctrlr);
|
||||
if (rc == -EAGAIN) {
|
||||
return SPDK_POLLER_BUSY;
|
||||
}
|
||||
@ -1311,20 +1311,22 @@ static void
|
||||
bdev_nvme_reset_ctrlr(struct spdk_io_channel_iter *i, int status)
|
||||
{
|
||||
struct nvme_ctrlr *nvme_ctrlr = spdk_io_channel_iter_get_io_device(i);
|
||||
int rc;
|
||||
int rc __attribute__((unused));
|
||||
|
||||
assert(status == 0);
|
||||
|
||||
rc = spdk_nvme_ctrlr_reset_async(nvme_ctrlr->ctrlr, &nvme_ctrlr->reset_ctx);
|
||||
if (rc != 0) {
|
||||
SPDK_ERRLOG("Create controller reset context failed\n");
|
||||
bdev_nvme_reset_complete(nvme_ctrlr, false);
|
||||
return;
|
||||
}
|
||||
/* Disconnect fails if ctrlr is already resetting or removed. Both cases are
|
||||
* not possible. Reset is controlled and the callback to hot remove is called
|
||||
* when ctrlr is hot removed.
|
||||
*/
|
||||
rc = spdk_nvme_ctrlr_disconnect(nvme_ctrlr->ctrlr);
|
||||
assert(rc == 0);
|
||||
|
||||
spdk_nvme_ctrlr_reconnect_async(nvme_ctrlr->ctrlr);
|
||||
|
||||
assert(nvme_ctrlr->reset_detach_poller == NULL);
|
||||
nvme_ctrlr->reset_detach_poller = SPDK_POLLER_REGISTER(bdev_nvme_ctrlr_reset_poll,
|
||||
nvme_ctrlr, 0);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -122,7 +122,6 @@ struct nvme_ctrlr {
|
||||
|
||||
bdev_nvme_reset_cb reset_cb_fn;
|
||||
void *reset_cb_arg;
|
||||
struct spdk_nvme_ctrlr_reset_ctx *reset_ctx;
|
||||
/* Poller used to check for reset/detach completion */
|
||||
struct spdk_poller *reset_detach_poller;
|
||||
struct spdk_nvme_detach_ctx *detach_ctx;
|
||||
|
@ -264,10 +264,6 @@ struct spdk_nvme_probe_ctx {
|
||||
struct spdk_nvme_ctrlr *init_ctrlr;
|
||||
};
|
||||
|
||||
struct spdk_nvme_ctrlr_reset_ctx {
|
||||
struct spdk_nvme_ctrlr *ctrlr;
|
||||
};
|
||||
|
||||
uint32_t
|
||||
spdk_nvme_ctrlr_get_first_active_ns(struct spdk_nvme_ctrlr *ctrlr)
|
||||
{
|
||||
@ -729,12 +725,8 @@ spdk_nvme_ctrlr_free_io_qpair(struct spdk_nvme_qpair *qpair)
|
||||
}
|
||||
|
||||
int
|
||||
spdk_nvme_ctrlr_reset_poll_async(struct spdk_nvme_ctrlr_reset_ctx *ctrlr_reset_ctx)
|
||||
spdk_nvme_ctrlr_reconnect_poll_async(struct spdk_nvme_ctrlr *ctrlr)
|
||||
{
|
||||
struct spdk_nvme_ctrlr *ctrlr = ctrlr_reset_ctx->ctrlr;
|
||||
|
||||
free(ctrlr_reset_ctx);
|
||||
|
||||
if (ctrlr->fail_reset) {
|
||||
ctrlr->is_failed = true;
|
||||
return -EIO;
|
||||
@ -743,22 +735,16 @@ spdk_nvme_ctrlr_reset_poll_async(struct spdk_nvme_ctrlr_reset_ctx *ctrlr_reset_c
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
spdk_nvme_ctrlr_reset_async(struct spdk_nvme_ctrlr *ctrlr,
|
||||
struct spdk_nvme_ctrlr_reset_ctx **reset_ctx)
|
||||
void
|
||||
spdk_nvme_ctrlr_reconnect_async(struct spdk_nvme_ctrlr *ctrlr)
|
||||
{
|
||||
struct spdk_nvme_ctrlr_reset_ctx *ctrlr_reset_ctx;
|
||||
|
||||
ctrlr_reset_ctx = calloc(1, sizeof(*ctrlr_reset_ctx));
|
||||
if (!ctrlr_reset_ctx) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
spdk_nvme_ctrlr_disconnect(struct spdk_nvme_ctrlr *ctrlr)
|
||||
{
|
||||
ctrlr->is_failed = false;
|
||||
|
||||
ctrlr_reset_ctx->ctrlr = ctrlr;
|
||||
*reset_ctx = ctrlr_reset_ctx;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user