lib/iscsi: Separate PDU header and payload handling for Login Request

Separate PDU header and payload handling for Login Request PDU.
This will clarify the header handling and payload handling.

Especially store the allocated and initialized response PDU to
the current connection and refer it later. This idea is as same as
iSCSI task and will work because login processing is synchronous
and only once per connection.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I7e0eb413ee5f759724a685b83a742515a3546780
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/471472
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Shuhei Matsumoto 2019-10-16 17:38:18 +09:00 committed by Jim Harris
parent 19687a5525
commit cbdd8335fa
2 changed files with 25 additions and 4 deletions

View File

@ -103,6 +103,7 @@ struct spdk_iscsi_conn {
enum iscsi_connection_state state;
int login_phase;
bool is_logged_out;
struct spdk_iscsi_pdu *login_rsp_pdu;
uint64_t last_flush;
uint64_t last_fill;

View File

@ -2157,13 +2157,11 @@ iscsi_op_login_rsp_handle(struct spdk_iscsi_conn *conn,
}
static int
iscsi_op_login(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
iscsi_pdu_hdr_op_login(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
{
int rc;
struct iscsi_bhs_login_req *reqh;
struct spdk_iscsi_pdu *rsp_pdu;
struct iscsi_param *params = NULL;
int cid;
if (conn->full_feature && conn->sess != NULL &&
conn->sess->session_type == SESSION_TYPE_DISCOVERY) {
@ -2172,7 +2170,6 @@ iscsi_op_login(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
reqh = (struct iscsi_bhs_login_req *)&pdu->bhs;
pdu->cmd_sn = from_be32(&reqh->cmd_sn);
cid = from_be16(&reqh->cid);
/* During login processing, use the 8KB default FirstBurstLength as
* our maximum data segment length value.
@ -2191,6 +2188,29 @@ iscsi_op_login(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
return rc;
}
conn->login_rsp_pdu = rsp_pdu;
return 0;
}
static int
iscsi_op_login(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
{
int rc;
struct iscsi_bhs_login_req *reqh;
struct spdk_iscsi_pdu *rsp_pdu;
struct iscsi_param *params = NULL;
int cid;
rc = iscsi_pdu_hdr_op_login(conn, pdu);
if (rc != 0 || pdu->is_rejected || conn->login_rsp_pdu == NULL) {
return rc;
}
rsp_pdu = conn->login_rsp_pdu;
reqh = (struct iscsi_bhs_login_req *)&pdu->bhs;
cid = from_be16(&reqh->cid);
rc = iscsi_op_login_store_incoming_params(conn, pdu, rsp_pdu, &params);
if (rc < 0) {
iscsi_op_login_response(conn, rsp_pdu, NULL);