Commit b03612bf authored by Ziye Yang's avatar Ziye Yang Committed by Jim Harris
Browse files

lib/iscsi: Using async writev for ISCSI_OP_TEXT_RSP PDU



To avoid partial write issue of this PDU.

Signed-off-by: default avatarZiye Yang <ziye.yang@intel.com>
Change-Id: Id9b22da844c75ae53c6881850d192b40ac4098ac
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/481948


Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent e199f1a5
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -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);
+27 −16
Original line number Diff line number Diff line
@@ -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;
}