From 24eb7a84b014b6747c791c4f1efe015b6bdaaa09 Mon Sep 17 00:00:00 2001 From: Ziye Yang Date: Tue, 3 Sep 2019 22:28:13 +0800 Subject: [PATCH] nvme/tcp: fix the iov vector count. Since we use pdu->data_iovcnt to build the iov in nvme_tcp_build_iovs, so send out pdu has the maximal iov number equals to: 2 + pdu->data_iovcnt, so we change the comparison. This makes sure that we can handle all the data owned by one pdu. Signed-off-by: Ziye Yang Change-Id: I2b9258cc5716d706c0fa38af609726c439708768 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/467207 Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Changpeng Liu Reviewed-by: Broadcom SPDK FC-NVMe CI --- lib/nvme/nvme_tcp.c | 2 +- lib/nvmf/tcp.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/nvme/nvme_tcp.c b/lib/nvme/nvme_tcp.c index 25840b7b6..b1e892468 100644 --- a/lib/nvme/nvme_tcp.c +++ b/lib/nvme/nvme_tcp.c @@ -402,7 +402,7 @@ nvme_tcp_qpair_process_send_queue(struct nvme_tcp_qpair *tqpair) * Build up a list of iovecs for the first few PDUs in the * tqpair 's send_queue. */ - while (pdu != NULL && ((array_size - iovcnt) >= 3)) { + while (pdu != NULL && ((array_size - iovcnt) >= (2 + (int)pdu->data_iovcnt))) { iovcnt += nvme_tcp_build_iovs(&iovs[iovcnt], array_size - iovcnt, pdu, tqpair->host_hdgst_enable, tqpair->host_ddgst_enable, &mapped_length); diff --git a/lib/nvmf/tcp.c b/lib/nvmf/tcp.c index 8afb81aa7..905598b2c 100644 --- a/lib/nvmf/tcp.c +++ b/lib/nvmf/tcp.c @@ -782,7 +782,7 @@ spdk_nvmf_tcp_qpair_flush_pdus_internal(struct spdk_nvmf_tcp_qpair *tqpair) int iovcnt = 0; int bytes = 0; int total_length = 0; - uint32_t mapped_length; + uint32_t mapped_length = 0; struct nvme_tcp_pdu *pdu; int pdu_length; TAILQ_HEAD(, nvme_tcp_pdu) completed_pdus_list; @@ -797,7 +797,7 @@ spdk_nvmf_tcp_qpair_flush_pdus_internal(struct spdk_nvmf_tcp_qpair *tqpair) * Build up a list of iovecs for the first few PDUs in the * tqpair 's send_queue. */ - while (pdu != NULL && ((array_size - iovcnt) >= 3)) { + while (pdu != NULL && ((array_size - iovcnt) >= (2 + (int)pdu->data_iovcnt))) { iovcnt += nvme_tcp_build_iovs(&iovs[iovcnt], array_size - iovcnt, pdu,