lib/iscsi: Increase buffer size to 64KB at most when more Data-OUT PDUs follow

The following patches will want to aggregate multiple Data-OUT PDUs
into the same data buffer, but it will be 64KB at most.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I72eabbeae0b027c2fbff2a5837d180b06b0a1b49
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6418
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Ziye Yang <ziye.yang@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Shuhei Matsumoto 2021-02-15 06:39:06 +09:00 committed by Tomasz Zawadzki
parent 2ef97692bc
commit acdeb53f4b
2 changed files with 13 additions and 2 deletions

View File

@ -4247,6 +4247,15 @@ iscsi_pdu_hdr_op_data(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
pdu->dif_insert_or_strip = true; pdu->dif_insert_or_strip = true;
} }
if (!F_bit && !pdu->dif_insert_or_strip) {
/* More Data-OUT PDUs will follow in this sequence. Increase the buffer size
* up to SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH to merge them into a single
* subtask.
*/
pdu->data_buf_len = spdk_min(task->desired_data_transfer_length,
SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH);
}
return 0; return 0;
} }
@ -4545,10 +4554,10 @@ iscsi_pdu_payload_read(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
data_len = pdu->data_segment_len; data_len = pdu->data_segment_len;
if (pdu->data == NULL) { if (pdu->data == NULL) {
if (data_len <= iscsi_get_max_immediate_data_size()) { if (pdu->data_buf_len <= iscsi_get_max_immediate_data_size()) {
pool = g_iscsi.pdu_immediate_data_pool; pool = g_iscsi.pdu_immediate_data_pool;
pdu->data_buf_len = SPDK_BDEV_BUF_SIZE_WITH_MD(iscsi_get_max_immediate_data_size()); pdu->data_buf_len = SPDK_BDEV_BUF_SIZE_WITH_MD(iscsi_get_max_immediate_data_size());
} else if (data_len <= SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH) { } else if (pdu->data_buf_len <= SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH) {
pool = g_iscsi.pdu_data_out_pool; pool = g_iscsi.pdu_data_out_pool;
pdu->data_buf_len = SPDK_BDEV_BUF_SIZE_WITH_MD(SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH); pdu->data_buf_len = SPDK_BDEV_BUF_SIZE_WITH_MD(SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH);
} else { } else {
@ -4663,6 +4672,7 @@ iscsi_read_pdu(struct spdk_iscsi_conn *conn)
} }
pdu->data_segment_len = ISCSI_ALIGN(DGET24(pdu->bhs.data_segment_len)); pdu->data_segment_len = ISCSI_ALIGN(DGET24(pdu->bhs.data_segment_len));
pdu->data_buf_len = pdu->data_segment_len;
/* AHS */ /* AHS */
ahs_len = pdu->bhs.total_ahs_len * 4; ahs_len = pdu->bhs.total_ahs_len * 4;

View File

@ -1967,6 +1967,7 @@ pdu_hdr_op_data_test(void)
rc = iscsi_pdu_hdr_op_data(&conn, &pdu); rc = iscsi_pdu_hdr_op_data(&conn, &pdu);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(!pdu.is_rejected); CU_ASSERT(!pdu.is_rejected);
CU_ASSERT(pdu.data_buf_len == SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH);
pdu.task = NULL; pdu.task = NULL;
/* Case 11 - SCSI Data-Out PDU is correct and processed. Its F bit is 1 and hence /* Case 11 - SCSI Data-Out PDU is correct and processed. Its F bit is 1 and hence