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

lib/iscsi: Using async writev for ISCSI_OP_LOGIN_RSP PDU



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


Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 67067ea4
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -1502,8 +1502,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))) {
	if (spdk_unlikely(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);
+40 −33
Original line number Diff line number Diff line
@@ -1123,15 +1123,39 @@ iscsi_conn_params_update(struct spdk_iscsi_conn *conn)
	return rc;
}

static void
iscsi_conn_login_pdu_err_complete(void *arg)
{
	struct spdk_iscsi_conn *conn = arg;

	if (conn->full_feature) {
		iscsi_conn_params_update(conn);
	}
}

static void
iscsi_conn_login_pdu_success_complete(void *arg)
{
	struct spdk_iscsi_conn *conn = arg;

	if (conn->full_feature) {
		if (iscsi_conn_params_update(conn) != 0) {
			return;
		}
	}
	conn->state = ISCSI_CONN_STATE_RUNNING;
	if (conn->full_feature != 0) {
		spdk_iscsi_conn_schedule(conn);
	}
}

/*
 * The response function of spdk_iscsi_op_login
 * return:
 * 0:success;
 * -1:error;
 */
static int
static void
iscsi_op_login_response(struct spdk_iscsi_conn *conn,
			struct spdk_iscsi_pdu *rsp_pdu, struct iscsi_param *params)
			struct spdk_iscsi_pdu *rsp_pdu, struct iscsi_param *params,
			iscsi_conn_xfer_complete_cb cb_fn)
{
	struct iscsi_bhs_login_rsp *rsph;

@@ -1160,16 +1184,8 @@ iscsi_op_login_response(struct spdk_iscsi_conn *conn,
		rsph->flags &= ~ISCSI_LOGIN_CURRENT_STAGE_MASK;
		rsph->flags &= ~ISCSI_LOGIN_NEXT_STAGE_MASK;
	}

	spdk_iscsi_param_free(params);
	spdk_iscsi_conn_write_pdu(conn, rsp_pdu, spdk_iscsi_conn_pdu_generic_complete, NULL);

	/* after send PDU digest on/off */
	if (conn->full_feature) {
		return iscsi_conn_params_update(conn);
	}

	return 0;
	spdk_iscsi_conn_write_pdu(conn, rsp_pdu, cb_fn, conn);
}

/*
@@ -2173,8 +2189,8 @@ iscsi_pdu_hdr_op_login(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
	}
	rc = iscsi_op_login_rsp_init(conn, pdu, rsp_pdu);
	if (rc < 0) {
		iscsi_op_login_response(conn, rsp_pdu, NULL);
		return rc;
		iscsi_op_login_response(conn, rsp_pdu, NULL, iscsi_conn_login_pdu_err_complete);
		return 0;
	}

	conn->login_rsp_pdu = rsp_pdu;
@@ -2201,35 +2217,26 @@ iscsi_pdu_payload_op_login(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *

	rc = iscsi_op_login_store_incoming_params(conn, pdu, rsp_pdu, &params);
	if (rc < 0) {
		iscsi_op_login_response(conn, rsp_pdu, NULL);
		return rc;
		iscsi_op_login_response(conn, rsp_pdu, NULL, iscsi_conn_login_pdu_err_complete);
		return 0;
	}

	if (conn->state == ISCSI_CONN_STATE_INVALID) {
		rc = iscsi_op_login_phase_none(conn, rsp_pdu, params, cid);
		if (rc == SPDK_ISCSI_LOGIN_ERROR_RESPONSE || rc == SPDK_ISCSI_LOGIN_ERROR_PARAMETER) {
			iscsi_op_login_response(conn, rsp_pdu, params);
			return rc;
			iscsi_op_login_response(conn, rsp_pdu, params, iscsi_conn_login_pdu_err_complete);
			return 0;
		}
	}

	rc = iscsi_op_login_rsp_handle(conn, rsp_pdu, &params);
	if (rc == SPDK_ISCSI_LOGIN_ERROR_RESPONSE) {
		iscsi_op_login_response(conn, rsp_pdu, params);
		return rc;
	}

	rc = iscsi_op_login_response(conn, rsp_pdu, params);
	if (rc == 0) {
		conn->state = ISCSI_CONN_STATE_RUNNING;
		if (conn->full_feature != 0) {
			spdk_iscsi_conn_schedule(conn);
		}
	} else {
		SPDK_ERRLOG("login error - connection will be destroyed\n");
		iscsi_op_login_response(conn, rsp_pdu, params, iscsi_conn_login_pdu_err_complete);
		return 0;
	}

	return rc;
	iscsi_op_login_response(conn, rsp_pdu, params, iscsi_conn_login_pdu_success_complete);
	return 0;
}

static int
+3 −3
Original line number Diff line number Diff line
@@ -1350,7 +1350,7 @@ pdu_hdr_op_login_test(void)
	login_reqh->flags |= ISCSI_LOGIN_CONTINUE;

	rc = iscsi_pdu_hdr_op_login(&conn, &pdu);
	CU_ASSERT(rc == SPDK_ISCSI_LOGIN_ERROR_RESPONSE);
	CU_ASSERT(rc == 0);
	check_login_response(ISCSI_CLASS_INITIATOR_ERROR, ISCSI_LOGIN_INITIATOR_ERROR);

	/* Case 5 - Both version-min and version-max must be set to 0x00. */
@@ -1358,7 +1358,7 @@ pdu_hdr_op_login_test(void)
	login_reqh->version_min = ISCSI_VERSION + 1;

	rc = iscsi_pdu_hdr_op_login(&conn, &pdu);
	CU_ASSERT(rc == SPDK_ISCSI_LOGIN_ERROR_RESPONSE);
	CU_ASSERT(rc == 0);
	check_login_response(ISCSI_CLASS_INITIATOR_ERROR, ISCSI_LOGIN_UNSUPPORTED_VERSION);

	/* Case 6 - T bit is set to 1 correctly but invalid stage code is set to NSG. */
@@ -1367,7 +1367,7 @@ pdu_hdr_op_login_test(void)
	login_reqh->flags |= ISCSI_NSG_RESERVED_CODE;

	rc = iscsi_pdu_hdr_op_login(&conn, &pdu);
	CU_ASSERT(rc == SPDK_ISCSI_LOGIN_ERROR_RESPONSE);
	CU_ASSERT(rc == 0);
	check_login_response(ISCSI_CLASS_INITIATOR_ERROR, ISCSI_LOGIN_INITIATOR_ERROR);

	/* Case 7 - Login request is correct.  Login response is initialized and set to