iscsi-initiator-utils/SOURCES/open-iscsi-2.0.876-69-Creat...

70 lines
2.3 KiB
Diff

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