From 3185df9057d293accf44e4b90cb5397a46c79886 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Mon, 3 Jan 2022 11:22:40 +0900 Subject: [PATCH] ut/bdev_nvme: Manage adminq's state and return -ENXIO if adminq is disconnected Signed-off-by: Shuhei Matsumoto Change-Id: I81d4a8ce5c487449ab634bcd4f984d6867febf35 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10949 Tested-by: SPDK CI Jenkins Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Reviewed-by: Jim Harris Reviewed-by: Aleksey Marchuk --- test/unit/lib/bdev/nvme/bdev_nvme.c/bdev_nvme_ut.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/unit/lib/bdev/nvme/bdev_nvme.c/bdev_nvme_ut.c b/test/unit/lib/bdev/nvme/bdev_nvme.c/bdev_nvme_ut.c index 7501f22f23..91898752c4 100644 --- a/test/unit/lib/bdev/nvme/bdev_nvme.c/bdev_nvme_ut.c +++ b/test/unit/lib/bdev/nvme/bdev_nvme.c/bdev_nvme_ut.c @@ -401,6 +401,7 @@ ut_attach_ctrlr(const struct spdk_nvme_transport_id *trid, uint32_t num_ns, ctrlr->attached = true; ctrlr->adminq.ctrlr = ctrlr; TAILQ_INIT(&ctrlr->adminq.outstanding_reqs); + ctrlr->adminq.is_connected = true; if (num_ns != 0) { ctrlr->num_ns = num_ns; @@ -776,6 +777,7 @@ spdk_nvme_ctrlr_reconnect_poll_async(struct spdk_nvme_ctrlr *ctrlr) return -EIO; } + ctrlr->adminq.is_connected = true; return 0; } @@ -787,6 +789,7 @@ spdk_nvme_ctrlr_reconnect_async(struct spdk_nvme_ctrlr *ctrlr) int spdk_nvme_ctrlr_disconnect(struct spdk_nvme_ctrlr *ctrlr) { + ctrlr->adminq.is_connected = false; ctrlr->is_failed = false; return 0; @@ -1092,6 +1095,10 @@ spdk_nvme_qpair_process_completions(struct spdk_nvme_qpair *qpair, struct ut_nvme_req *req, *tmp; uint32_t num_completions = 0; + if (!qpair->is_connected) { + return -ENXIO; + } + qpair->in_completion_context = true; TAILQ_FOREACH_SAFE(req, &qpair->outstanding_reqs, tailq, tmp) {