Commit af85c0ff authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Changpeng Liu
Browse files

iscsi: Add a function to read PDU data from socket by spdk_sock_readv



This patch adds spdk_iscsi_conn_readv_data() to read PDU data
from network socket by using spdk_sock_readv().

Additionally, this patch changes the existing spdk_iscsi_conn_read_data()
to call spdk_iscsi_conn_readv_data() by creating a single struct
iovec.

Change-Id: Ied487bb71bd4261ad53c9f3744ae272e65f98d7a
Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446377


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 1ee8deae
Loading
Loading
Loading
Loading
+18 −6
Original line number Diff line number Diff line
@@ -875,16 +875,16 @@ spdk_iscsi_drop_conns(struct spdk_iscsi_conn *conn, const char *conn_match,
 * Otherwise returns the number of bytes successfully read.
 */
int
spdk_iscsi_conn_read_data(struct spdk_iscsi_conn *conn, int bytes,
			  void *buf)
spdk_iscsi_conn_readv_data(struct spdk_iscsi_conn *conn,
			   struct iovec *iov, int iovcnt)
{
	int ret;

	if (bytes == 0) {
	if (iov == NULL || iovcnt == 0) {
		return 0;
	}

	ret = spdk_sock_recv(conn->sock, buf, bytes);
	ret = spdk_sock_readv(conn->sock, iov, iovcnt);

	if (ret > 0) {
		spdk_trace_record(TRACE_ISCSI_READ_FROM_SOCKET_DONE, conn->id, ret, 0, 0);
@@ -898,10 +898,10 @@ spdk_iscsi_conn_read_data(struct spdk_iscsi_conn *conn, int bytes,

		/* For connect reset issue, do not output error log */
		if (errno == ECONNRESET) {
			SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "spdk_sock_recv() failed, errno %d: %s\n",
			SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "spdk_sock_readv() failed, errno %d: %s\n",
				      errno, spdk_strerror(errno));
		} else {
			SPDK_ERRLOG("spdk_sock_recv() failed, errno %d: %s\n",
			SPDK_ERRLOG("spdk_sock_readv() failed, errno %d: %s\n",
				    errno, spdk_strerror(errno));
		}
	}
@@ -910,6 +910,18 @@ spdk_iscsi_conn_read_data(struct spdk_iscsi_conn *conn, int bytes,
	return SPDK_ISCSI_CONNECTION_FATAL;
}

int
spdk_iscsi_conn_read_data(struct spdk_iscsi_conn *conn, int bytes,
			  void *buf)
{
	struct iovec iov;

	iov.iov_base = buf;
	iov.iov_len = bytes;

	return spdk_iscsi_conn_readv_data(conn, &iov, 1);
}

void
spdk_iscsi_task_mgmt_cpl(struct spdk_scsi_task *scsi_task)
{
+3 −2
Original line number Diff line number Diff line
@@ -183,8 +183,9 @@ int spdk_iscsi_drop_conns(struct spdk_iscsi_conn *conn,
void spdk_iscsi_conn_set_min_per_core(int count);
int spdk_iscsi_conn_get_min_per_core(void);

int spdk_iscsi_conn_read_data(struct spdk_iscsi_conn *conn, int len,
			      void *buf);
int spdk_iscsi_conn_read_data(struct spdk_iscsi_conn *conn, int len, void *buf);
int spdk_iscsi_conn_readv_data(struct spdk_iscsi_conn *conn,
			       struct iovec *iov, int iovcnt);
void spdk_iscsi_conn_write_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu);

void spdk_iscsi_conn_free_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu);
+3 −0
Original line number Diff line number Diff line
@@ -191,6 +191,9 @@ DEFINE_STUB_V(spdk_iscsi_task_mgmt_cpl, (struct spdk_scsi_task *scsi_task));
DEFINE_STUB(spdk_iscsi_conn_read_data, int,
	    (struct spdk_iscsi_conn *conn, int bytes, void *buf), 0);

DEFINE_STUB(spdk_iscsi_conn_readv_data, int,
	    (struct spdk_iscsi_conn *conn, struct iovec *iov, int iovcnt), 0);

void
spdk_iscsi_conn_write_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
{
+3 −0
Original line number Diff line number Diff line
@@ -78,6 +78,9 @@ spdk_sock_close(struct spdk_sock **sock)
DEFINE_STUB(spdk_sock_recv, ssize_t,
	    (struct spdk_sock *sock, void *buf, size_t len), 0);

DEFINE_STUB(spdk_sock_readv, ssize_t,
	    (struct spdk_sock *sock, struct iovec *iov, int iovcnt), 0);

DEFINE_STUB(spdk_sock_writev, ssize_t,
	    (struct spdk_sock *sock, struct iovec *iov, int iovcnt), 0);