lib/iscsi: Refactor the code in iscsi_read_pdu.
For the logic in ISCSI_PDU_RECV_STATE_AWAIT_PDU_PAYLOAD case, this change will make it easier to read. Signed-off-by: Ziye Yang <ziye.yang@intel.com> Change-Id: Iccc582dd5c749c60b3d22b2b9b73fb8407e59b0d Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6360 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
9451030761
commit
36b9a670c8
@ -4669,8 +4669,8 @@ iscsi_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) {
|
||||
if (data_len != 0) {
|
||||
if (pdu->data_buf == 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());
|
||||
@ -4693,7 +4693,7 @@ iscsi_read_pdu(struct spdk_iscsi_conn *conn)
|
||||
}
|
||||
|
||||
/* copy the actual data into local buffer */
|
||||
if (pdu->data_valid_bytes < data_len) {
|
||||
if ((pdu->data_valid_bytes < data_len)) {
|
||||
rc = iscsi_conn_read_data_segment(conn, pdu, data_len);
|
||||
if (rc < 0) {
|
||||
conn->pdu_recv_state = ISCSI_PDU_RECV_STATE_ERROR;
|
||||
@ -4707,7 +4707,7 @@ iscsi_read_pdu(struct spdk_iscsi_conn *conn)
|
||||
}
|
||||
|
||||
/* copy out the data digest */
|
||||
if (conn->data_digest && data_len != 0 &&
|
||||
if (conn->data_digest &&
|
||||
pdu->ddigest_valid_bytes < ISCSI_DIGEST_LEN) {
|
||||
rc = iscsi_conn_read_data(conn,
|
||||
ISCSI_DIGEST_LEN - pdu->ddigest_valid_bytes,
|
||||
@ -4728,7 +4728,7 @@ iscsi_read_pdu(struct spdk_iscsi_conn *conn)
|
||||
(uintptr_t)pdu, pdu->bhs.opcode);
|
||||
|
||||
/* check data digest */
|
||||
if (conn->data_digest && data_len != 0) {
|
||||
if (conn->data_digest) {
|
||||
crc32c = iscsi_pdu_calc_data_digest(pdu);
|
||||
rc = MATCH_DIGEST_WORD(pdu->data_digest, crc32c);
|
||||
if (rc == 0) {
|
||||
@ -4737,6 +4737,7 @@ iscsi_read_pdu(struct spdk_iscsi_conn *conn)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!pdu->is_rejected) {
|
||||
rc = iscsi_pdu_payload_handle(conn, pdu);
|
||||
|
Loading…
Reference in New Issue
Block a user