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: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ice77b7266af8ac392d9094478523e6e6fe6d131a
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470413
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
This commit is contained in:
Shuhei Matsumoto 2019-10-17 08:03:07 +09:00 committed by Jim Harris
parent c92ff6bf91
commit 43f695d939

View File

@ -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; conn->pdu_recv_state = ISCSI_PDU_RECV_STATE_AWAIT_PDU_PAYLOAD;
break; break;
case ISCSI_PDU_RECV_STATE_AWAIT_PDU_PAYLOAD: case ISCSI_PDU_RECV_STATE_AWAIT_PDU_PAYLOAD:
@ -4953,9 +4960,10 @@ iscsi_read_pdu(struct spdk_iscsi_conn *conn)
break; break;
} }
rc = iscsi_pdu_hdr_handle(conn, pdu); if (!pdu->is_rejected) {
if (rc == 0 && !pdu->is_rejected) {
rc = iscsi_pdu_payload_handle(conn, pdu); rc = iscsi_pdu_payload_handle(conn, pdu);
} else {
rc = 0;
} }
if (rc == 0) { if (rc == 0) {
spdk_trace_record(TRACE_ISCSI_TASK_EXECUTED, 0, 0, (uintptr_t)pdu, 0); spdk_trace_record(TRACE_ISCSI_TASK_EXECUTED, 0, 0, (uintptr_t)pdu, 0);