From 51b643648c6633c13c60e841a76dc923fd235124 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Fri, 5 Jul 2019 14:26:14 +0900 Subject: [PATCH] nvmf/tcp: Increase buffer to insert/strip DIF in spdk_nvmf_tcp_req_parse_sgl If tcp_req->dif_insert_or_strip, increase the length from LBA based to extended LBA based by using its own DIF context. Change-Id: Ie9f5cf757328dda795b43a7b6c70a72259865115 Signed-off-by: Shuhei Matsumoto Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/458925 Tested-by: SPDK CI Jenkins Reviewed-by: Darek Stojaczyk Reviewed-by: Ziye Yang Reviewed-by: Changpeng Liu --- lib/nvmf/tcp.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/nvmf/tcp.c b/lib/nvmf/tcp.c index b7c2e5bfa..9289244f3 100644 --- a/lib/nvmf/tcp.c +++ b/lib/nvmf/tcp.c @@ -188,6 +188,9 @@ struct spdk_nvmf_tcp_req { uint32_t c2h_data_offset; uint32_t c2h_data_pdu_num; + struct spdk_dif_ctx dif_ctx; + bool dif_insert_or_strip; + TAILQ_ENTRY(spdk_nvmf_tcp_req) link; TAILQ_ENTRY(spdk_nvmf_tcp_req) state_link; }; @@ -361,6 +364,7 @@ spdk_nvmf_tcp_req_get(struct spdk_nvmf_tcp_qpair *tqpair) tcp_req->r2tl_remain = 0; tcp_req->c2h_data_offset = 0; tcp_req->has_incapsule_data = false; + tcp_req->dif_insert_or_strip = false; spdk_nvmf_tcp_req_set_state(tcp_req, TCP_REQUEST_STATE_NEW); return tcp_req; @@ -2144,6 +2148,10 @@ spdk_nvmf_tcp_req_parse_sgl(struct spdk_nvmf_tcp_transport *ttransport, SPDK_DEBUGLOG(SPDK_LOG_NVMF_TCP, "Data requested length= 0x%x\n", length); + if (spdk_unlikely(tcp_req->dif_insert_or_strip)) { + length = spdk_dif_get_length_with_md(length, &tcp_req->dif_ctx); + } + if (spdk_nvmf_tcp_req_fill_iovs(ttransport, tcp_req, length) < 0) { /* No available buffers. Queue this request up. */ SPDK_DEBUGLOG(SPDK_LOG_NVMF_TCP, "No available large data buffers. Queueing request %p\n", @@ -2187,6 +2195,10 @@ spdk_nvmf_tcp_req_parse_sgl(struct spdk_nvmf_tcp_transport *ttransport, tcp_req->data_from_pool = false; tcp_req->req.length = length; + if (spdk_unlikely(tcp_req->dif_insert_or_strip)) { + length = spdk_dif_get_length_with_md(length, &tcp_req->dif_ctx); + } + tcp_req->req.iov[0].iov_base = tcp_req->req.data; tcp_req->req.iov[0].iov_len = length; tcp_req->req.iovcnt = 1;