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:
Ziye Yang 2020-01-18 00:57:40 +08:00 committed by Jim Harris
parent 67067ea4de
commit 16d5a6155a
3 changed files with 44 additions and 38 deletions

View File

@ -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);

View File

@ -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;
iscsi_op_login_response(conn, rsp_pdu, params, iscsi_conn_login_pdu_err_complete);
return 0;
}
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");
}
return rc;
iscsi_op_login_response(conn, rsp_pdu, params, iscsi_conn_login_pdu_success_complete);
return 0;
}
static int

View File

@ -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