Commit 43f695d9 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Jim Harris
Browse files

lib/iscsi: Move PDU header handling before data buffer allocation



To use zero copy bdev I/O APIs for write I/O, we have to allocate
iSCSI task before allocating data buffer because allocating data
buffer will be changed to spdk_bdev_zcopy_start() call and the
allocated iSCSI task will be passed to the call.

One critical change is that we have to read all data for the
current PDU even if handling the PDU is rejected. For that purpose,
use is_rejected flag and do not call iscsi_pdu_payload_handle()
is is_rejected is true. If iscsi_pdu_hdr_handle() returns negative,
close the connection, so return the state machine immediately.

Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ice77b7266af8ac392d9094478523e6e6fe6d131a
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470413


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
parent c92ff6bf
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -4870,6 +4870,13 @@ iscsi_read_pdu(struct spdk_iscsi_conn *conn)
				}
			}

			rc = iscsi_pdu_hdr_handle(conn, pdu);
			if (rc < 0) {
				SPDK_ERRLOG("Critical error is detected. Close the connection\n");
				conn->pdu_recv_state = ISCSI_PDU_RECV_STATE_ERROR;
				break;
			}

			conn->pdu_recv_state = ISCSI_PDU_RECV_STATE_AWAIT_PDU_PAYLOAD;
			break;
		case ISCSI_PDU_RECV_STATE_AWAIT_PDU_PAYLOAD:
@@ -4953,9 +4960,10 @@ iscsi_read_pdu(struct spdk_iscsi_conn *conn)
				break;
			}

			rc = iscsi_pdu_hdr_handle(conn, pdu);
			if (rc == 0 && !pdu->is_rejected) {
			if (!pdu->is_rejected) {
				rc = iscsi_pdu_payload_handle(conn, pdu);
			} else {
				rc = 0;
			}
			if (rc == 0) {
				spdk_trace_record(TRACE_ISCSI_TASK_EXECUTED, 0, 0, (uintptr_t)pdu, 0);