diff --git a/include/spdk_internal/nvme_tcp.h b/include/spdk_internal/nvme_tcp.h index bbc6926ab..e78e6bf8a 100644 --- a/include/spdk_internal/nvme_tcp.h +++ b/include/spdk_internal/nvme_tcp.h @@ -248,19 +248,19 @@ _nvme_tcp_sgl_append(struct _nvme_tcp_sgl *s, uint8_t *data, uint32_t data_len) } static int -nvme_tcp_build_iovecs(struct iovec *iovec, int num_iovs, struct nvme_tcp_pdu *pdu, - bool hdgst_enable, bool ddgst_enable, uint32_t *_mapped_length) +nvme_tcp_build_iovs(struct iovec *iov, int iovcnt, struct nvme_tcp_pdu *pdu, + bool hdgst_enable, bool ddgst_enable, uint32_t *_mapped_length) { int enable_digest; uint32_t hlen, plen, i; struct _nvme_tcp_sgl *sgl; - if (num_iovs == 0) { + if (iovcnt == 0) { return 0; } sgl = &pdu->sgl; - _nvme_tcp_sgl_init(sgl, iovec, num_iovs, pdu->writev_offset); + _nvme_tcp_sgl_init(sgl, iov, iovcnt, pdu->writev_offset); hlen = pdu->hdr.common.hlen; enable_digest = 1; if (pdu->hdr.common.pdu_type == SPDK_NVME_TCP_PDU_TYPE_IC_REQ || @@ -317,22 +317,22 @@ end: assert(plen == pdu->hdr.common.plen); } - return num_iovs - sgl->iovcnt; + return iovcnt - sgl->iovcnt; } static int -nvme_tcp_build_payload_iovecs(struct iovec *iovec, int num_iovs, struct nvme_tcp_pdu *pdu, - bool ddgst_enable, uint32_t *_mapped_length) +nvme_tcp_build_payload_iovs(struct iovec *iov, int iovcnt, struct nvme_tcp_pdu *pdu, + bool ddgst_enable, uint32_t *_mapped_length) { struct _nvme_tcp_sgl *sgl; uint32_t i; - if (num_iovs == 0) { + if (iovcnt == 0) { return 0; } sgl = &pdu->sgl; - _nvme_tcp_sgl_init(sgl, iovec, num_iovs, pdu->readv_offset); + _nvme_tcp_sgl_init(sgl, iov, iovcnt, pdu->readv_offset); for (i = 0; i < pdu->data_iovcnt; i++) { if (!_nvme_tcp_sgl_append(sgl, pdu->data_iov[i].iov_base, pdu->data_iov[i].iov_len)) { @@ -349,7 +349,7 @@ end: if (_mapped_length != NULL) { *_mapped_length = sgl->total_size; } - return num_iovs - sgl->iovcnt; + return iovcnt - sgl->iovcnt; } static int @@ -426,15 +426,14 @@ nvme_tcp_readv_data(struct spdk_sock *sock, struct iovec *iov, int iovcnt) static int nvme_tcp_read_payload_data(struct spdk_sock *sock, struct nvme_tcp_pdu *pdu) { - struct iovec iovec_array[NVME_TCP_MAX_SGL_DESCRIPTORS + 1]; - struct iovec *iov = iovec_array; - int iovec_cnt; + struct iovec iov[NVME_TCP_MAX_SGL_DESCRIPTORS + 1]; + int iovcnt; - iovec_cnt = nvme_tcp_build_payload_iovecs(iovec_array, NVME_TCP_MAX_SGL_DESCRIPTORS + 1, pdu, - pdu->ddgst_enable, NULL); - assert(iovec_cnt >= 0); + iovcnt = nvme_tcp_build_payload_iovs(iov, NVME_TCP_MAX_SGL_DESCRIPTORS + 1, pdu, + pdu->ddgst_enable, NULL); + assert(iovcnt >= 0); - return nvme_tcp_readv_data(sock, iov, iovec_cnt); + return nvme_tcp_readv_data(sock, iov, iovcnt); } static void diff --git a/lib/nvme/nvme_tcp.c b/lib/nvme/nvme_tcp.c index b38a57c32..1d6a81401 100644 --- a/lib/nvme/nvme_tcp.c +++ b/lib/nvme/nvme_tcp.c @@ -383,9 +383,8 @@ static int nvme_tcp_qpair_process_send_queue(struct nvme_tcp_qpair *tqpair) { const int array_size = 32; - struct iovec iovec_array[array_size]; - struct iovec *iov = iovec_array; - int iovec_cnt = 0; + struct iovec iovs[array_size]; + int iovcnt = 0; int bytes = 0; uint32_t mapped_length; struct nvme_tcp_pdu *pdu; @@ -402,14 +401,14 @@ 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 - iovec_cnt) >= 3)) { - iovec_cnt += nvme_tcp_build_iovecs(&iovec_array[iovec_cnt], array_size - iovec_cnt, - pdu, tqpair->host_hdgst_enable, - tqpair->host_ddgst_enable, &mapped_length); + while (pdu != NULL && ((array_size - iovcnt) >= 3)) { + iovcnt += nvme_tcp_build_iovs(&iovs[iovcnt], array_size - iovcnt, + pdu, tqpair->host_hdgst_enable, + tqpair->host_ddgst_enable, &mapped_length); pdu = TAILQ_NEXT(pdu, tailq); } - bytes = spdk_sock_writev(tqpair->sock, iov, iovec_cnt); + bytes = spdk_sock_writev(tqpair->sock, iovs, iovcnt); SPDK_DEBUGLOG(SPDK_LOG_NVME, "bytes=%d are out\n", bytes); if (bytes == -1) { if (errno == EWOULDBLOCK || errno == EAGAIN) { diff --git a/lib/nvmf/tcp.c b/lib/nvmf/tcp.c index 101ee3eae..e5abb529d 100644 --- a/lib/nvmf/tcp.c +++ b/lib/nvmf/tcp.c @@ -755,9 +755,8 @@ static int spdk_nvmf_tcp_qpair_flush_pdus_internal(struct spdk_nvmf_tcp_qpair *tqpair) { const int array_size = 32; - struct iovec iovec_array[array_size]; - struct iovec *iov = iovec_array; - int iovec_cnt = 0; + struct iovec iovs[array_size]; + int iovcnt = 0; int bytes = 0; int total_length = 0; uint32_t mapped_length; @@ -776,20 +775,20 @@ 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 - iovec_cnt) >= 3)) { - iovec_cnt += nvme_tcp_build_iovecs(&iovec_array[iovec_cnt], - array_size - iovec_cnt, - pdu, - tqpair->host_hdgst_enable, - tqpair->host_ddgst_enable, - &mapped_length); + while (pdu != NULL && ((array_size - iovcnt) >= 3)) { + iovcnt += nvme_tcp_build_iovs(&iovs[iovcnt], + array_size - iovcnt, + pdu, + tqpair->host_hdgst_enable, + tqpair->host_ddgst_enable, + &mapped_length); total_length += mapped_length; pdu = TAILQ_NEXT(pdu, tailq); } - spdk_trace_record(TRACE_TCP_FLUSH_WRITEBUF_START, 0, total_length, 0, iovec_cnt); + spdk_trace_record(TRACE_TCP_FLUSH_WRITEBUF_START, 0, total_length, 0, iovcnt); - bytes = spdk_sock_writev(tqpair->sock, iov, iovec_cnt); + bytes = spdk_sock_writev(tqpair->sock, iovs, iovcnt); if (bytes == -1) { if (errno == EWOULDBLOCK || errno == EAGAIN) { return 1;