From 5cfc19af377200d5f523238af911a613bcd5d01b Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Wed, 19 Jun 2019 10:38:38 +0900 Subject: [PATCH] nvme/tcp: Move assert to the correct location in nvme_tcp_build_iovs When the iovec array becomes full in the middle of the data segment, plen may not be equal to pdu->hdr.common.plen because data digest is not included. This doesn't cause any error in release mode but fix this for debug mode. Signed-off-by: Shuhei Matsumoto Change-Id: Ife5900b3075c35dfe3890fa1d9f99a6935d40a9f Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/458540 Tested-by: SPDK CI Jenkins Reviewed-by: Ziye Yang Reviewed-by: Darek Stojaczyk Reviewed-by: Paul Luse Reviewed-by: Changpeng Liu --- include/spdk_internal/nvme_tcp.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/spdk_internal/nvme_tcp.h b/include/spdk_internal/nvme_tcp.h index e78e6bf8a..ad9160692 100644 --- a/include/spdk_internal/nvme_tcp.h +++ b/include/spdk_internal/nvme_tcp.h @@ -307,16 +307,16 @@ nvme_tcp_build_iovs(struct iovec *iov, int iovcnt, struct nvme_tcp_pdu *pdu, _nvme_tcp_sgl_append(sgl, pdu->data_digest, SPDK_NVME_TCP_DIGEST_LEN); } -end: - if (_mapped_length != NULL) { - *_mapped_length = sgl->total_size; - } - /* check the plen for the first time constructing iov */ if (!pdu->writev_offset) { assert(plen == pdu->hdr.common.plen); } +end: + if (_mapped_length != NULL) { + *_mapped_length = sgl->total_size; + } + return iovcnt - sgl->iovcnt; }