iscsi: Use iov instead of iovec for names of variabls and functions

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 <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446173
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: wuzhouhui <wuzhouhui@kingsoft.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ziye Yang <ziye.yang@intel.com>
Reviewed-by: Piotr Pelpliński <piotr.pelplinski@intel.com>
This commit is contained in:
Shuhei Matsumoto 2019-02-26 09:14:29 +09:00 committed by Jim Harris
parent 154eb3399a
commit 42596fb6b1
4 changed files with 33 additions and 36 deletions

View File

@ -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;

View File

@ -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

View File

@ -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);

View File

@ -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);