From a82748513ab74b86a1a13203a41f8225d3fbc086 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Mon, 21 Oct 2019 07:28:20 +0900 Subject: [PATCH] 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: Shuhei Matsumoto Change-Id: If6f690623687ee974c5a1d73814e8675bb7077c8 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/471852 Tested-by: SPDK CI Jenkins Reviewed-by: Changpeng Liu Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- lib/iscsi/iscsi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c index 39d1e95c4..d149d2833 100644 --- a/lib/iscsi/iscsi.c +++ b/lib/iscsi/iscsi.c @@ -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;