From b95fc6fc64cfcd73bf15c585be7e1d6492804950 Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Mon, 4 Jun 2018 13:54:23 -0700 Subject: [PATCH] nvmf: Return the correct error for out-of-range QID This one is actually a bit tough to deduce in the specification. The NVMe-oF spec says that QID errors detected in the RDMA transport shall return an RDMA-specific error indicating the problem. However, our code doesn't detect the error in RDMA-specific code, and it isn't clear if the language is a "must" or a "should". The NVMe specification does clearly indicate what error to return on invalid QID in response to a Create I/O Queue Pair command. For now, return that while we game plan whether we need to call into the RDMA transport to correctly report this error. Change-Id: I7faf37bad9b9202bc50a906214a51c17e4808fc0 Signed-off-by: Ben Walker Reviewed-on: https://review.gerrithub.io/413858 Tested-by: SPDK Automated Test System Reviewed-by: Daniel Verkamp Reviewed-by: Shuhei Matsumoto --- lib/nvmf/ctrlr.c | 6 +++--- test/unit/lib/nvmf/ctrlr.c/ctrlr_ut.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/nvmf/ctrlr.c b/lib/nvmf/ctrlr.c index 3a906c9aa..d6ab71eec 100644 --- a/lib/nvmf/ctrlr.c +++ b/lib/nvmf/ctrlr.c @@ -249,8 +249,8 @@ spdk_nvmf_ctrlr_add_io_qpair(void *ctx) if (spdk_nvmf_ctrlr_get_qpair(ctrlr, cmd->qid)) { SPDK_ERRLOG("Got I/O connect with duplicate QID %u\n", cmd->qid); - rsp->status.sct = SPDK_NVME_SCT_GENERIC; - rsp->status.sc = SPDK_NVME_SC_COMMAND_SEQUENCE_ERROR; + rsp->status.sct = SPDK_NVME_SCT_COMMAND_SPECIFIC; + rsp->status.sc = SPDK_NVME_SC_INVALID_QUEUE_IDENTIFIER; goto end; } @@ -258,7 +258,7 @@ spdk_nvmf_ctrlr_add_io_qpair(void *ctx) if (ctrlr->num_qpairs >= ctrlr->max_qpairs_allowed) { SPDK_ERRLOG("qpair limit %d\n", ctrlr->num_qpairs); rsp->status.sct = SPDK_NVME_SCT_COMMAND_SPECIFIC; - rsp->status.sc = SPDK_NVMF_FABRIC_SC_CONTROLLER_BUSY; + rsp->status.sc = SPDK_NVME_SC_INVALID_QUEUE_IDENTIFIER; goto end; } diff --git a/test/unit/lib/nvmf/ctrlr.c/ctrlr_ut.c b/test/unit/lib/nvmf/ctrlr.c/ctrlr_ut.c index 559372edb..e27a05e7d 100644 --- a/test/unit/lib/nvmf/ctrlr.c/ctrlr_ut.c +++ b/test/unit/lib/nvmf/ctrlr.c/ctrlr_ut.c @@ -525,7 +525,7 @@ test_connect(void) rc = spdk_nvmf_ctrlr_connect(&req); CU_ASSERT(rc == SPDK_NVMF_REQUEST_EXEC_STATUS_ASYNCHRONOUS); CU_ASSERT(rsp.nvme_cpl.status.sct == SPDK_NVME_SCT_COMMAND_SPECIFIC); - CU_ASSERT(rsp.nvme_cpl.status.sc == SPDK_NVMF_FABRIC_SC_CONTROLLER_BUSY); + CU_ASSERT(rsp.nvme_cpl.status.sc == SPDK_NVME_SC_INVALID_QUEUE_IDENTIFIER); CU_ASSERT(qpair.ctrlr == NULL); ctrlr.num_qpairs = 0; @@ -538,8 +538,8 @@ test_connect(void) cmd.connect_cmd.qid = 1; rc = spdk_nvmf_ctrlr_connect(&req); CU_ASSERT(rc == SPDK_NVMF_REQUEST_EXEC_STATUS_ASYNCHRONOUS); - CU_ASSERT(rsp.nvme_cpl.status.sct == SPDK_NVME_SCT_GENERIC); - CU_ASSERT(rsp.nvme_cpl.status.sc == SPDK_NVME_SC_COMMAND_SEQUENCE_ERROR); + CU_ASSERT(rsp.nvme_cpl.status.sct == SPDK_NVME_SCT_COMMAND_SPECIFIC); + CU_ASSERT(rsp.nvme_cpl.status.sc == SPDK_NVME_SC_INVALID_QUEUE_IDENTIFIER); CU_ASSERT(qpair.ctrlr == NULL); TAILQ_INIT(&ctrlr.qpairs);