From df46a0b893673b6726446de7784a2b777f476cbf Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Thu, 10 Oct 2019 15:58:16 +0900 Subject: [PATCH] lib/iscsi: Move Logout check from iscsi_conn_handle_incoming_pdus() to spdk_iscsi_read_pdu() Move logout check from iscsi_conn_handle_incoming_pdus() to spdk_iscsi_read_pdu() to introduce state machine into receive incoming PDUs processing. Besides, remove a debug log because similar debug log is already collected in spdk_iscsi_conn_read_data(). Signed-off-by: Shuhei Matsumoto Change-Id: I11ee800eb1fd60796669d5390bd3cd1031066ca7 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470285 Reviewed-by: Changpeng Liu Reviewed-by: Jim Harris Reviewed-by: Ben Walker Reviewed-by: Paul Luse Tested-by: SPDK CI Jenkins --- lib/iscsi/conn.c | 9 +-------- lib/iscsi/iscsi.c | 11 +++++++---- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/iscsi/conn.c b/lib/iscsi/conn.c index fb6df92f4..c439fa697 100644 --- a/lib/iscsi/conn.c +++ b/lib/iscsi/conn.c @@ -1405,14 +1405,7 @@ iscsi_conn_handle_incoming_pdus(struct spdk_iscsi_conn *conn) if (rc == 0) { break; } else if (rc < 0) { - SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "Failed to read pdu, error=%d\n", rc); - return SPDK_ISCSI_CONNECTION_FATAL; - } - - if (conn->is_logged_out) { - SPDK_ERRLOG("pdu received after logout\n"); - spdk_put_pdu(pdu); - return SPDK_ISCSI_CONNECTION_FATAL; + return rc; } rc = spdk_iscsi_execute(conn, pdu); diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c index d19f90132..2ab7d346f 100644 --- a/lib/iscsi/iscsi.c +++ b/lib/iscsi/iscsi.c @@ -4683,7 +4683,6 @@ spdk_iscsi_read_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu **_pdu) } else { SPDK_ERRLOG("Data(%d) > MaxSegment(%d)\n", data_len, SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH); - rc = SPDK_ISCSI_CONNECTION_FATAL; goto error; } pdu->mobj = spdk_mempool_get(pool); @@ -4741,7 +4740,6 @@ spdk_iscsi_read_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu **_pdu) rc = MATCH_DIGEST_WORD(pdu->header_digest, crc32c); if (rc == 0) { SPDK_ERRLOG("header digest error (%s)\n", conn->initiator_name); - rc = SPDK_ISCSI_CONNECTION_FATAL; goto error; } } @@ -4749,19 +4747,24 @@ spdk_iscsi_read_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu **_pdu) crc32c = spdk_iscsi_pdu_calc_data_digest(pdu); rc = MATCH_DIGEST_WORD(pdu->data_digest, crc32c); if (rc == 0) { - rc = SPDK_ISCSI_CONNECTION_FATAL; SPDK_ERRLOG("data digest error (%s)\n", conn->initiator_name); goto error; } } + if (conn->is_logged_out) { + SPDK_ERRLOG("pdu received after logout\n"); + spdk_put_pdu(pdu); + return SPDK_ISCSI_CONNECTION_FATAL; + } + *_pdu = pdu; return 1; error: spdk_put_pdu(pdu); conn->pdu_in_progress = NULL; - return rc; + return SPDK_ISCSI_CONNECTION_FATAL; } bool