lib/iscsi: Add data_len to mobj and use mobj to create write subtask

The following patches will aggregate multiple Data-OUT PDUs into a
single SCSI write up to 64KB. Any variable to accumulate data length
is necessary.

Hence add data_len to mobj and accumulate read data length into
mobj->data_len, and then refer mobj instead of pdu->data and
pdu->data_segment_len to submit write subtask.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I6354534769e67c0fd995bbc3c2b4a80d21a23915
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6422
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-17 03:29:57 +09:00 committed by Tomasz Zawadzki
parent 7a783b5b38
commit 00508c8ef1
2 changed files with 10 additions and 3 deletions

View File

@ -4273,6 +4273,7 @@ iscsi_pdu_payload_op_data(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *p
{
struct spdk_iscsi_task *task, *subtask;
struct iscsi_bhs_data_out *reqh;
struct spdk_mobj *mobj;
uint32_t transfer_tag;
uint32_t buffer_offset;
@ -4292,19 +4293,22 @@ iscsi_pdu_payload_op_data(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *p
return iscsi_reject(conn, pdu, ISCSI_REASON_PROTOCOL_ERROR);
}
mobj = pdu->mobj;
assert(mobj != NULL);
subtask = iscsi_task_get(conn, task, iscsi_task_cpl);
if (subtask == NULL) {
SPDK_ERRLOG("Unable to acquire subtask\n");
return SPDK_ISCSI_CONNECTION_FATAL;
}
subtask->scsi.offset = buffer_offset;
subtask->scsi.length = pdu->data_segment_len;
subtask->scsi.length = mobj->data_len;
iscsi_task_associate_pdu(subtask, pdu);
if (spdk_likely(!pdu->dif_insert_or_strip)) {
spdk_scsi_task_set_data(&subtask->scsi, pdu->data, pdu->data_segment_len);
spdk_scsi_task_set_data(&subtask->scsi, mobj->buf, mobj->data_len);
} else {
spdk_scsi_task_set_data(&subtask->scsi, pdu->data, pdu->data_buf_len);
spdk_scsi_task_set_data(&subtask->scsi, mobj->buf, pdu->data_buf_len);
}
iscsi_queue_task(conn, subtask);
@ -4592,6 +4596,7 @@ iscsi_pdu_payload_read(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
return rc;
}
pdu->mobj->data_len += rc;
pdu->data_valid_bytes += rc;
if (pdu->data_valid_bytes < data_len) {
return 1;

View File

@ -147,6 +147,7 @@
struct spdk_mobj {
struct spdk_mempool *mp;
void *buf;
uint32_t data_len;
};
/*
@ -465,6 +466,7 @@ iscsi_datapool_put(struct spdk_mobj *mobj)
{
assert(mobj != NULL);
mobj->data_len = 0;
spdk_mempool_put(mobj->mp, (void *)mobj);
}