From 143692d18f5e7c319f5a7dc76a2889dd855b01db Mon Sep 17 00:00:00 2001 From: Ziye Yang Date: Fri, 6 Jan 2017 08:56:34 +0800 Subject: [PATCH] iscsi: handle the corner case while partial read is failed Change-Id: If2ba687d49bd5e282c3a5f8516760859376dc658 Signed-off-by: Ziye Yang --- lib/iscsi/iscsi.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c index 0b5e17f26..5b02cbe60 100644 --- a/lib/iscsi/iscsi.c +++ b/lib/iscsi/iscsi.c @@ -2700,6 +2700,20 @@ spdk_iscsi_transfer_in(struct spdk_iscsi_conn *conn, data_len = task->scsi.data_transferred; transfer_len = task->scsi.length; + if (task->scsi.status != SPDK_SCSI_STATUS_GOOD) { + if (task != primary) { + conn->data_in_cnt--; + } else { + /* handle the case that it is a primary task which has subtasks */ + if (primary->scsi.transfer_len != task->scsi.length) { + conn->data_in_cnt--; + spdk_iscsi_task_put(task); + } + } + + return 0; + } + if (data_len < transfer_len) { /* underflow */ SPDK_TRACELOG(SPDK_TRACE_DEBUG, "Underflow %u/%u\n",