From 97406c5b36ac85a9f1cfa78a998052429206a825 Mon Sep 17 00:00:00 2001 From: Peter Lieven Date: Thu, 17 Mar 2016 11:41:36 +0100 Subject: [PATCH 1/2] Revert "Fail pending LOGOUT commands on session reconnect" This seriously breaks qemu NOP timeouts and probably other things. The reason is that the define ISCSI_PDU_ERROR_ON_RECONNECT 0x00000016 is masking bits 0x2 and 0x4 as well. Correctly it should read: define ISCSI_PDU_ERROR_ON_RECONNECT 0x00000010 However, the better solution for this approach is invoke all callbacks of PDUs which carry the ISCSI_PDU_DROP_ON_RECONNECT flag. This will make sure that callbacks of whatever sync tasks are invoked. This reverts commit 0407cf6aed5e7acf0d99afaa9ce5d5179a8986cc. --- include/iscsi-private.h | 2 -- lib/connect.c | 12 ------------ lib/login.c | 2 +- 3 files changed, 1 insertion(+), 15 deletions(-) diff --git a/include/iscsi-private.h b/include/iscsi-private.h index 1d0f263..77425b0 100644 --- a/include/iscsi-private.h +++ b/include/iscsi-private.h @@ -233,8 +233,6 @@ struct iscsi_pdu { #define ISCSI_PDU_DROP_ON_RECONNECT 0x00000004 /* stop sending after this PDU has been sent */ #define ISCSI_PDU_CORK_WHEN_SENT 0x00000008 -/* Fail the command with error on reconnect */ -#define ISCSI_PDU_ERROR_ON_RECONNECT 0x00000016 uint32_t flags; diff --git a/lib/connect.c b/lib/connect.c index a1abbf6..093827f 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -338,18 +338,6 @@ void iscsi_reconnect_cb(struct iscsi_context *iscsi _U_, int status, continue; } - if (pdu->flags & ISCSI_PDU_ERROR_ON_RECONNECT) { - /* - * We only want to re-queue SCSI COMMAND PDUs. - * All other PDUs are discarded at this point. - * This includes DATA-OUT, NOP and task management. - */ - pdu->callback(iscsi, SCSI_STATUS_ERROR, NULL, - pdu->private_data); - iscsi_free_pdu(old_iscsi, pdu); - continue; - } - if (pdu->flags & ISCSI_PDU_DROP_ON_RECONNECT) { /* * We only want to re-queue SCSI COMMAND PDUs. diff --git a/lib/login.c b/lib/login.c index aa4dfaa..72ceaf9 100644 --- a/lib/login.c +++ b/lib/login.c @@ -1267,7 +1267,7 @@ iscsi_logout_async(struct iscsi_context *iscsi, iscsi_command_cb cb, ISCSI_PDU_LOGOUT_REQUEST, ISCSI_PDU_LOGOUT_RESPONSE, iscsi_itt_post_increment(iscsi), - ISCSI_PDU_ERROR_ON_RECONNECT|ISCSI_PDU_CORK_WHEN_SENT); + ISCSI_PDU_DROP_ON_RECONNECT|ISCSI_PDU_CORK_WHEN_SENT); if (pdu == NULL) { iscsi_set_error(iscsi, "Out-of-memory: Failed to allocate " "logout pdu."); From a7c94a7af52b84cd92d334824a6ffd602ff98756 Mon Sep 17 00:00:00 2001 From: Peter Lieven Date: Thu, 17 Mar 2016 11:55:46 +0100 Subject: [PATCH 2/2] connect: invoke all callbacks for dropped PDUs if we drop a PDU which has a callback we should invoke it otherwise the caller may wait infinetely for a command completion. Signed-off-by: Peter Lieven --- lib/connect.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/connect.c b/lib/connect.c index 093827f..b7adb25 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -344,6 +344,10 @@ void iscsi_reconnect_cb(struct iscsi_context *iscsi _U_, int status, * All other PDUs are discarded at this point. * This includes DATA-OUT, NOP and task management. */ + if (pdu->callback) { + pdu->callback(iscsi, SCSI_STATUS_CANCELLED, + NULL, pdu->private_data); + } iscsi_free_pdu(old_iscsi, pdu); continue; }