Compare commits

..

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
f75c64db22
!139 update open-iscsi.spec
From: @cossbow 
Reviewed-by: @volcanodragon 
Signed-off-by: @swf504
2024-02-21 09:48:40 +00:00
zhuchunyi
56143befd3 update sub version for modify .spec info
Last commit modify info but ver no not changed, this commit just
change version for update.
2024-02-21 14:27:41 +08:00
openeuler-ci-bot
978da269ab
!130 update open-iscsi.spec
From: @cossbow 
Reviewed-by: @wenchao-hao, @swf504 
Signed-off-by: @swf504
2024-02-19 06:10:48 +00:00
SuperSix173
57c8b69a53 update open-iscsi.spec
correct the spell error.
2024-02-02 14:51:06 +08:00
openeuler-ci-bot
2aa4815ed6
!124 iscsid: fixformatoverflowwarning.
From: @louhongxiang 
Reviewed-by: @wubo009 
Signed-off-by: @liuzhiqiang26
2023-06-25 06:44:00 +00:00
louhongxiang
e12b72440b iscsid: fixformatoverflowwarning.
This function can be called with NULL arguments, so check that before
passing to log_error.
2023-06-25 14:18:05 +08:00
openeuler-ci-bot
d5290666f9
!120 iscsid: stop connection for recovery if error is not timeout in iscsi_login_eh
From: @wenchao-hao 
Reviewed-by: @wubo009 
Signed-off-by: @wubo009
2023-01-17 09:33:38 +00:00
Wenchao Hao
021ba3614f iscsid: stop connection for recovery if error is not timeout in iscsi_login_eh
When iscsid is reopening a connection, and the reopen process has succeed
to call bind_conn and comes to iscsi_session_set_params() to set
parameters. If the iscsi target trigger another error event(such as
close the socket connection between initiator and target) at this time,
kernel would perform the error handler and set connection's state to
ISCSI_CONN_FAILED, and set kernel iscsi_cls_conn->flags'
ISCSI_CLS_CONN_BIT_CLEANUP bit. Which would make iscsid's
iscsi_session_set_params() failed with ENOTCONN, so iscsi_login_eh()
would be called by iscsid to handle this error.

Now iscsid see conn->state is ISCSI_CONN_STATE_XPT_WAIT and
session->r_stage is R_STAGE_SESSION_REOPEN, so it would call
session_conn_reopen() with do_stop set to 0, which would not trigger
kernel to call iscsi_if_stop_conn() to clear kernel data struct
iscsi_cls_conn->flags' ISCSI_CLS_CONN_BIT_CLEANUP bit.

The reopen would fall into an infinite cycle which looks like
following:

iscsi_conn_connect -> bind_conn(failed with ENOTCONN)

         ^                     |
         |                     |
         |                     v

    session_conn_reopwn(with do_stop set to 0)

The phenomenon is iscsid would always report log "can't bind conn x:0
to session x, retcode -107 (115)" and the session would not recovery.

Fix this issue by checking error type in iscsi_login_eh(), if the error
type is not timeout, make sure we would call session_conn_reopen() with
do_stop set to STOP_CONN_RECOVER.

Signed-off-by: Wenchao Hao <haowenchao@huawei.com>
2023-01-17 17:28:21 +08:00
openeuler-ci-bot
3d3a92976e
!116 iscsid: clear scanning thread's PR_SET_IO_FLUSHER flag
From: @wenchao-hao 
Reviewed-by: @wubo009 
Signed-off-by: @wubo009
2023-01-17 09:07:56 +00:00
Wenchao Hao
a9eca8e602 iscsid: clear scanning thread's PR_SET_IO_FLUSHER flag
commit 72949ef (iscsid: set PR_SET_IO_FLUSHER) set the iscsid's
PR_SET_IO_FLUSHER flag to avoid deadlock. While we do not need
to set this flag when scanning host.

If this flag is set for scanning thread, we may lost devices
reported by target because of memory allocation failure.

Signed-off-by: Wenchao Hao <haowenchao@huawei.com>
2023-01-17 17:05:00 +08:00
4 changed files with 265 additions and 4 deletions

View File

