Commit 42596fb6 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Jim Harris
Browse files

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: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446173


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarwuzhouhui <wuzhouhui@kingsoft.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarZiye Yang <ziye.yang@intel.com>
Reviewed-by: default avatarPiotr Pelpliński <piotr.pelplinski@intel.com>
parent 154eb339
Loading
Loading
Loading
Loading
+9 −11
Original line number Diff line number Diff line
@@ -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;
+19 −19
Original line number Diff line number Diff line
@@ -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,
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
+3 −4
Original line number Diff line number Diff line
@@ -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);

+2 −2
Original line number Diff line number Diff line
@@ -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);