Commit 7bf5e1de authored by Ziye Yang's avatar Ziye Yang Committed by Jim Harris
Browse files

nvme/tcp: Implement nvme_tcp_qpair_fail function.



This patch is used to implement this function.
Since we need to call nvme_tcp_req_complete in this
function, so we need to adjust the location of the
nvme_tcp_rep_complete funtion.

Change-Id: I5fc3693aec8dc166ac1eb03babcd2d73d7b00e63
Signed-off-by: default avatarZiye Yang <optimistyzy@gmail.com>
Reviewed-on: https://review.gerrithub.io/c/444489


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarSeth Howell <seth.howell5141@gmail.com>
parent e7dc2369
Loading
Loading
Loading
Loading
+29 −8
Original line number Diff line number Diff line
@@ -244,6 +244,7 @@ nvme_tcp_qpair_destroy(struct spdk_nvme_qpair *qpair)
		return -1;
	}

	nvme_tcp_qpair_fail(qpair);
	nvme_qpair_deinit(qpair);

	tqpair = nvme_tcp_qpair(qpair);
@@ -748,9 +749,37 @@ nvme_tcp_qpair_reset(struct spdk_nvme_qpair *qpair)
	return 0;
}

static void
nvme_tcp_req_complete(struct nvme_request *req,
		      struct spdk_nvme_cpl *rsp)
{
	nvme_complete_request(req, rsp);
	nvme_free_request(req);
}

int
nvme_tcp_qpair_fail(struct spdk_nvme_qpair *qpair)
{
	/*
	 * 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;
	struct nvme_tcp_qpair *tqpair = nvme_tcp_qpair(qpair);

	cpl.status.sc = SPDK_NVME_SC_ABORTED_SQ_DELETION;
	cpl.status.sct = SPDK_NVME_SCT_GENERIC;

	TAILQ_FOREACH_SAFE(tcp_req, &tqpair->outstanding_reqs, link, tmp) {
		assert(tcp_req->req != NULL);
		req = tcp_req->req;

		nvme_tcp_req_complete(req, &cpl);
		nvme_tcp_req_put(tqpair, tcp_req);
	}

	return 0;
}

@@ -926,14 +955,6 @@ get_nvme_active_req_by_cid(struct nvme_tcp_qpair *tqpair, uint32_t cid)
	return &tqpair->tcp_reqs[cid];
}

static void
nvme_tcp_req_complete(struct nvme_request *req,
		      struct spdk_nvme_cpl *rsp)
{
	nvme_complete_request(req, rsp);
	nvme_free_request(req);
}

static void
nvme_tcp_free_and_handle_queued_req(struct spdk_nvme_qpair *qpair)
{