diff --git a/0008-do-not-sync-session-when-a-session-is-already-created.patch b/0008-do-not-sync-session-when-a-session-is-already-created.patch deleted file mode 100644 index 65c5d2d8eb3071e25a32a9177c82f6e20512611c..0000000000000000000000000000000000000000 --- a/0008-do-not-sync-session-when-a-session-is-already-created.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 93d217ce22e7668abfc5e6dbc015b37b20174b09 Mon Sep 17 00:00:00 2001 -From: huangkaibin -Date: Fri, 19 Jan 2018 03:00:17 +0800 -Subject: [PATCH] iscsid: Do not sync session when a session is already created - for a remote device - -Do not sync session when a session is already created for a remote device -1. In the following scenarios, two or more sessions will be created and open for one remote device -a) two or more sync sessions are requested from the sync process for the same remote device. -this may occur when iscsid is restarted, one is requested by the previous started sync process but not handled, and another -is requested by the newly started sync process. -b) one is created in sync session, the other is created in __session_login_task. -2. If two or more sessions are created for one remote device, and there are connection problems on the remote device, -these sessions will be reopen again, and will cause one to close the connection while the other to set param for the remote device -in kernel, and will cause kernel to panic. -3. this patch fix this problem by not sync session when a session is already created for a remote device ---- - usr/initiator.c | 7 +++++++ - 1 file changed, 7 insertions(+) - -diff --git a/usr/initiator.c b/usr/initiator.c -index 60bd2b7..4a48bf5 100644 ---- a/usr/initiator.c -+++ b/usr/initiator.c -@@ -2097,11 +2097,18 @@ iscsi_sync_session(node_rec_t *rec, queue_task_t *qtask, uint32_t sid) - iscsi_session_t *session; - struct iscsi_transport *t; - int err; -+ int nr_found; - - t = iscsi_sysfs_get_transport_by_name(rec->iface.transport_name); - if (!t) - return ISCSI_ERR_TRANS_NOT_FOUND; - -+ nr_found = session_find_by_rec(rec); -+ if(nr_found > 0) { -+ log_error("session is already created. sid: %d, name: %s.\n", sid, rec->name); -+ return ISCSI_ERR_SESS_EXISTS; -+ } -+ - session = __session_create(rec, t, &err); - if (!session) - return ISCSI_ERR_LOGIN; --- -1.8.3.1 - diff --git a/0008-iscsid-Check-session-id-before-start-sync-a-thread.patch b/0008-iscsid-Check-session-id-before-start-sync-a-thread.patch new file mode 100644 index 0000000000000000000000000000000000000000..2e2ff2664cf56237b5ae900feb30aa02f66b7919 --- /dev/null +++ b/0008-iscsid-Check-session-id-before-start-sync-a-thread.patch @@ -0,0 +1,59 @@ +From 88fa76cec740cc44b7c4b9b384a87ef6c1288174 Mon Sep 17 00:00:00 2001 +From: Wenchao Hao +Date: Tue, 8 Feb 2022 10:40:33 +0800 +Subject: [PATCH] iscsid: Check session id before start sync a thread + +If session id has already been synced just return ISCSI_ERR_SESS_EXISTS. + +A same session id would make two MGMT_IPC_SESSION_SYNC requests in +following scenario: + +iscsid.socket is enabled, and iscsid did not handle previous +MGMT_IPC_SESSION_SYNC due to abnormal exit. This MGMT_IPC_SESSION_SYNC +request would left unhandled, when iscsid restart again, newly started +iscsid can get this MGMT_IPC_SESSION_SYNC request. + +While the newly started iscsid would make a MGMT_IPC_SESSION_SYNC +request for same session id too. + +So here should check if the session id has already been synced. + +Signed-off-by: Wenchao Hao +--- + usr/initiator.c | 4 ++++ + usr/iscsid.c | 3 +++ + 2 files changed, 7 insertions(+) + +diff --git a/usr/initiator.c b/usr/initiator.c +index 684647c..4ec00b0 100644 +--- a/usr/initiator.c ++++ b/usr/initiator.c +@@ -2012,6 +2012,10 @@ iscsi_sync_session(node_rec_t *rec, queue_task_t *qtask, uint32_t sid) + struct iscsi_transport *t; + int err; + ++ session = session_find_by_sid(sid); ++ if (session != NULL) ++ return ISCSI_ERR_SESS_EXISTS; ++ + t = iscsi_sysfs_get_transport_by_name(rec->iface.transport_name); + if (!t) + return ISCSI_ERR_TRANS_NOT_FOUND; +diff --git a/usr/iscsid.c b/usr/iscsid.c +index 478c83d..e5bd1f5 100644 +--- a/usr/iscsid.c ++++ b/usr/iscsid.c +@@ -289,7 +289,10 @@ retry: + retries++; + sleep(1); + goto retry; ++ } else if (rc == ISCSI_ERR_SESS_EXISTS) { ++ log_debug(1, "sync session %d returned ISCSI_ERR_SESS_EXISTS", info->sid); + } ++ + return 0; + } + +-- +2.27.0 + diff --git a/open-iscsi.spec b/open-iscsi.spec index d8d7d71680b27dbc3d4d820d0834b5ee05e40192..de7375e78f3d2a4567481cebede327d489785b70 100644 --- a/open-iscsi.spec +++ b/open-iscsi.spec @@ -4,7 +4,7 @@ Name: open-iscsi Version: 2.1.1 -Release: 11 +Release: 12 Summary: ISCSI software initiator daemon and utility programs License: GPLv2+ and BSD URL: http://www.open-iscsi.com @@ -16,7 +16,7 @@ Patch4: 0004-not-send-stop-message-if-iscsid-absent.patch Patch5: 0005-iscsid-SIGTERM-syncprocess-hang.patch Patch6: 0006-restart-log-daemon-when-exited-abnormally.patch Patch7: 0007-check-initiator-name-out-of-range.patch -Patch8: 0008-do-not-sync-session-when-a-session-is-already-created.patch +Patch8: 0008-iscsid-Check-session-id-before-start-sync-a-thread.patch Patch9: 0009-fix-default-file-corrupt.patch Patch10: 0010-iscsiadm-fix-infinite-loop-while-recv-returns-0.patch Patch11: 0011-fix-iscsiadm-logout-timeout.patch @@ -166,6 +166,9 @@ fi %{_mandir}/man8/* %changelog +* Tue Sep 27 2022 haowenchao - 2.1.1-12 +- Substitute self-developed patch with mainline patch + * Thu Oct 21 2021 haowenchao - 2.1.1-11 - Remove password print in session info display