Commit f4704111 authored by Richael Zhuang's avatar Richael Zhuang Committed by Tomasz Zawadzki
Browse files

bdev_nvme: fix failure in creating qpair for a disabled controller



It reported the following error when running bdevperf with controller
disabled before nvme bdev channels are created.
"
bdevperf: nvme_ctrlr.c:5263: spdk_nvme_ctrlr_alloc_qid: Assertion
`ctrlr->free_io_qids' failed.
"
Because when a controller is disconnected, free_io_qids is freed and set
as NULL in nvme_ctrlr_disconnect_done. But the namespaces of this controller
is not marked as something like disabled and skip this namespace when
creating nvme bdev channel. So when creating nvme bdev channel, it will
add io path for this nvme_ns, which cause the failure finally.

So if a nvme_ctrlr is disabled, don't create the spdk_nvme_qpair. We
only keep the io_path and nvme_qpair. spdk_nvme_qpair will be created
when this nvme_ctrlr is enabled.

Change-Id: I5bcecd4f8aa1a90a5e2d9d0db7f7016e5272c5d7
Signed-off-by: default avatarRichael Zhuang <richael.zhuang@arm.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/18903


Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@gmail.com>
parent 38df3ad5
Loading
Loading
Loading
Loading
+17 −13
Original line number Diff line number Diff line
@@ -3165,10 +3165,13 @@ nvme_qpair_create(struct nvme_ctrlr *nvme_ctrlr, struct nvme_ctrlr_channel *ctrl
	nvme_qpair->group->collect_spin_stat = false;
#endif

	if (!nvme_ctrlr->disabled) {
		/* If a nvme_ctrlr is disabled, don't try to create qpair for it. Qpair will
		 * be created when it's enabled.
		 */
		rc = bdev_nvme_create_qpair(nvme_qpair);
		if (rc != 0) {
			/* nvme_ctrlr can't create IO qpair if connection is down.
		 *
			 * If reconnect_delay_sec is non-zero, creating IO qpair is retried
			 * after reconnect_delay_sec seconds. If bdev_retry_count is non-zero,
			 * submitted IO will be queued until IO qpair is successfully created.
@@ -3181,6 +3184,7 @@ nvme_qpair_create(struct nvme_ctrlr *nvme_ctrlr, struct nvme_ctrlr_channel *ctrl
				return rc;
			}
		}
	}

	TAILQ_INSERT_TAIL(&nvme_qpair->group->qpair_list, nvme_qpair, tailq);