nvme: add transport_qpair_abort_reqs
This will allow us to move more of the reset-related functionality to the common layer, as part of enabling resets for fabrics controllers. The transport qpair_enable and qpair_fail functions acted similarly - so those are both removed now and replaced with this new qpair_abort_reqs function. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: I9486630ad5b807239b0b5bcde50e8cfd313695d3 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/453486 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
5d431efd6d
commit
783a2a20f1
@ -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); \
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user