From d752a1755da50a3f42204efc880a00e0e6cfc128 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Mon, 15 Feb 2021 03:16:38 +0900 Subject: [PATCH] lib/iscsi: Remove pdu->data_buf and use pdu->data instead for all cases data_buf was duplicated with data and was not necessary. Hence remove it and use data instead in this patch. Signed-off-by: Shuhei Matsumoto Change-Id: I207047ce73d938f83e39f1454d44a9e4bba6b2f7 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6407 Reviewed-by: Ziye Yang Reviewed-by: Changpeng Liu Reviewed-by: Jim Harris Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot --- lib/iscsi/iscsi.c | 9 ++++----- lib/iscsi/iscsi.h | 1 - test/app/fuzz/iscsi_fuzz/iscsi_fuzz.c | 7 +++---- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c index 5481ef62f..2f5967801 100644 --- a/lib/iscsi/iscsi.c +++ b/lib/iscsi/iscsi.c @@ -324,7 +324,7 @@ iscsi_pdu_calc_data_digest(struct spdk_iscsi_pdu *pdu) if (spdk_likely(!pdu->dif_insert_or_strip)) { crc32c = spdk_crc32c_update(pdu->data, data_len, crc32c); } else { - iov.iov_base = pdu->data_buf; + iov.iov_base = pdu->data; iov.iov_len = pdu->data_buf_len; num_blocks = pdu->data_buf_len / pdu->dif_ctx.block_size; @@ -356,9 +356,9 @@ iscsi_conn_read_data_segment(struct spdk_iscsi_conn *conn, if (spdk_likely(!pdu->dif_insert_or_strip)) { return iscsi_conn_read_data(conn, segment_len - pdu->data_valid_bytes, - pdu->data_buf + pdu->data_valid_bytes); + pdu->data + pdu->data_valid_bytes); } else { - buf_iov.iov_base = pdu->data_buf; + buf_iov.iov_base = pdu->data; buf_iov.iov_len = pdu->data_buf_len; rc = spdk_dif_set_md_interleave_iovs(iovs, 32, &buf_iov, 1, pdu->data_valid_bytes, @@ -4568,7 +4568,7 @@ iscsi_pdu_payload_read(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu) data_len = pdu->data_segment_len; - if (pdu->data_buf == NULL) { + if (pdu->data == NULL) { if (data_len <= iscsi_get_max_immediate_data_size()) { pool = g_iscsi.pdu_immediate_data_pool; pdu->data_buf_len = SPDK_BDEV_BUF_SIZE_WITH_MD(iscsi_get_max_immediate_data_size()); @@ -4584,7 +4584,6 @@ iscsi_pdu_payload_read(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu) if (pdu->mobj == NULL) { return 1; } - pdu->data_buf = pdu->mobj->buf; pdu->data = pdu->mobj->buf; pdu->data_from_mempool = true; } diff --git a/lib/iscsi/iscsi.h b/lib/iscsi/iscsi.h index 701b3bd21..8c0f22066 100644 --- a/lib/iscsi/iscsi.h +++ b/lib/iscsi/iscsi.h @@ -161,7 +161,6 @@ struct spdk_iscsi_pdu { struct iscsi_bhs bhs; struct spdk_mobj *mobj; bool is_rejected; - uint8_t *data_buf; uint8_t *data; uint8_t header_digest[ISCSI_DIGEST_LEN]; uint8_t data_digest[ISCSI_DIGEST_LEN]; diff --git a/test/app/fuzz/iscsi_fuzz/iscsi_fuzz.c b/test/app/fuzz/iscsi_fuzz/iscsi_fuzz.c index 45840b0aa..a7dc2fee2 100644 --- a/test/app/fuzz/iscsi_fuzz/iscsi_fuzz.c +++ b/test/app/fuzz/iscsi_fuzz/iscsi_fuzz.c @@ -479,12 +479,11 @@ iscsi_fuzz_read_pdu(struct spdk_iscsi_conn *conn) break; case ISCSI_PDU_RECV_STATE_AWAIT_PDU_PAYLOAD: data_len = pdu->data_segment_len; - if (data_len != 0 && pdu->data_buf == NULL) { - pdu->data_buf = calloc(1, data_len); - if (pdu->data_buf == NULL) { + if (data_len != 0 && pdu->data == NULL) { + pdu->data = calloc(1, data_len); + if (pdu->data == NULL) { return 0; } - pdu->data = pdu->data_buf; } /* copy the actual data into local buffer */