bdev/nvme: Handle failed IO qpair creation

It is possible that the application calls
get_io_channel during nvme controller reset.
In that case IO qpair won't be created and the
application will get a NULL pointer.
It is possible to repeat get_io_channel later but
there is no such indiciation for the application,
so it can't distinguish between a real failure and
"try again" case during controller reset.

This patch ignores IO qpair creation error if
controller is resetting. IO qpair will be created
when reset completes.

Signed-off-by: Alexey Marchuk <alexeymar@mellanox.com>
Change-Id: Id39202f5a6878453ff54e35df91d5dc49a5f046a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10828
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuheimatsumoto@gmail.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Alexey Marchuk 2021-12-22 14:53:42 +03:00 committed by Tomasz Zawadzki
parent 3c4a68cafc
commit 17e9f58f1f

View File

@ -1874,6 +1874,7 @@ bdev_nvme_io_type_supported(void *ctx, enum spdk_bdev_io_type io_type)
static int
bdev_nvme_create_ctrlr_channel_cb(void *io_device, void *ctx_buf)
{
struct nvme_ctrlr *nvme_ctrlr = io_device;
struct nvme_ctrlr_channel *ctrlr_ch = ctx_buf;
struct spdk_io_channel *pg_ch;
int rc;
@ -1897,7 +1898,12 @@ bdev_nvme_create_ctrlr_channel_cb(void *io_device, void *ctx_buf)
rc = bdev_nvme_create_qpair(ctrlr_ch);
if (rc != 0) {
goto err_qpair;
/* nvme ctrlr can't create IO qpair during reset. In that case ctrlr_ch->qpair
* pointer will be NULL and IO qpair will be created when reset completes.
* If the user submits IO requests during reset, they will be queued and resubmitted later */
if (!nvme_ctrlr->resetting) {
goto err_qpair;
}
}
return 0;