From 17e9f58f1fe6c589f043b7182d94abb5d144f0ad Mon Sep 17 00:00:00 2001 From: Alexey Marchuk Date: Wed, 22 Dec 2021 14:53:42 +0300 Subject: [PATCH] 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 Change-Id: Id39202f5a6878453ff54e35df91d5dc49a5f046a Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10828 Community-CI: Mellanox Build Bot Community-CI: Broadcom CI Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto Tested-by: SPDK CI Jenkins --- module/bdev/nvme/bdev_nvme.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/module/bdev/nvme/bdev_nvme.c b/module/bdev/nvme/bdev_nvme.c index 01ad6d04c..435b331d6 100644 --- a/module/bdev/nvme/bdev_nvme.c +++ b/module/bdev/nvme/bdev_nvme.c @@ -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;