lib/iscsi: Separate allocating data buffer and reading PDU payload
When we introduce state machine, allocating data buffer and reading PDU payload will be done in the different state. Hence separate them into the different code block. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: Ic54a31d7da9dbc46f558ad0f0ad26bf8b99a3ea7 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470101 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
af8f50e9d4
commit
f93770c25d
@ -4684,32 +4684,32 @@ spdk_iscsi_read_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu **_pdu)
|
||||
|
||||
data_len = ISCSI_ALIGN(DGET24(pdu->bhs.data_segment_len));
|
||||
|
||||
if (data_len != 0 && pdu->data_buf == NULL) {
|
||||
if (data_len <= spdk_get_max_immediate_data_size()) {
|
||||
pool = g_spdk_iscsi.pdu_immediate_data_pool;
|
||||
pdu->data_buf_len = SPDK_BDEV_BUF_SIZE_WITH_MD(spdk_get_max_immediate_data_size());
|
||||
} else if (data_len <= SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH) {
|
||||
pool = g_spdk_iscsi.pdu_data_out_pool;
|
||||
pdu->data_buf_len = SPDK_BDEV_BUF_SIZE_WITH_MD(SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH);
|
||||
} else {
|
||||
SPDK_ERRLOG("Data(%d) > MaxSegment(%d)\n",
|
||||
data_len, SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH);
|
||||
rc = SPDK_ISCSI_CONNECTION_FATAL;
|
||||
goto error;
|
||||
}
|
||||
pdu->mobj = spdk_mempool_get(pool);
|
||||
if (pdu->mobj == NULL) {
|
||||
return 0;
|
||||
}
|
||||
pdu->data_buf = pdu->mobj->buf;
|
||||
|
||||
if (spdk_unlikely(spdk_iscsi_get_dif_ctx(conn, pdu, &pdu->dif_ctx))) {
|
||||
pdu->dif_insert_or_strip = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* copy the actual data into local buffer */
|
||||
if (pdu->data_valid_bytes < data_len) {
|
||||
if (pdu->data_buf == NULL) {
|
||||
if (data_len <= spdk_get_max_immediate_data_size()) {
|
||||
pool = g_spdk_iscsi.pdu_immediate_data_pool;
|
||||
pdu->data_buf_len = SPDK_BDEV_BUF_SIZE_WITH_MD(spdk_get_max_immediate_data_size());
|
||||
} else if (data_len <= SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH) {
|
||||
pool = g_spdk_iscsi.pdu_data_out_pool;
|
||||
pdu->data_buf_len = SPDK_BDEV_BUF_SIZE_WITH_MD(SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH);
|
||||
} else {
|
||||
SPDK_ERRLOG("Data(%d) > MaxSegment(%d)\n",
|
||||
data_len, SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH);
|
||||
rc = SPDK_ISCSI_CONNECTION_FATAL;
|
||||
goto error;
|
||||
}
|
||||
pdu->mobj = spdk_mempool_get(pool);
|
||||
if (pdu->mobj == NULL) {
|
||||
return 0;
|
||||
}
|
||||
pdu->data_buf = pdu->mobj->buf;
|
||||
|
||||
if (spdk_unlikely(spdk_iscsi_get_dif_ctx(conn, pdu, &pdu->dif_ctx))) {
|
||||
pdu->dif_insert_or_strip = true;
|
||||
}
|
||||
}
|
||||
|
||||
rc = iscsi_conn_read_data_segment(conn, pdu, data_len);
|
||||
if (rc < 0) {
|
||||
goto error;
|
||||
|
Loading…
Reference in New Issue
Block a user