lib/iscsi: Using async writev for ISCSI_OP_TEXT_RSP PDU

To avoid partial write issue of this PDU.

Signed-off-by: Ziye Yang <ziye.yang@intel.com>
Change-Id: Id9b22da844c75ae53c6881850d192b40ac4098ac
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/481948
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Ziye Yang 2020-01-18 04:22:49 +08:00 committed by Jim Harris
parent e199f1a5b4
commit b03612bf4d
2 changed files with 28 additions and 18 deletions

View File

@ -1503,8 +1503,7 @@ spdk_iscsi_conn_write_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *p
spdk_trace_record(TRACE_ISCSI_FLUSH_WRITEBUF_START, conn->id, pdu->mapped_length, (uintptr_t)pdu,
pdu->sock_req.iovcnt);
if (spdk_unlikely((pdu->bhs.opcode == ISCSI_OP_LOGIN_RSP) ||
(pdu->bhs.opcode == ISCSI_OP_LOGOUT_RSP) ||
(pdu->bhs.opcode == ISCSI_OP_TEXT_RSP))) {
(pdu->bhs.opcode == ISCSI_OP_LOGOUT_RSP))) {
rc = spdk_sock_writev(conn->sock, pdu->iov, pdu->sock_req.iovcnt);
if (rc == pdu->mapped_length) {
_iscsi_conn_pdu_write_done(pdu, 0);

View File

@ -2279,6 +2279,32 @@ iscsi_pdu_hdr_op_text(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
return 0;
}
static void
spdk_iscsi_conn_text_pdu_complete(void *arg)
{
struct spdk_iscsi_conn *conn = arg;
int rc;
/* update internal variables */
rc = spdk_iscsi_copy_param2var(conn);
if (rc < 0) {
SPDK_ERRLOG("spdk_iscsi_copy_param2var() failed\n");
if (conn->state < ISCSI_CONN_STATE_EXITING) {
conn->state = ISCSI_CONN_STATE_EXITING;
}
return;
}
/* check value */
rc = iscsi_check_values(conn);
if (rc < 0) {
SPDK_ERRLOG("iscsi_check_values() failed\n");
if (conn->state < ISCSI_CONN_STATE_EXITING) {
conn->state = ISCSI_CONN_STATE_EXITING;
}
}
}
static int
iscsi_pdu_payload_op_text(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
{
@ -2415,22 +2441,7 @@ iscsi_pdu_payload_op_text(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *p
to_be32(&rsph->exp_cmd_sn, conn->sess->ExpCmdSN);
to_be32(&rsph->max_cmd_sn, conn->sess->MaxCmdSN);
spdk_iscsi_conn_write_pdu(conn, rsp_pdu, spdk_iscsi_conn_pdu_generic_complete, NULL);
/* update internal variables */
rc = spdk_iscsi_copy_param2var(conn);
if (rc < 0) {
SPDK_ERRLOG("spdk_iscsi_copy_param2var() failed\n");
return -1;
}
/* check value */
rc = iscsi_check_values(conn);
if (rc < 0) {
SPDK_ERRLOG("iscsi_check_values() failed\n");
return -1;
}
spdk_iscsi_conn_write_pdu(conn, rsp_pdu, spdk_iscsi_conn_text_pdu_complete, conn);
return 0;
}