@ -0,0 +1,150 @@
From 138a5306fc9238d0becf3cc8a5d90ca0b9d71f72 Mon Sep 17 00:00:00 2001
From: Wenchao Hao <73930449+wenchao-hao@users.noreply.github.com>
Date: Thu, 5 Jan 2023 07:46:05 +0800
Subject: [PATCH 1/2] iscsid: clear scanning thread's PR_SET_IO_FLUSHER flag
(#382)
commit 72949ef (iscsid: set PR_SET_IO_FLUSHER) set the iscsid's
PR_SET_IO_FLUSHER flag to avoid deadlock. While we do not need
to set this flag when scanning host.
If this flag is set for scanning thread, we may lost devices
reported by target because of memory allocation failure.
Signed-off-by: Wenchao Hao <haowenchao@huawei.com>
---
usr/iscsi_sysfs.c | 7 +++++++
usr/iscsi_util.c | 27 +++++++++++++++++++++++++++
usr/iscsi_util.h | 1 +
usr/iscsid.c | 15 ++-------------
4 files changed, 37 insertions(+), 13 deletions(-)
diff --git a/usr/iscsi_sysfs.c b/usr/iscsi_sysfs.c
index 9a591be..07fb059 100644
--- a/usr/iscsi_sysfs.c
+++ b/usr/iscsi_sysfs.c
@@ -40,6 +40,7 @@
#include "host.h"
#include "iscsi_err.h"
#include "flashnode.h"
+#include "iscsi_util.h"
/*
* TODO: remove the _DIR defines and search for subsys dirs like
@@ -1994,6 +1995,12 @@ pid_t iscsi_sysfs_scan_host(int hostno, int async, int autoscan)
/* child */
log_debug(4, "scanning host%d", hostno);
+ /*
+ * The return value of init_thread_io_flusher would not
+ * affect the scan flow, so just ignore it.
+ */
+ set_thread_io_flusher(0);
+
snprintf(id, sizeof(id), ISCSI_HOST_ID, hostno);
sysfs_set_param(id, SCSI_HOST_SUBSYS, "scan", write_buf,
strlen(write_buf));
diff --git a/usr/iscsi_util.c b/usr/iscsi_util.c
index 2f1de3e..2a8408c 100644
--- a/usr/iscsi_util.c
+++ b/usr/iscsi_util.c
@@ -30,6 +30,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/resource.h>
+#include <sys/prctl.h>
#include "sysdeps.h"
#include "log.h"
@@ -38,6 +39,10 @@
#include "session_info.h"
#include "iscsi_util.h"
+#ifndef PR_SET_IO_FLUSHER
+#define PR_SET_IO_FLUSHER 57
+#endif
+
int setup_abstract_addr(struct sockaddr_un *addr, char *unix_sock_name)
{
memset(addr, 0, sizeof(*addr));
@@ -392,3 +397,25 @@ int iscsi_match_target(void *data, struct session_info *info)
info->persistent_port, NULL,
MATCH_ANY_SID);
}
+
+/*
+ * set thread's PR_SET_IO_FLUSHER flag
+ *
+ * val: 1 to set to set thread's PR_SET_IO_FLUSHER flag
+ * 0 to clear thread's PR_SET_IO_FLUSHER flag
+ *
+ * return: return 0 on success, else error number is returned
+ */
+int set_thread_io_flusher(int val)
+{
+ if (prctl(PR_SET_IO_FLUSHER, val, 0, 0, 0) == 0)
+ return 0;
+
+ /*
+ * prctl would return EINVAL if the kernel do not support PR_SET_IO_FLUSHER
+ * so donot print error log if errorno is EINVAL to avoid unnecessary errorlog
+ */
+ if (errno != EINVAL)
+ log_error("prctl could not %s thread's PR_SET_IO_FLUSHER flag due to error %s\n", val ? "set" : "clear", strerror(errno));
+ return errno;
+}
diff --git a/usr/iscsi_util.h b/usr/iscsi_util.h
index ff725eb..43889af 100644
--- a/usr/iscsi_util.h
+++ b/usr/iscsi_util.h
@@ -20,6 +20,7 @@ extern int __iscsi_match_session(struct node_rec *rec, char *targetname,
char *address, int port,
struct iface_rec *iface,
unsigned sid);
+extern int set_thread_io_flusher(int val);
#define MATCH_ANY_SID 0
diff --git a/usr/iscsid.c b/usr/iscsid.c
index 0cf2368..d5ea789 100644
--- a/usr/iscsid.c
+++ b/usr/iscsid.c
@@ -34,7 +34,6 @@
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/prctl.h>
#ifndef NO_SYSTEMD
#include <systemd/sd-daemon.h>
#endif
@@ -57,10 +56,6 @@
#include "iscsid_req.h"
#include "iscsi_err.h"
-#ifndef PR_SET_IO_FLUSHER
-#define PR_SET_IO_FLUSHER 57
-#endif
-
/* global config info */
struct iscsi_daemon_config daemon_config;
struct iscsi_daemon_config *dconfig = &daemon_config;
@@ -630,14 +625,8 @@ int main(int argc, char *argv[])
exit(ISCSI_ERR);
}
- if (prctl(PR_SET_IO_FLUSHER, 1, 0, 0, 0) == -1) {
- if (errno == EINVAL) {
- log_info("prctl could not mark iscsid with the PR_SET_IO_FLUSHER flag, because the feature is not supported in this kernel. Will proceed, but iscsid may hang during session level recovery if memory is low.\n");
- } else {
- log_error("prctl could not mark iscsid with the PR_SET_IO_FLUSHER flag due to error %s\n",
- strerror(errno));
- }
- }
+ if (set_thread_io_flusher(1) == EINVAL)
+ log_info("prctl could not mark iscsid with the PR_SET_IO_FLUSHER flag, because the feature is not supported in this kernel. Will proceed, but iscsid may hang during session level recovery if memory is low.\n");
set_state_to_ready();
event_loop(ipc, control_fd, mgmt_ipc_fd);
--
2.35.3

