From 40b74cd34308ead50214456ced5e8ab5ecc1e9b0 Mon Sep 17 00:00:00 2001 From: Cunyin Chang Date: Wed, 19 Jul 2017 22:26:03 +0800 Subject: [PATCH] iscsi: optimization of large read process. This patch move the spdk_iscsi_conn_handle_queued_tasks() to the main loop of connection poller, make the logic more clear, it will also fix one issue of hotplug: for large read command, it has the potential risk: one task will be split into N subtaks, when primary task return error and try to send data in pdu, it will call spdk_iscsi_conn_handle_queued_tasks(), the primary task is pending now, and all the subtasks will return error from lun layer synchronous, this make the primary task return from the function spdk_iscsi_transfer_in() after all the other subtaks, but when the N - 1 subtask return from function spdk_iscsi_transfer_in(), it meet the condition: primary->bytes_completed == primary->scsi.transfer_len then it will send response pdu, after this, the primary task return from spdk_iscsi_transfer_in(), it also meet the condition, so it will also try to send response pdu, this will make the application run into error. Change-Id: I72206c1ce303f5fb6bd650713742d5819a88a30f Signed-off-by: Cunyin Chang Reviewed-on: https://review.gerrithub.io/370339 Tested-by: SPDK Automated Test System Reviewed-by: Ben Walker Reviewed-by: Daniel Verkamp --- lib/iscsi/conn.c | 3 ++- lib/iscsi/iscsi.c | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/iscsi/conn.c b/lib/iscsi/conn.c index d6424cfd8..b668e0be7 100644 --- a/lib/iscsi/conn.c +++ b/lib/iscsi/conn.c @@ -416,7 +416,6 @@ spdk_iscsi_conn_free_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pd conn->data_in_cnt--; spdk_iscsi_task_put(spdk_iscsi_task_get_primary(pdu->task)); } - spdk_iscsi_conn_handle_queued_tasks(conn); } } else if (pdu->bhs.opcode == ISCSI_OP_SCSI_RSP && pdu->task->scsi.status != SPDK_SCSI_STATUS_GOOD) { @@ -1261,6 +1260,8 @@ spdk_iscsi_conn_execute(struct spdk_iscsi_conn *conn) } } + spdk_iscsi_conn_handle_queued_tasks(conn); + if (conn_active) { return 1; } diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c index 0b09e0104..42b388a80 100644 --- a/lib/iscsi/iscsi.c +++ b/lib/iscsi/iscsi.c @@ -2722,12 +2722,10 @@ spdk_iscsi_transfer_in(struct spdk_iscsi_conn *conn, if (task->scsi.status != SPDK_SCSI_STATUS_GOOD) { if (task != primary) { conn->data_in_cnt--; - spdk_iscsi_conn_handle_queued_tasks(conn); } 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_conn_handle_queued_tasks(conn); } }