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

iscsi: Fix the case that incoming data is split into multiple packets



We had not considered a case that incoming data to the second data
buffer was split into multiple TCP packets when merging incoming data
up to 64KB.

We do not change the unit test because we already have data check
and it is very hard to include partial read into the data check.

However, it is very usual that incoming data is split into multple
TCP packets. The feature to merge incoming data up to 64KB will be
actually enabled in the following patches. So we rely on the I/O test
to verify this fix.

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


Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 1d269b07
Loading
Loading
Loading
Loading
+18 −16
Original line number Diff line number Diff line
@@ -4644,10 +4644,11 @@ iscsi_pdu_payload_read(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
		pdu->data = mobj->buf;
		pdu->data_from_mempool = true;
	} else if (mobj->data_len == SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH) {
		/* The first data buffer ran out. Allocate the second data buffer and
		mobj = pdu->mobj[1];
		if (mobj == NULL) {
			/* The first data buffer just ran out. Allocate the second data buffer and
			 * continue reading the data segment.
			 */
		assert(pdu->mobj[1] == NULL);
			assert(pdu->data_from_mempool == true);
			assert(!pdu->dif_insert_or_strip);

@@ -4663,6 +4664,7 @@ iscsi_pdu_payload_read(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
			pdu->data_offset = pdu->data_valid_bytes;
			pdu->data_buf_len = SPDK_BDEV_BUF_SIZE_WITH_MD(SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH);
		}
	}

	/* copy the actual data into local buffer */
	read_len = spdk_min(data_len - pdu->data_valid_bytes,