View File

@ -0,0 +1,68 @@
From 9f2074568e6c39f85c9d948cb3b869f4fc774695 Mon Sep 17 00:00:00 2001
From: Wenchao Hao <73930449+wenchao-hao@users.noreply.github.com>
Date: Thu, 12 Jan 2023 11:10:05 +0800
Subject: iscsid: stop connection for recovery if error is not
timeout in iscsi_login_eh (#388)
When iscsid is reopening a connection, and the reopen process has succeed
to call bind_conn and comes to iscsi_session_set_params() to set
parameters. If the iscsi target trigger another error event(such as
close the socket connection between initiator and target) at this time,
kernel would perform the error handler and set connection's state to
ISCSI_CONN_FAILED, and set kernel iscsi_cls_conn->flags'
ISCSI_CLS_CONN_BIT_CLEANUP bit. Which would make iscsid's
iscsi_session_set_params() failed with ENOTCONN, so iscsi_login_eh()
would be called by iscsid to handle this error.
Now iscsid see conn->state is ISCSI_CONN_STATE_XPT_WAIT and
session->r_stage is R_STAGE_SESSION_REOPEN, so it would call
session_conn_reopen() with do_stop set to 0, which would not trigger
kernel to call iscsi_if_stop_conn() to clear kernel data struct
iscsi_cls_conn->flags' ISCSI_CLS_CONN_BIT_CLEANUP bit.
The reopen would fall into an infinite cycle which looks like
following:
iscsi_conn_connect -> bind_conn(failed with ENOTCONN)
^ |
| |
| v
session_conn_reopwn(with do_stop set to 0)
The phenomenon is iscsid would always report log "can't bind conn x:0
to session x, retcode -107 (115)" and the session would not recovery.
Fix this issue by checking error type in iscsi_login_eh(), if the error
type is not timeout, make sure we would call session_conn_reopen() with
do_stop set to STOP_CONN_RECOVER.
Signed-off-by: Wenchao Hao <haowenchao@huawei.com>
---
usr/initiator.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/usr/initiator.c b/usr/initiator.c
index 56bf38b..9c48dd5 100644
--- a/usr/initiator.c
+++ b/usr/initiator.c
@@ -735,8 +735,13 @@ static void iscsi_login_eh(struct iscsi_conn *conn, struct queue_task *qtask,
session_conn_shutdown(conn, qtask, err);
break;
}
- /* timeout during reopen connect. try again */
- session_conn_reopen(conn, qtask, 0);
+ /*
+ * stop connection for recovery if error is not
+ * timeout
+ */
+ if (err != ISCSI_ERR_TRANS_TIMEOUT)
+ stop_flag = STOP_CONN_RECOVER;
+ session_conn_reopen(conn, qtask, stop_flag);
break;
case R_STAGE_SESSION_CLEANUP:
session_conn_shutdown(conn, qtask, err);
--
2.35.3

View File

@ -0,0 +1,29 @@
From 0334727da730a3d011a8e8b350d8df2ddcf408ce Mon Sep 17 00:00:00 2001
From: Chris Leech <cleech@redhat.com>
Date: Mon, 17 Apr 2023 17:04:40 -0700
Subject: [PATCH] discoveryd: fix format overflow warning (#413)
This function can be called with NULL arguments, so check that before
passing to log_error.
Signed-off-by: Chris Leech <cleech@redhat.com>
---
usr/discoveryd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/usr/discoveryd.c b/usr/discoveryd.c
index 08eb2bb..dd639a5 100644
--- a/usr/discoveryd.c
+++ b/usr/discoveryd.c
@@ -372,7 +372,7 @@ static int isns_disc_new_portals(const char *targetname, const char *iname)
&rec_list);
if (rc) {
log_error("Could not perform iSNS DevAttrQuery for node %s.",
- targetname);
+ targetname ? targetname : "(null)");
goto free_ifaces;
}
update_sessions(&rec_list, targetname, iname);
--
2.33.0

