From 42596fb6b16a0341e5a0d302701257ab3a0ba477 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Tue, 26 Feb 2019 09:14:29 +0900 Subject: [PATCH] iscsi: Use iov instead of iovec for names of variabls and functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit iovec_cnt and iovec_array are very descriptive and good but iovcnt and iovs are often seen in SPDK and will be enough. Subsequent patches will add some changes on iovec operations and simple and familiar names will be helpful to work and review them. This patch doesn't change any behavior. Change-Id: I89ff74809a0ddbb358e3fc8fdc353a47338cc3c5 Signed-off-by: Shuhei Matsumoto Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446173 Tested-by: SPDK CI Jenkins Reviewed-by: wuzhouhui Reviewed-by: Ben Walker Reviewed-by: Jim Harris Reviewed-by: Ziye Yang Reviewed-by: Piotr Pelpliński --- lib/iscsi/conn.c | 20 +++++++-------- lib/iscsi/iscsi.c | 38 ++++++++++++++-------------- lib/iscsi/iscsi.h | 7 +++-- test/unit/lib/iscsi/conn.c/conn_ut.c | 4 +-- 4 files changed, 33 insertions(+), 36 deletions(-) diff --git a/lib/iscsi/conn.c b/lib/iscsi/conn.c index 018753827..259d18ed2 100644 --- a/lib/iscsi/conn.c +++ b/lib/iscsi/conn.c @@ -1148,10 +1148,10 @@ spdk_iscsi_conn_handle_nop(struct spdk_iscsi_conn *conn) static int spdk_iscsi_conn_flush_pdus_internal(struct spdk_iscsi_conn *conn) { - const int array_size = 32; - struct iovec iovec_array[array_size]; - struct iovec *iov = iovec_array; - int iovec_cnt = 0; + const int num_iovs = 32; + struct iovec iovs[num_iovs]; + struct iovec *iov = iovs; + int iovcnt = 0; int bytes = 0; int total_length = 0; uint32_t writev_offset; @@ -1168,13 +1168,11 @@ spdk_iscsi_conn_flush_pdus_internal(struct spdk_iscsi_conn *conn) * Build up a list of iovecs for the first few PDUs in the * connection's write_pdu_list. */ - while (pdu != NULL && ((array_size - iovec_cnt) >= 5)) { + while (pdu != NULL && ((num_iovs - iovcnt) >= 5)) { pdu_length = spdk_iscsi_get_pdu_length(pdu, conn->header_digest, conn->data_digest); - iovec_cnt += spdk_iscsi_build_iovecs(conn, - &iovec_array[iovec_cnt], - pdu); + iovcnt += spdk_iscsi_build_iovs(conn, &iovs[iovcnt], pdu); total_length += pdu_length; pdu = TAILQ_NEXT(pdu, tailq); } @@ -1190,7 +1188,7 @@ spdk_iscsi_conn_flush_pdus_internal(struct spdk_iscsi_conn *conn) if (writev_offset >= iov->iov_len) { writev_offset -= iov->iov_len; iov++; - iovec_cnt--; + iovcnt--; } else { iov->iov_len -= writev_offset; iov->iov_base = (char *)iov->iov_base + writev_offset; @@ -1198,9 +1196,9 @@ spdk_iscsi_conn_flush_pdus_internal(struct spdk_iscsi_conn *conn) } } - spdk_trace_record(TRACE_ISCSI_FLUSH_WRITEBUF_START, conn->id, total_length, 0, iovec_cnt); + spdk_trace_record(TRACE_ISCSI_FLUSH_WRITEBUF_START, conn->id, total_length, 0, iovcnt); - bytes = spdk_sock_writev(conn->sock, iov, iovec_cnt); + bytes = spdk_sock_writev(conn->sock, iov, iovcnt); if (bytes == -1) { if (errno == EWOULDBLOCK || errno == EAGAIN) { return 1; diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c index dfeba61f4..8661cc839 100644 --- a/lib/iscsi/iscsi.c +++ b/lib/iscsi/iscsi.c @@ -564,10 +564,10 @@ spdk_iscsi_read_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu **_pdu) } int -spdk_iscsi_build_iovecs(struct spdk_iscsi_conn *conn, struct iovec *iovec, - struct spdk_iscsi_pdu *pdu) +spdk_iscsi_build_iovs(struct spdk_iscsi_conn *conn, struct iovec *iovs, + struct spdk_iscsi_pdu *pdu) { - int iovec_cnt = 0; + int iovcnt = 0; int enable_digest; int total_ahs_len; int data_len; @@ -582,39 +582,39 @@ spdk_iscsi_build_iovecs(struct spdk_iscsi_conn *conn, struct iovec *iovec, } /* BHS */ - iovec[iovec_cnt].iov_base = &pdu->bhs; - iovec[iovec_cnt].iov_len = ISCSI_BHS_LEN; - iovec_cnt++; + iovs[iovcnt].iov_base = &pdu->bhs; + iovs[iovcnt].iov_len = ISCSI_BHS_LEN; + iovcnt++; /* AHS */ if (total_ahs_len > 0) { - iovec[iovec_cnt].iov_base = pdu->ahs; - iovec[iovec_cnt].iov_len = 4 * total_ahs_len; - iovec_cnt++; + iovs[iovcnt].iov_base = pdu->ahs; + iovs[iovcnt].iov_len = 4 * total_ahs_len; + iovcnt++; } /* Header Digest */ if (enable_digest && conn->header_digest) { - iovec[iovec_cnt].iov_base = pdu->header_digest; - iovec[iovec_cnt].iov_len = ISCSI_DIGEST_LEN; - iovec_cnt++; + iovs[iovcnt].iov_base = pdu->header_digest; + iovs[iovcnt].iov_len = ISCSI_DIGEST_LEN; + iovcnt++; } /* Data Segment */ if (data_len > 0) { - iovec[iovec_cnt].iov_base = pdu->data; - iovec[iovec_cnt].iov_len = ISCSI_ALIGN(data_len); - iovec_cnt++; + iovs[iovcnt].iov_base = pdu->data; + iovs[iovcnt].iov_len = ISCSI_ALIGN(data_len); + iovcnt++; } /* Data Digest */ if (enable_digest && conn->data_digest && data_len != 0) { - iovec[iovec_cnt].iov_base = pdu->data_digest; - iovec[iovec_cnt].iov_len = ISCSI_DIGEST_LEN; - iovec_cnt++; + iovs[iovcnt].iov_base = pdu->data_digest; + iovs[iovcnt].iov_len = ISCSI_DIGEST_LEN; + iovcnt++; } - return iovec_cnt; + return iovcnt; } static int diff --git a/lib/iscsi/iscsi.h b/lib/iscsi/iscsi.h index b9301df0f..459b46b57 100644 --- a/lib/iscsi/iscsi.h +++ b/lib/iscsi/iscsi.h @@ -404,10 +404,9 @@ void spdk_iscsi_send_nopin(struct spdk_iscsi_conn *conn); void spdk_iscsi_task_response(struct spdk_iscsi_conn *conn, struct spdk_iscsi_task *task); int spdk_iscsi_execute(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu); -int spdk_iscsi_build_iovecs(struct spdk_iscsi_conn *conn, - struct iovec *iovec, struct spdk_iscsi_pdu *pdu); -int -spdk_iscsi_read_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu **_pdu); +int spdk_iscsi_build_iovs(struct spdk_iscsi_conn *conn, + struct iovec *iovs, struct spdk_iscsi_pdu *pdu); +int spdk_iscsi_read_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu **_pdu); void spdk_iscsi_task_mgmt_response(struct spdk_iscsi_conn *conn, struct spdk_iscsi_task *task); diff --git a/test/unit/lib/iscsi/conn.c/conn_ut.c b/test/unit/lib/iscsi/conn.c/conn_ut.c index b99ff9ac4..1e047f239 100644 --- a/test/unit/lib/iscsi/conn.c/conn_ut.c +++ b/test/unit/lib/iscsi/conn.c/conn_ut.c @@ -137,8 +137,8 @@ DEFINE_STUB_V(spdk_clear_all_transfer_task, (struct spdk_iscsi_conn *conn, struct spdk_scsi_lun *lun, struct spdk_iscsi_pdu *pdu)); -DEFINE_STUB(spdk_iscsi_build_iovecs, int, - (struct spdk_iscsi_conn *conn, struct iovec *iovec, +DEFINE_STUB(spdk_iscsi_build_iovs, int, + (struct spdk_iscsi_conn *conn, struct iovec *iov, struct spdk_iscsi_pdu *pdu), 0);