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

lib/iscsi: Set pdu->data_segment_len immediately after reading PDU BHS



Previously, pdu->data_segment_len had been set after reading all
data segment to the allocate data buffer pdu->data_bur together with
pdu->data and pdu->data_from_mempool.

But we don't have any ordering constraint to do that and the value of
pdu->data_segment_len has been fixed when reading all PDU BHS.

Hence move setting pdu->data_segment_len up to immediately after
reading PDU Basic Header Segment to pdu->bhs in iscsi_read_pdu().

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


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 1b6d1c80
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -3374,7 +3374,7 @@ iscsi_pdu_hdr_op_scsi(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
	W_bit = reqh->write_bit;
	lun = from_be64(&reqh->lun);
	task_tag = from_be32(&reqh->itt);
	data_len = ISCSI_ALIGN(DGET24(pdu->bhs.data_segment_len));
	data_len = pdu->data_segment_len;
	transfer_len = from_be32(&reqh->expected_data_xfer_len);
	cdb = reqh->cdb;

@@ -4715,6 +4715,8 @@ iscsi_read_pdu(struct spdk_iscsi_conn *conn)
				}
			}

			pdu->data_segment_len = ISCSI_ALIGN(DGET24(pdu->bhs.data_segment_len));

			/* AHS */
			ahs_len = pdu->bhs.total_ahs_len * 4;
			assert(ahs_len <= ISCSI_AHS_LEN);
@@ -4763,7 +4765,7 @@ iscsi_read_pdu(struct spdk_iscsi_conn *conn)
			conn->pdu_recv_state = ISCSI_PDU_RECV_STATE_AWAIT_PDU_PAYLOAD;
			break;
		case ISCSI_PDU_RECV_STATE_AWAIT_PDU_PAYLOAD:
			data_len = ISCSI_ALIGN(DGET24(pdu->bhs.data_segment_len));
			data_len = pdu->data_segment_len;

			if (data_len != 0 && pdu->data_buf == NULL) {
				if (data_len <= spdk_get_max_immediate_data_size()) {
@@ -4785,7 +4787,6 @@ iscsi_read_pdu(struct spdk_iscsi_conn *conn)
				pdu->data_buf = pdu->mobj->buf;
				pdu->data = pdu->mobj->buf;
				pdu->data_from_mempool = true;
				pdu->data_segment_len = data_len;

				if (spdk_unlikely(spdk_iscsi_get_dif_ctx(conn, pdu, &pdu->dif_ctx))) {
					pdu->dif_insert_or_strip = true;