View File

@ -4,7 +4,7 @@
Name: open-iscsi
Version: 2.1.5
Release: 10
Release: 14
Summary: ISCSI software initiator daemon and utility programs
License: GPLv2+ and BSD
URL: http://www.open-iscsi.com
@ -34,7 +34,9 @@ patch22: 0022-initiator_common-make-set-operational-parameter-log-.patch
patch23: 0023-Remove-unused-fwparam_ibft.-ch-files-in-fwparam_ibft.patch
patch24: 0024-Fix-a-possible-passing-null-pointer-in-usr-iface.c-3.patch
patch25: 0025-iscsid-iscsiuio-fix-OOM-adjustment-377.patch
patch26: 0026-iscsid-clear-scanning-thread-s-PR_SET_IO_FLUSHER-fla.patch
patch27: 0027-iscsid-stop-connection-for-recovery-if-error-is-not-.patch
patch28: 0028-discoveryd-fix-format-overflow-warning-413.patch
BuildRequires: flex bison doxygen kmod-devel systemd-units gcc git isns-utils-devel systemd-devel
BuildRequires: autoconf automake libtool libmount-devel openssl-devel pkg-config
@ -43,8 +45,8 @@ Provides: iscsi-initiator-utils
Obsoletes: iscsi-initiator-utils
Provides: iscsi-initiator-utils-iscsiuio
Obsoletes: iscsi-initiator-utils-iscsiuio
Provides: libbopeniscsiusr
Obsoletes: libbopeniscsiusr
Provides: libopeniscsiusr
Obsoletes: libopeniscsiusr
%{?systemd_requires}
%description
@ -161,6 +163,18 @@ fi
%{_mandir}/man8/*
%changelog
* Tue Feb 20 2024 jiangjianjun <jiangjianjun3@huawei.com> - 2.1.5-14
- update open-iscsi.spec
* Sun Jun 25 2023 louhongxiang <louhongxiang@huawei.com> - 2.1.5-13
- iscsid: fix format overflow warning.
* Tue Jan 17 2023 haowenchao <haowenchao@huawei.com> - 2.1.5-12
- iscsid: stop connection for recovery if error is not timeout in iscsi_login_eh
* Tue Jan 17 2023 haowenchao <haowenchao@huawei.com> - 2.1.5-11
- iscsid: clear scanning thread's PR_SET_IO_FLUSHER flag
* Fri Dec 2 2022 haowenchao <haowenchao@huawei.com> - 2.1.5-10
- Backport bugfix patches from mainline