Blame SOURCES/open-iscsi-2.0.876-69-Create-a-new-error-for-target-not-connected.patch

62f653
commit 7d121d12ad6ba7783308c25ffd338a9fa0cc402b
62f653
Author: Lee Duncan <lduncan@suse.com>
62f653
Date:   Tue Sep 25 09:48:53 2018 -0700
62f653
62f653
    Create a new error for "target not connected".
62f653
    
62f653
    The session_logout_qtask() function now recognizes
62f653
    a new state of "target likely not connected" if
62f653
    syncing up, in connection wait state, and re-opening
62f653
    the connection.
62f653
---
62f653
 include/iscsi_err.h |  2 ++
62f653
 usr/initiator.c     | 16 +++++++++++++++-
62f653
 usr/iscsi_err.c     |  1 +
62f653
 3 files changed, 18 insertions(+), 1 deletion(-)
62f653
62f653
diff --git a/include/iscsi_err.h b/include/iscsi_err.h
62f653
index 506bd8c9bd27..ed000dd00baf 100644
62f653
--- a/include/iscsi_err.h
62f653
+++ b/include/iscsi_err.h
62f653
@@ -68,6 +68,8 @@ enum {
62f653
 	ISCSI_ERR_UNKNOWN_DISCOVERY_TYPE = 30,
62f653
 	/* child process terminated */
62f653
 	ISCSI_ERR_CHILD_TERMINATED	= 31,
62f653
+	/* session likely not connected */
62f653
+	ISCSI_ERR_SESSION_NOT_CONNECTED = 32,
62f653
 
62f653
 	/* Always last. Indicates end of error code space */
62f653
 	ISCSI_MAX_ERR_VAL,
62f653
diff --git a/usr/initiator.c b/usr/initiator.c
62f653
index a86d1e6dee90..935056a3abde 100644
62f653
--- a/usr/initiator.c
62f653
+++ b/usr/initiator.c
62f653
@@ -2056,8 +2056,22 @@ int session_logout_task(int sid, queue_task_t *qtask)
62f653
 		return ISCSI_ERR_SESS_NOT_FOUND;
62f653
 	}
62f653
 	conn = &session->conn[0];
62f653
+
62f653
 	/*
62f653
-	 * If syncing up or if this is the initial login and mgmt_ipc
62f653
+	 * If syncing up, in XPT_WAIT, and REOPENing, then return
62f653
+	 * an informative error, since the target for this session
62f653
+	 * is likely not connected
62f653
+	 */
62f653
+	if (session->notify_qtask &&
62f653
+	    (conn->state == ISCSI_CONN_STATE_XPT_WAIT) &&
62f653
+	    (session->r_stage == R_STAGE_SESSION_REOPEN)) {
62f653
+		log_warning("session cannot be terminted because it's trying to reconnect: try again later");
62f653
+		return ISCSI_ERR_SESSION_NOT_CONNECTED;
62f653
+	}
62f653
+
62f653
+	/*
62f653
+	 * If syncing up and not reconnecting,
62f653
+	 * or if this is the initial login and mgmt_ipc
62f653
 	 * has not been notified of that result fail the logout request
62f653
 	 */
62f653
 	if (session->notify_qtask ||
62f653
diff --git a/usr/iscsi_err.c b/usr/iscsi_err.c
62f653
index 1ba9e648d7c1..23c61fc3574e 100644
62f653
--- a/usr/iscsi_err.c
62f653
+++ b/usr/iscsi_err.c
62f653
@@ -54,6 +54,7 @@ static char *iscsi_err_msgs[] = {
62f653
 	/* 29 */ "operation failed but retry may succeed",
62f653
 	/* 30 */ "unknown discovery type",
62f653
 	/* 31 */ "child process terminated",
62f653
+	/* 32 */ "target likely not connected",
62f653
 };
62f653
 
62f653
 char *iscsi_err_to_str(int err)