From 31607f3f9efeb15f2c169ba6063297f6026ac89f Mon Sep 17 00:00:00 2001 From: Ziye Yang Date: Tue, 4 Jun 2019 22:27:36 +0800 Subject: [PATCH] nvme/tcp: fix the user iov length caculation in nvme_tcp_build_sgl_request The length should be no larger than the remaining_size. For example, The remaining_size(firstly, assigned by payload_size) is 128KB, and user's sgl length is 1MB. Since we already split the I/O, so we should not use the original length(1MB), but use the remaining_size. Fix issue reported by: https://github.com/spdk/spdk/issues/808 Signed-off-by: Ziye Yang Change-Id: I0a7d0f2282c8ad0e253d8de7091b6c5b87018e9a Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456760 Tested-by: SPDK CI Jenkins Reviewed-by: Changpeng Liu Reviewed-by: Shuhei Matsumoto Reviewed-by: Jim Harris --- lib/nvme/nvme_tcp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/nvme/nvme_tcp.c b/lib/nvme/nvme_tcp.c index b4a184fba..aaae9d378 100644 --- a/lib/nvme/nvme_tcp.c +++ b/lib/nvme/nvme_tcp.c @@ -528,6 +528,7 @@ nvme_tcp_build_sgl_request(struct nvme_tcp_qpair *tqpair, struct nvme_tcp_req *t return -1; } + length = spdk_min(length, remaining_size); tcp_req->iov[iovcnt].iov_len = length; remaining_size -= length; iovcnt++;