diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c index 9b8fa1e46..2d6b8681a 100644 --- a/lib/iscsi/iscsi.c +++ b/lib/iscsi/iscsi.c @@ -4270,10 +4270,37 @@ iscsi_pdu_hdr_op_data(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu) return 0; } +static int +iscsi_submit_write_subtask(struct spdk_iscsi_conn *conn, struct spdk_iscsi_task *task, + struct spdk_iscsi_pdu *pdu, struct spdk_mobj *mobj) +{ + struct spdk_iscsi_task *subtask; + + 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 = task->current_data_offset; + subtask->scsi.length = mobj->data_len; + iscsi_task_associate_pdu(subtask, pdu); + + task->current_data_offset += mobj->data_len; + + if (spdk_likely(!pdu->dif_insert_or_strip)) { + spdk_scsi_task_set_data(&subtask->scsi, mobj->buf, mobj->data_len); + } else { + spdk_scsi_task_set_data(&subtask->scsi, mobj->buf, pdu->data_buf_len); + } + + iscsi_queue_task(conn, subtask); + return 0; +} + static int iscsi_pdu_payload_op_data(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu) { - struct spdk_iscsi_task *task, *subtask; + struct spdk_iscsi_task *task; struct iscsi_bhs_data_out *reqh; struct spdk_mobj *mobj; uint32_t transfer_tag; @@ -4296,25 +4323,7 @@ iscsi_pdu_payload_op_data(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *p 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 = task->current_data_offset; - subtask->scsi.length = mobj->data_len; - iscsi_task_associate_pdu(subtask, pdu); - - task->current_data_offset += mobj->data_len; - - if (spdk_likely(!pdu->dif_insert_or_strip)) { - spdk_scsi_task_set_data(&subtask->scsi, mobj->buf, mobj->data_len); - } else { - spdk_scsi_task_set_data(&subtask->scsi, mobj->buf, pdu->data_buf_len); - } - - iscsi_queue_task(conn, subtask); - return 0; + return iscsi_submit_write_subtask(conn, task, pdu, mobj); } static void