Commit ba3adc43 authored by Ziye Yang's avatar Ziye Yang Committed by Changpeng Liu
Browse files

iscsi: return the correct error code in spdk_iscsi_read_pdu



We shoud not always return SPDK_ISCSI_CONNECTION_FATAL
in spdk_iscsi_read_pdu function.

Reason: In iscsi_conn_handle_incoming_pdus, the loop
directly return only rc==SPDK_ISCSI_CONNECTION_FATAL.
But it masks all the necessary information. So we would like
to keep some information of the return value for spdk_iscsi_read_pdu,
and we can use error log to track those information.

Then we can return SPDK_ISCSI_CONNECTION_FATAL as the error
return value for iscsi_conn_handle_incoming_pdus function.

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


Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 858718c3
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -1353,8 +1353,9 @@ iscsi_conn_handle_incoming_pdus(struct spdk_iscsi_conn *conn)
		rc = spdk_iscsi_read_pdu(conn, &pdu);
		if (rc == 0) {
			break;
		} else if (rc == SPDK_ISCSI_CONNECTION_FATAL) {
			return rc;
		} else if (rc < 0) {
			SPDK_ERRLOG("Failed to read pdu, error=%d\n", rc);
			return SPDK_ISCSI_CONNECTION_FATAL;
		}

		if (conn->state == ISCSI_CONN_STATE_LOGGED_OUT) {
@@ -1365,11 +1366,11 @@ iscsi_conn_handle_incoming_pdus(struct spdk_iscsi_conn *conn)

		rc = spdk_iscsi_execute(conn, pdu);
		spdk_put_pdu(pdu);
		if (rc != 0) {
		if (rc < 0) {
			SPDK_ERRLOG("spdk_iscsi_execute() fatal error on %s(%s)\n",
				    conn->target_port != NULL ? spdk_scsi_port_get_name(conn->target_port) : "NULL",
				    conn->initiator_port != NULL ? spdk_scsi_port_get_name(conn->initiator_port) : "NULL");
			return rc;
			return SPDK_ISCSI_CONNECTION_FATAL;
		}

		spdk_trace_record(TRACE_ISCSI_TASK_EXECUTED, 0, 0, (uintptr_t)pdu, 0);
+4 −1
Original line number Diff line number Diff line
@@ -485,6 +485,7 @@ 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);
@@ -560,6 +561,7 @@ 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;
		}
	}
@@ -567,6 +569,7 @@ 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;
		}
@@ -578,7 +581,7 @@ spdk_iscsi_read_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu **_pdu)
error:
	spdk_put_pdu(pdu);
	conn->pdu_in_progress = NULL;
	return SPDK_ISCSI_CONNECTION_FATAL;
	return rc;
}

struct _iscsi_sgl {