Commit 476b1b0f authored by Ziye Yang's avatar Ziye Yang Committed by Changpeng Liu
Browse files

lib/iscsi: fix the queued_datain_task hanlding issue.



Due to the network issue, spdk_iscsi_conn_free_pdu in
spdk_iscsi_conn_flush_pdus_internal will not be executed.
So consider the pdu free, we should call spdk_iscsi_conn_free_pdu
in spdk_iscsi_conn_free_tasks.

Actually, for the task which in queued_datain_task, we have
the following case:

1 The task is not sent to the scsi layer: it means that
the task is not freed, so we should call spdk_iscsi_task_put
here.
2 The task is sent to the scsi layer, but no subtasks
are sent to the scsi layer: It means that the call
back function (spdk_iscsi_task_cpl) will be called,
but since it will have the subtask, so spdk_iscsi_task_put
will not be called, thus, we should call spdk_iscsi_task_put
here.
3 The task is sent to the scsi layer, and some subtasks
are also sent to the scsi layer: It also mean that the
spdk_iscsi_task_put will not be called in spdk_iscsi_task_cpl,
and not all the subtasks will be finished, so the father task
will not be freed, so we should still call spdk_iscsi_task_put
here.

4 The task is sent to the scsi layer, and all the subtasks
are also sent to the scsi layer,
thus this task is not in the queued_data_in_task.

So according to 1-4, we should call spdk_iscsi_task_put here,
and also decrease the data_in_cnt;

Change-Id: Icb13df1ae07f6eea0247d45f4a0397edc4aa2500
Signed-off-by: default avatarZiye Yang <optimistyzy@gmail.com>
Reviewed-on: https://review.gerrithub.io/420875


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
parent 5ff172ee
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -364,10 +364,7 @@ static int spdk_iscsi_conn_free_tasks(struct spdk_iscsi_conn *conn)

	TAILQ_FOREACH_SAFE(pdu, &conn->write_pdu_list, tailq, tmp_pdu) {
		TAILQ_REMOVE(&conn->write_pdu_list, pdu, tailq);
		if (pdu->task) {
			spdk_iscsi_task_put(pdu->task);
		}
		spdk_put_pdu(pdu);
		spdk_iscsi_conn_free_pdu(conn, pdu);
	}

	TAILQ_FOREACH_SAFE(pdu, &conn->snack_pdu_list, tailq, tmp_pdu) {
@@ -380,9 +377,7 @@ static int spdk_iscsi_conn_free_tasks(struct spdk_iscsi_conn *conn)

	TAILQ_FOREACH_SAFE(iscsi_task, &conn->queued_datain_tasks, link, tmp_iscsi_task) {
		TAILQ_REMOVE(&conn->queued_datain_tasks, iscsi_task, link);
		pdu = iscsi_task->pdu;
		spdk_iscsi_task_put(iscsi_task);
		spdk_put_pdu(pdu);
	}

	if (conn->pending_task_cnt) {