diff --git a/lib/nvme/nvme_internal.h b/lib/nvme/nvme_internal.h index e7a081f7a7..95e0deee41 100644 --- a/lib/nvme/nvme_internal.h +++ b/lib/nvme/nvme_internal.h @@ -991,10 +991,9 @@ struct spdk_nvme_ctrlr *spdk_nvme_get_ctrlr_by_trid_unsafe( int nvme_ ## name ## _ctrlr_free_cmb_io_buffer(struct spdk_nvme_ctrlr *ctrlr, void *buf, size_t size); \ int nvme_ ## name ## _ctrlr_delete_io_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_qpair *qpair); \ int nvme_ ## name ## _ctrlr_reconnect_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_qpair *qpair); \ - int nvme_ ## name ## _qpair_enable(struct spdk_nvme_qpair *qpair); \ + void nvme_ ## name ## _qpair_abort_reqs(struct spdk_nvme_qpair *qpair, uint32_t dnr); \ int nvme_ ## name ## _qpair_disable(struct spdk_nvme_qpair *qpair); \ int nvme_ ## name ## _qpair_reset(struct spdk_nvme_qpair *qpair); \ - int nvme_ ## name ## _qpair_fail(struct spdk_nvme_qpair *qpair); \ int nvme_ ## name ## _qpair_submit_request(struct spdk_nvme_qpair *qpair, struct nvme_request *req); \ int32_t nvme_ ## name ## _qpair_process_completions(struct spdk_nvme_qpair *qpair, uint32_t max_completions); \ void nvme_ ## name ## _admin_qpair_abort_aers(struct spdk_nvme_qpair *qpair); \ diff --git a/lib/nvme/nvme_pcie.c b/lib/nvme/nvme_pcie.c index daa654a130..a914617ae4 100644 --- a/lib/nvme/nvme_pcie.c +++ b/lib/nvme/nvme_pcie.c @@ -1410,35 +1410,10 @@ nvme_pcie_qpair_destroy(struct spdk_nvme_qpair *qpair) return 0; } -static void -nvme_pcie_admin_qpair_enable(struct spdk_nvme_qpair *qpair) +void +nvme_pcie_qpair_abort_reqs(struct spdk_nvme_qpair *qpair, uint32_t dnr) { - /* - * Manually abort each outstanding admin command. Do not retry - * admin commands found here, since they will be left over from - * a controller reset and its likely the context in which the - * command was issued no longer applies. - */ - nvme_pcie_qpair_abort_trackers(qpair, 1 /* do not retry */); -} - -static void -nvme_pcie_io_qpair_enable(struct spdk_nvme_qpair *qpair) -{ - /* Manually abort each outstanding I/O. */ - nvme_pcie_qpair_abort_trackers(qpair, 0); -} - -int -nvme_pcie_qpair_enable(struct spdk_nvme_qpair *qpair) -{ - if (nvme_qpair_is_io_queue(qpair)) { - nvme_pcie_io_qpair_enable(qpair); - } else { - nvme_pcie_admin_qpair_enable(qpair); - } - - return 0; + nvme_pcie_qpair_abort_trackers(qpair, dnr); } static void @@ -1463,15 +1438,6 @@ nvme_pcie_qpair_disable(struct spdk_nvme_qpair *qpair) return 0; } - -int -nvme_pcie_qpair_fail(struct spdk_nvme_qpair *qpair) -{ - nvme_pcie_qpair_abort_trackers(qpair, 1 /* do not retry */); - - return 0; -} - static int nvme_pcie_ctrlr_cmd_create_io_cq(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_qpair *io_que, spdk_nvme_cmd_cb cb_fn, diff --git a/lib/nvme/nvme_qpair.c b/lib/nvme/nvme_qpair.c index 67162b333c..7bcb7ac2ef 100644 --- a/lib/nvme/nvme_qpair.c +++ b/lib/nvme/nvme_qpair.c @@ -34,7 +34,7 @@ #include "nvme_internal.h" #include "spdk/nvme_ocssd.h" -static void nvme_qpair_fail(struct spdk_nvme_qpair *qpair); +static void nvme_qpair_abort_reqs(struct spdk_nvme_qpair *qpair, uint32_t dnr); struct nvme_string { uint16_t value; @@ -403,7 +403,7 @@ spdk_nvme_qpair_process_completions(struct spdk_nvme_qpair *qpair, uint32_t max_ struct nvme_request *req, *tmp; if (qpair->ctrlr->is_failed) { - nvme_qpair_fail(qpair); + nvme_qpair_abort_reqs(qpair, 1 /* do not retry */); return 0; } @@ -597,7 +597,7 @@ nvme_qpair_enable(struct spdk_nvme_qpair *qpair) } qpair->is_enabled = true; - nvme_transport_qpair_enable(qpair); + nvme_transport_qpair_abort_reqs(qpair, 0 /* retry */); } void @@ -622,7 +622,7 @@ nvme_qpair_disable(struct spdk_nvme_qpair *qpair) } static void -nvme_qpair_fail(struct spdk_nvme_qpair *qpair) +nvme_qpair_abort_reqs(struct spdk_nvme_qpair *qpair, uint32_t dnr) { struct nvme_request *req; @@ -631,10 +631,10 @@ nvme_qpair_fail(struct spdk_nvme_qpair *qpair) STAILQ_REMOVE_HEAD(&qpair->queued_req, stailq); SPDK_ERRLOG("failing queued i/o\n"); nvme_qpair_manual_complete_request(qpair, req, SPDK_NVME_SCT_GENERIC, - SPDK_NVME_SC_ABORTED_BY_REQUEST, true); + SPDK_NVME_SC_ABORTED_BY_REQUEST, dnr); } - nvme_transport_qpair_fail(qpair); + nvme_transport_qpair_abort_reqs(qpair, dnr); } int diff --git a/lib/nvme/nvme_rdma.c b/lib/nvme/nvme_rdma.c index 0ef69332ea..662fa9d1fe 100644 --- a/lib/nvme/nvme_rdma.c +++ b/lib/nvme/nvme_rdma.c @@ -1334,7 +1334,7 @@ nvme_rdma_qpair_destroy(struct spdk_nvme_qpair *qpair) if (!qpair) { return -1; } - nvme_rdma_qpair_fail(qpair); + nvme_rdma_qpair_abort_reqs(qpair, 1); nvme_qpair_deinit(qpair); rqpair = nvme_rdma_qpair(qpair); @@ -1598,13 +1598,6 @@ nvme_rdma_ctrlr_reconnect_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_ return nvme_rdma_qpair_connect(nvme_rdma_qpair(qpair)); } -int -nvme_rdma_qpair_enable(struct spdk_nvme_qpair *qpair) -{ - /* Currently, doing nothing here */ - return 0; -} - int nvme_rdma_qpair_disable(struct spdk_nvme_qpair *qpair) { @@ -1619,13 +1612,9 @@ nvme_rdma_qpair_reset(struct spdk_nvme_qpair *qpair) return 0; } -int -nvme_rdma_qpair_fail(struct spdk_nvme_qpair *qpair) +void +nvme_rdma_qpair_abort_reqs(struct spdk_nvme_qpair *qpair, uint32_t dnr) { - /* - * If the qpair is really failed, the connection is broken - * and we need to flush back all I/O - */ struct spdk_nvme_rdma_req *rdma_req, *tmp; struct nvme_request *req; struct spdk_nvme_cpl cpl; @@ -1633,6 +1622,7 @@ nvme_rdma_qpair_fail(struct spdk_nvme_qpair *qpair) cpl.status.sc = SPDK_NVME_SC_ABORTED_SQ_DELETION; cpl.status.sct = SPDK_NVME_SCT_GENERIC; + cpl.status.dnr = dnr; TAILQ_FOREACH_SAFE(rdma_req, &rqpair->outstanding_reqs, link, tmp) { assert(rdma_req->req != NULL); @@ -1641,8 +1631,6 @@ nvme_rdma_qpair_fail(struct spdk_nvme_qpair *qpair) nvme_rdma_req_complete(req, &cpl); nvme_rdma_req_put(rqpair, rdma_req); } - - return 0; } static void diff --git a/lib/nvme/nvme_tcp.c b/lib/nvme/nvme_tcp.c index 811f1b5946..9c48ae418d 100644 --- a/lib/nvme/nvme_tcp.c +++ b/lib/nvme/nvme_tcp.c @@ -236,7 +236,7 @@ nvme_tcp_qpair_destroy(struct spdk_nvme_qpair *qpair) return -1; } - nvme_tcp_qpair_fail(qpair); + nvme_tcp_qpair_abort_reqs(qpair, 1); nvme_qpair_deinit(qpair); tqpair = nvme_tcp_qpair(qpair); @@ -735,12 +735,6 @@ nvme_tcp_ctrlr_reconnect_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_q return -1; } -int -nvme_tcp_qpair_enable(struct spdk_nvme_qpair *qpair) -{ - return 0; -} - int nvme_tcp_qpair_disable(struct spdk_nvme_qpair *qpair) { @@ -761,13 +755,9 @@ nvme_tcp_req_complete(struct nvme_request *req, nvme_free_request(req); } -int -nvme_tcp_qpair_fail(struct spdk_nvme_qpair *qpair) +void +nvme_tcp_qpair_abort_reqs(struct spdk_nvme_qpair *qpair, uint32_t dnr) { - /* - * If the qpair is really failed, the connection is broken - * and we need to flush back all I/O - */ struct nvme_tcp_req *tcp_req, *tmp; struct nvme_request *req; struct spdk_nvme_cpl cpl; @@ -775,6 +765,7 @@ nvme_tcp_qpair_fail(struct spdk_nvme_qpair *qpair) cpl.status.sc = SPDK_NVME_SC_ABORTED_SQ_DELETION; cpl.status.sct = SPDK_NVME_SCT_GENERIC; + cpl.status.dnr = dnr; TAILQ_FOREACH_SAFE(tcp_req, &tqpair->outstanding_reqs, link, tmp) { assert(tcp_req->req != NULL); @@ -783,8 +774,6 @@ nvme_tcp_qpair_fail(struct spdk_nvme_qpair *qpair) nvme_tcp_req_complete(req, &cpl); nvme_tcp_req_put(tqpair, tcp_req); } - - return 0; } static void diff --git a/lib/nvme/nvme_transport.c b/lib/nvme/nvme_transport.c index c408f5b4df..f4417d70e5 100644 --- a/lib/nvme/nvme_transport.c +++ b/lib/nvme/nvme_transport.c @@ -185,10 +185,11 @@ nvme_transport_ctrlr_reconnect_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_ NVME_TRANSPORT_CALL(ctrlr->trid.trtype, ctrlr_reconnect_qpair, (ctrlr, qpair)); } -int -nvme_transport_qpair_enable(struct spdk_nvme_qpair *qpair) +void +nvme_transport_qpair_abort_reqs(struct spdk_nvme_qpair *qpair, uint32_t dnr) { - NVME_TRANSPORT_CALL(qpair->trtype, qpair_enable, (qpair)); + assert(dnr <= 1); + NVME_TRANSPORT_CALL(qpair->trtype, qpair_abort_reqs, (qpair, dnr)); } int @@ -203,12 +204,6 @@ nvme_transport_qpair_reset(struct spdk_nvme_qpair *qpair) NVME_TRANSPORT_CALL(qpair->trtype, qpair_reset, (qpair)); } -int -nvme_transport_qpair_fail(struct spdk_nvme_qpair *qpair) -{ - NVME_TRANSPORT_CALL(qpair->trtype, qpair_fail, (qpair)); -} - int nvme_transport_qpair_submit_request(struct spdk_nvme_qpair *qpair, struct nvme_request *req) { diff --git a/test/unit/lib/nvme/nvme_pcie.c/nvme_pcie_ut.c b/test/unit/lib/nvme/nvme_pcie.c/nvme_pcie_ut.c index be14866ad0..f8cca9d387 100644 --- a/test/unit/lib/nvme/nvme_pcie.c/nvme_pcie_ut.c +++ b/test/unit/lib/nvme/nvme_pcie.c/nvme_pcie_ut.c @@ -573,7 +573,7 @@ test_hw_sgl_req(void) nvme_free_request(req); } -static void test_nvme_qpair_fail(void) +static void test_nvme_qpair_abort_reqs(void) { struct spdk_nvme_qpair qpair = {}; struct nvme_request *req = NULL; @@ -590,14 +590,14 @@ static void test_nvme_qpair_fail(void) tr_temp->req->cmd.cid = tr_temp->cid; TAILQ_INSERT_HEAD(&qpair.outstanding_tr, tr_temp, tq_list); - nvme_qpair_fail(&qpair); + nvme_qpair_abort_reqs(&qpair, true); CU_ASSERT_TRUE(TAILQ_EMPTY(&qpair.outstanding_tr)); req = nvme_allocate_request_null(expected_failure_callback, NULL); SPDK_CU_ASSERT_FATAL(req != NULL); STAILQ_INSERT_HEAD(&qpair.queued_req, req, stailq); - nvme_qpair_fail(&qpair); + nvme_qpair_abort_reqs(&qpair, true); CU_ASSERT_TRUE(STAILQ_EMPTY(&qpair.queued_req)); cleanup_submit_request_test(&qpair); diff --git a/test/unit/lib/nvme/nvme_qpair.c/nvme_qpair_ut.c b/test/unit/lib/nvme/nvme_qpair.c/nvme_qpair_ut.c index ec44d526b7..93d5052c92 100644 --- a/test/unit/lib/nvme/nvme_qpair.c/nvme_qpair_ut.c +++ b/test/unit/lib/nvme/nvme_qpair.c/nvme_qpair_ut.c @@ -56,22 +56,15 @@ nvme_request_remove_child(struct nvme_request *parent, TAILQ_REMOVE(&parent->children, child, child_tailq); } -int -nvme_transport_qpair_enable(struct spdk_nvme_qpair *qpair) -{ - return 0; -} - int nvme_transport_qpair_disable(struct spdk_nvme_qpair *qpair) { return 0; } -int -nvme_transport_qpair_fail(struct spdk_nvme_qpair *qpair) +void +nvme_transport_qpair_abort_reqs(struct spdk_nvme_qpair *qpair, uint32_t dnr) { - return 0; } int