diff --git a/lib/iscsi/conn.c b/lib/iscsi/conn.c index e56d4cda1..308129501 100644 --- a/lib/iscsi/conn.c +++ b/lib/iscsi/conn.c @@ -828,7 +828,11 @@ process_read_task_completion(struct spdk_iscsi_conn *conn, primary->scsi.bytes_completed += task->scsi.length; spdk_iscsi_task_response(conn, task); - spdk_iscsi_task_put(task); + + if ((task != primary) || + (task->scsi.transfer_len == task->scsi.length)) { + spdk_iscsi_task_put(task); + } process_completed_read_subtask_list(conn, primary); } @@ -1030,14 +1034,18 @@ spdk_iscsi_conn_flush_pdus_internal(struct spdk_iscsi_conn *conn) tailq); } else { if (pdu->task) { - uint64_t offset = pdu->task->scsi.offset; - spdk_iscsi_task_put(pdu->task); + if (pdu->bhs.opcode == ISCSI_OP_SCSI_DATAIN) { + if (pdu->task->scsi.offset > 0) { + conn->data_in_cnt--; + if (pdu->bhs.flags & ISCSI_DATAIN_STATUS) { + spdk_iscsi_task_put(spdk_iscsi_task_get_primary(pdu->task)); + } + } - if ((pdu->bhs.opcode == ISCSI_OP_SCSI_DATAIN) && - (offset > 0)) { - conn->data_in_cnt--; spdk_iscsi_conn_handle_queued_datain(conn); } + + spdk_iscsi_task_put(pdu->task); } spdk_put_pdu(pdu); }