lib/iscsi: Using async writev for ISCSI_OP_LOGIN_RSP PDU
Change-Id: Ia69c996c731dfd89702bbb28468d8798c391034d Signed-off-by: Ziye Yang <ziye.yang@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/481922 Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Community-CI: SPDK CI Jenkins <sys_sgci@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
67067ea4de
commit
16d5a6155a
@ -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,
|
spdk_trace_record(TRACE_ISCSI_FLUSH_WRITEBUF_START, conn->id, pdu->mapped_length, (uintptr_t)pdu,
|
||||||
pdu->sock_req.iovcnt);
|
pdu->sock_req.iovcnt);
|
||||||
if (spdk_unlikely((pdu->bhs.opcode == ISCSI_OP_LOGIN_RSP) ||
|
if (spdk_unlikely(pdu->bhs.opcode == ISCSI_OP_LOGOUT_RSP)) {
|
||||||
(pdu->bhs.opcode == ISCSI_OP_LOGOUT_RSP))) {
|
|
||||||
rc = spdk_sock_writev(conn->sock, pdu->iov, pdu->sock_req.iovcnt);
|
rc = spdk_sock_writev(conn->sock, pdu->iov, pdu->sock_req.iovcnt);
|
||||||
if (rc == pdu->mapped_length) {
|
if (rc == pdu->mapped_length) {
|
||||||
_iscsi_conn_pdu_write_done(pdu, 0);
|
_iscsi_conn_pdu_write_done(pdu, 0);
|
||||||
|
@ -1123,15 +1123,39 @@ iscsi_conn_params_update(struct spdk_iscsi_conn *conn)
|
|||||||
return rc;
|
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
|
* 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,
|
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;
|
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_CURRENT_STAGE_MASK;
|
||||||
rsph->flags &= ~ISCSI_LOGIN_NEXT_STAGE_MASK;
|
rsph->flags &= ~ISCSI_LOGIN_NEXT_STAGE_MASK;
|
||||||
}
|
}
|
||||||
|
|
||||||
spdk_iscsi_param_free(params);
|
spdk_iscsi_param_free(params);
|
||||||
spdk_iscsi_conn_write_pdu(conn, rsp_pdu, spdk_iscsi_conn_pdu_generic_complete, NULL);
|
spdk_iscsi_conn_write_pdu(conn, rsp_pdu, cb_fn, conn);
|
||||||
|
|
||||||
/* after send PDU digest on/off */
|
|
||||||
if (conn->full_feature) {
|
|
||||||
return iscsi_conn_params_update(conn);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -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);
|
rc = iscsi_op_login_rsp_init(conn, pdu, rsp_pdu);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
iscsi_op_login_response(conn, rsp_pdu, NULL);
|
iscsi_op_login_response(conn, rsp_pdu, NULL, iscsi_conn_login_pdu_err_complete);
|
||||||
return rc;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
conn->login_rsp_pdu = rsp_pdu;
|
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, ¶ms);
|
rc = iscsi_op_login_store_incoming_params(conn, pdu, rsp_pdu, ¶ms);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
iscsi_op_login_response(conn, rsp_pdu, NULL);
|
iscsi_op_login_response(conn, rsp_pdu, NULL, iscsi_conn_login_pdu_err_complete);
|
||||||
return rc;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conn->state == ISCSI_CONN_STATE_INVALID) {
|
if (conn->state == ISCSI_CONN_STATE_INVALID) {
|
||||||
rc = iscsi_op_login_phase_none(conn, rsp_pdu, params, cid);
|
rc = iscsi_op_login_phase_none(conn, rsp_pdu, params, cid);
|
||||||
if (rc == SPDK_ISCSI_LOGIN_ERROR_RESPONSE || rc == SPDK_ISCSI_LOGIN_ERROR_PARAMETER) {
|
if (rc == SPDK_ISCSI_LOGIN_ERROR_RESPONSE || rc == SPDK_ISCSI_LOGIN_ERROR_PARAMETER) {
|
||||||
iscsi_op_login_response(conn, rsp_pdu, params);
|
iscsi_op_login_response(conn, rsp_pdu, params, iscsi_conn_login_pdu_err_complete);
|
||||||
return rc;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = iscsi_op_login_rsp_handle(conn, rsp_pdu, ¶ms);
|
rc = iscsi_op_login_rsp_handle(conn, rsp_pdu, ¶ms);
|
||||||
if (rc == SPDK_ISCSI_LOGIN_ERROR_RESPONSE) {
|
if (rc == SPDK_ISCSI_LOGIN_ERROR_RESPONSE) {
|
||||||
iscsi_op_login_response(conn, rsp_pdu, params);
|
iscsi_op_login_response(conn, rsp_pdu, params, iscsi_conn_login_pdu_err_complete);
|
||||||
return rc;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = iscsi_op_login_response(conn, rsp_pdu, params);
|
iscsi_op_login_response(conn, rsp_pdu, params, iscsi_conn_login_pdu_success_complete);
|
||||||
if (rc == 0) {
|
return 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");
|
|
||||||
}
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -1350,7 +1350,7 @@ pdu_hdr_op_login_test(void)
|
|||||||
login_reqh->flags |= ISCSI_LOGIN_CONTINUE;
|
login_reqh->flags |= ISCSI_LOGIN_CONTINUE;
|
||||||
|
|
||||||
rc = iscsi_pdu_hdr_op_login(&conn, &pdu);
|
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);
|
check_login_response(ISCSI_CLASS_INITIATOR_ERROR, ISCSI_LOGIN_INITIATOR_ERROR);
|
||||||
|
|
||||||
/* Case 5 - Both version-min and version-max must be set to 0x00. */
|
/* 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;
|
login_reqh->version_min = ISCSI_VERSION + 1;
|
||||||
|
|
||||||
rc = iscsi_pdu_hdr_op_login(&conn, &pdu);
|
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);
|
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. */
|
/* 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;
|
login_reqh->flags |= ISCSI_NSG_RESERVED_CODE;
|
||||||
|
|
||||||
rc = iscsi_pdu_hdr_op_login(&conn, &pdu);
|
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);
|
check_login_response(ISCSI_CLASS_INITIATOR_ERROR, ISCSI_LOGIN_INITIATOR_ERROR);
|
||||||
|
|
||||||
/* Case 7 - Login request is correct. Login response is initialized and set to
|
/* Case 7 - Login request is correct. Login response is initialized and set to
|
||||||
|
Loading…
Reference in New Issue
Block a user