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: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446377 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
1ee8deae9c
commit
af85c0ff68
@ -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.
|
* Otherwise returns the number of bytes successfully read.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
spdk_iscsi_conn_read_data(struct spdk_iscsi_conn *conn, int bytes,
|
spdk_iscsi_conn_readv_data(struct spdk_iscsi_conn *conn,
|
||||||
void *buf)
|
struct iovec *iov, int iovcnt)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (bytes == 0) {
|
if (iov == NULL || iovcnt == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = spdk_sock_recv(conn->sock, buf, bytes);
|
ret = spdk_sock_readv(conn->sock, iov, iovcnt);
|
||||||
|
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
spdk_trace_record(TRACE_ISCSI_READ_FROM_SOCKET_DONE, conn->id, ret, 0, 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 */
|
/* For connect reset issue, do not output error log */
|
||||||
if (errno == ECONNRESET) {
|
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));
|
errno, spdk_strerror(errno));
|
||||||
} else {
|
} 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));
|
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;
|
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
|
void
|
||||||
spdk_iscsi_task_mgmt_cpl(struct spdk_scsi_task *scsi_task)
|
spdk_iscsi_task_mgmt_cpl(struct spdk_scsi_task *scsi_task)
|
||||||
{
|
{
|
||||||
|
@ -183,8 +183,9 @@ int spdk_iscsi_drop_conns(struct spdk_iscsi_conn *conn,
|
|||||||
void spdk_iscsi_conn_set_min_per_core(int count);
|
void spdk_iscsi_conn_set_min_per_core(int count);
|
||||||
int spdk_iscsi_conn_get_min_per_core(void);
|
int spdk_iscsi_conn_get_min_per_core(void);
|
||||||
|
|
||||||
int spdk_iscsi_conn_read_data(struct spdk_iscsi_conn *conn, int len,
|
int spdk_iscsi_conn_read_data(struct spdk_iscsi_conn *conn, int len, void *buf);
|
||||||
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_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);
|
void spdk_iscsi_conn_free_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu);
|
||||||
|
@ -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,
|
DEFINE_STUB(spdk_iscsi_conn_read_data, int,
|
||||||
(struct spdk_iscsi_conn *conn, int bytes, void *buf), 0);
|
(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
|
void
|
||||||
spdk_iscsi_conn_write_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
|
spdk_iscsi_conn_write_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
|
||||||
{
|
{
|
||||||
|
@ -78,6 +78,9 @@ spdk_sock_close(struct spdk_sock **sock)
|
|||||||
DEFINE_STUB(spdk_sock_recv, ssize_t,
|
DEFINE_STUB(spdk_sock_recv, ssize_t,
|
||||||
(struct spdk_sock *sock, void *buf, size_t len), 0);
|
(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,
|
DEFINE_STUB(spdk_sock_writev, ssize_t,
|
||||||
(struct spdk_sock *sock, struct iovec *iov, int iovcnt), 0);
|
(struct spdk_sock *sock, struct iovec *iov, int iovcnt), 0);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user