diff --git a/lib/iscsi/conn.c b/lib/iscsi/conn.c index 148cc4f8f..0f236e4c3 100644 --- a/lib/iscsi/conn.c +++ b/lib/iscsi/conn.c @@ -1100,13 +1100,13 @@ spdk_iscsi_conn_flush_pdus_internal(struct spdk_iscsi_conn *conn) if (pdu->task->scsi.offset > 0) { conn->data_in_cnt--; if (pdu->bhs.flags & ISCSI_DATAIN_STATUS) { + /* Free the primary task after the last subtask done */ + conn->data_in_cnt--; spdk_iscsi_task_put(spdk_iscsi_task_get_primary(pdu->task)); } + spdk_iscsi_conn_handle_queued_tasks(conn); } - - spdk_iscsi_conn_handle_queued_datain(conn); } - spdk_iscsi_task_put(pdu->task); } spdk_put_pdu(pdu); diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c index 6ab957ea0..193933735 100644 --- a/lib/iscsi/iscsi.c +++ b/lib/iscsi/iscsi.c @@ -2838,15 +2838,21 @@ static void spdk_iscsi_queue_mgmt_task(struct spdk_iscsi_conn *conn, spdk_scsi_dev_queue_mgmt_task(conn->dev, &task->scsi); } -int spdk_iscsi_conn_handle_queued_datain(struct spdk_iscsi_conn *conn) +int spdk_iscsi_conn_handle_queued_tasks(struct spdk_iscsi_conn *conn) { struct spdk_iscsi_task *task; while (!TAILQ_EMPTY(&conn->queued_datain_tasks) && - conn->data_in_cnt < MAX_EXTRA_DATAIN_PER_CONNECTION) { + conn->data_in_cnt < MAX_LARGE_DATAIN_PER_CONNECTION) { task = TAILQ_FIRST(&conn->queued_datain_tasks); assert(task->current_datain_offset <= task->scsi.transfer_len); + if (task->current_datain_offset == 0) { + task->current_datain_offset = task->scsi.length; + conn->data_in_cnt++; + spdk_iscsi_queue_task(conn, task); + continue; + } if (task->current_datain_offset < task->scsi.transfer_len) { struct spdk_iscsi_task *subtask; uint32_t remaining_size = 0; @@ -2879,16 +2885,18 @@ static int spdk_iscsi_op_scsi_read(struct spdk_iscsi_conn *conn, task->scsi.offset = 0; task->scsi.length = DMIN32(SPDK_BDEV_LARGE_RBUF_MAX_SIZE, task->scsi.transfer_len); task->scsi.rbuf = NULL; - spdk_iscsi_queue_task(conn, task); remaining_size = task->scsi.transfer_len - task->scsi.length; - task->current_datain_offset = task->scsi.length; + task->current_datain_offset = 0; - if (remaining_size > 0) { - TAILQ_INSERT_TAIL(&conn->queued_datain_tasks, task, link); - return spdk_iscsi_conn_handle_queued_datain(conn); + if (remaining_size == 0) { + spdk_iscsi_queue_task(conn, task); + return 0; } - return 0; + + TAILQ_INSERT_TAIL(&conn->queued_datain_tasks, task, link); + + return spdk_iscsi_conn_handle_queued_tasks(conn); } static int diff --git a/lib/iscsi/iscsi.h b/lib/iscsi/iscsi.h index 8c6a1d479..a101c34fa 100644 --- a/lib/iscsi/iscsi.h +++ b/lib/iscsi/iscsi.h @@ -107,13 +107,12 @@ /* * Defines maximum number of data in buffers each connection can have in - * use at any given time. An "extra data in buffer" means any buffer after - * the first for the iSCSI I/O command. So this limit does not affect I/O - * smaller than SPDK_ISCSI_MAX_SEND_DATA_SEGMENT_LENGTH. + * use at any given time. So this limit does not affect I/O smaller than + * SPDK_BDEV_SMALL_RBUF_MAX_SIZE. */ -#define MAX_EXTRA_DATAIN_PER_CONNECTION 64 +#define MAX_LARGE_DATAIN_PER_CONNECTION 64 -#define NUM_PDU_PER_CONNECTION (2 * (SPDK_ISCSI_MAX_QUEUE_DEPTH + MAX_EXTRA_DATAIN_PER_CONNECTION + 8)) +#define NUM_PDU_PER_CONNECTION (2 * (SPDK_ISCSI_MAX_QUEUE_DEPTH + MAX_LARGE_DATAIN_PER_CONNECTION + 8)) #define SPDK_ISCSI_MAX_BURST_LENGTH \ (SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH * MAX_DATA_OUT_PER_CONNECTION) @@ -358,7 +357,7 @@ void process_task_mgmt_completion(spdk_event_t event); /* Memory management */ void spdk_put_pdu(struct spdk_iscsi_pdu *pdu); struct spdk_iscsi_pdu *spdk_get_pdu(void); -int spdk_iscsi_conn_handle_queued_datain(struct spdk_iscsi_conn *conn); +int spdk_iscsi_conn_handle_queued_tasks(struct spdk_iscsi_conn *conn); static inline int spdk_get_immediate_data_buffer_size(void)