diff --git a/SOURCES/0024-libopeniscsiusr-fix-error-messages.patch b/SOURCES/0024-libopeniscsiusr-fix-error-messages.patch new file mode 100644 index 0000000..81f4998 --- /dev/null +++ b/SOURCES/0024-libopeniscsiusr-fix-error-messages.patch @@ -0,0 +1,96 @@ +From 13affd82b8248b954d10eb4fd3d544796360fafd Mon Sep 17 00:00:00 2001 +From: Chris Leech +Date: Wed, 17 Feb 2021 09:56:55 -0800 +Subject: [PATCH] libopeniscsiusr: fix error messages + +The error message in iscsi_session_get [libopeniscsiusr/session.c:140] +when a session or connection path isn't found in sysfs was failing to +print the session ID, instead it printed the address of the static +string for the remainder of the message ("does not exists") due to an +extra comma. + +Additionally change all occurances of "does not exists" to "does not +exist" + +Signed-off-by: Chris Leech +--- + libopeniscsiusr/libopeniscsiusr/libopeniscsiusr.h | 2 +- + libopeniscsiusr/session.c | 6 +++--- + libopeniscsiusr/sysfs.c | 8 ++++---- + 3 files changed, 8 insertions(+), 8 deletions(-) + +diff --git a/libopeniscsiusr/libopeniscsiusr/libopeniscsiusr.h b/libopeniscsiusr/libopeniscsiusr/libopeniscsiusr.h +index 4395902..a29d5b1 100644 +--- a/libopeniscsiusr/libopeniscsiusr/libopeniscsiusr.h ++++ b/libopeniscsiusr/libopeniscsiusr/libopeniscsiusr.h +@@ -288,7 +288,7 @@ __DLL_EXPORT void iscsi_sessions_free(struct iscsi_session **ses, + * Output pointer of 'struct iscsi_session' pointer. Its memory + * should be freed by iscsi_session_free(). + * If this pointer is NULL, your program will be terminated by assert. +- * If specified iSCSI session does not exists, this pointer will be set to ++ * If specified iSCSI session does not exist, this pointer will be set to + * NULL with LIBISCSI_OK returned. + * + * Return: +diff --git a/libopeniscsiusr/session.c b/libopeniscsiusr/session.c +index 7ace4d6..f122fe3 100644 +--- a/libopeniscsiusr/session.c ++++ b/libopeniscsiusr/session.c +@@ -127,17 +127,17 @@ int iscsi_session_get(struct iscsi_context *ctx, uint32_t sid, + _alloc_null_check(ctx, *se , rc, out); + + if (! _file_exists(sysfs_se_dir_path)) { +- _info(ctx, "Sysfs path '%s' does not exists", ++ _info(ctx, "Sysfs path '%s' does not exist", + sysfs_se_dir_path); + rc = LIBISCSI_ERR_SESS_NOT_FOUND; + } + if (! _file_exists(sysfs_con_dir_path)) { +- _info(ctx, "Sysfs path '%s' does not exists", ++ _info(ctx, "Sysfs path '%s' does not exist", + sysfs_se_dir_path); + rc = LIBISCSI_ERR_SESS_NOT_FOUND; + } + if (rc == LIBISCSI_ERR_SESS_NOT_FOUND) { +- _error(ctx, "Specified SID %" PRIu32, "does not exists", ++ _error(ctx, "Specified SID %" PRIu32 " does not exist", + sid); + goto out; + } +diff --git a/libopeniscsiusr/sysfs.c b/libopeniscsiusr/sysfs.c +index 2c3f077..355ad55 100644 +--- a/libopeniscsiusr/sysfs.c ++++ b/libopeniscsiusr/sysfs.c +@@ -169,11 +169,11 @@ int _sysfs_prop_get_str(struct iscsi_context *ctx, const char *dir_path, + if (default_value == NULL) { + rc = LIBISCSI_ERR_SYSFS_LOOKUP; + _error(ctx, "Failed to read '%s': " +- "file '%s' does not exists", prop_name, ++ "file '%s' does not exist", prop_name, + file_path); + } else { + _info(ctx, "Failed to read '%s': " +- "file '%s' does not exists, " ++ "file '%s' does not exist, " + "using default value %s", prop_name, + file_path, default_value); + memcpy(buff, (void *) default_value, +@@ -244,13 +244,13 @@ static int iscsi_sysfs_prop_get_ll(struct iscsi_context *ctx, + if (! ignore_error) { + rc = LIBISCSI_ERR_SYSFS_LOOKUP; + _error(ctx, "Failed to read '%s': " +- "file '%s' does not exists", ++ "file '%s' does not exist", + prop_name, file_path); + goto out; + } else { + _info(ctx, + "Failed to read '%s': " +- "File '%s' does not exists, using ", ++ "File '%s' does not exist, using ", + "default value %lld", + prop_name, file_path, default_value); + *val = default_value; +-- +2.26.2 + diff --git a/SOURCES/0025-libopeniscsiusr-skip-over-removed-sessions.patch b/SOURCES/0025-libopeniscsiusr-skip-over-removed-sessions.patch new file mode 100644 index 0000000..fdaa9fd --- /dev/null +++ b/SOURCES/0025-libopeniscsiusr-skip-over-removed-sessions.patch @@ -0,0 +1,60 @@ +From a744d91046865416a50ea27f143ef0f02fcaf1c6 Mon Sep 17 00:00:00 2001 +From: Chris Leech +Date: Wed, 17 Feb 2021 12:22:17 -0800 +Subject: [PATCH] libopeniscsiusr: skip over removed sessions + +When looping over all sessions with iscsi_sessions_get, it's possible to +race against sessions being destroyed and have the sysfs attribute files +be removed before they're read. Let's not treat this as an error, and +simply drop the session that failed to read from the list. I think it +makes sense to treat session that disapear while they're being read as +if they were already gone when the sessions directory was first scanned. + +Apparently having iscsiadm exit with an error when trying to get a list +of sessions is a problem for OpenStack deployments. + +Signed-off-by: Chris Leech +--- + libopeniscsiusr/session.c | 18 ++++++++++++++++-- + 1 file changed, 16 insertions(+), 2 deletions(-) + +diff --git a/libopeniscsiusr/session.c b/libopeniscsiusr/session.c +index f122fe3..4a724c8 100644 +--- a/libopeniscsiusr/session.c ++++ b/libopeniscsiusr/session.c +@@ -246,6 +246,7 @@ int iscsi_sessions_get(struct iscsi_context *ctx, + { + int rc = LIBISCSI_OK; + uint32_t i = 0; ++ uint32_t j = 0; + uint32_t *sids = NULL; + + assert(ctx != NULL); +@@ -264,9 +265,22 @@ int iscsi_sessions_get(struct iscsi_context *ctx, + + for (i = 0; i < *session_count; ++i) { + _debug(ctx, "sid %" PRIu32, sids[i]); +- _good(iscsi_session_get(ctx, sids[i], &((*sessions)[i])), +- rc, out); ++ rc = iscsi_session_get(ctx, sids[i], &((*sessions)[j])); ++ if (rc == LIBISCSI_OK) { ++ /* if session info was successfully read from sysfs, advance the sessions pointer */ ++ j++; ++ } else { ++ /* if not, just ignore the issue and keep trying with the next session ID, ++ * there's always going to be an inherent race against session removal when collecting ++ * attribute data from sysfs ++ */ ++ _debug(ctx, "Problem reading session %" PRIu32 ", skipping.", sids[i]); ++ rc = LIBISCSI_OK; ++ } + } ++ /* reset session count and sessions array length to what we were able to read from sysfs */ ++ *session_count = j; ++ *sessions = reallocarray(*sessions, *session_count, sizeof(struct iscsi_session *)); + + out: + free(sids); +-- +2.26.2 + diff --git a/SOURCES/0026-libopeniscsiusr-dont-error-loudly-if-a-session-isn-t.patch b/SOURCES/0026-libopeniscsiusr-dont-error-loudly-if-a-session-isn-t.patch new file mode 100644 index 0000000..ab4d722 --- /dev/null +++ b/SOURCES/0026-libopeniscsiusr-dont-error-loudly-if-a-session-isn-t.patch @@ -0,0 +1,72 @@ +From b21066fc07261e05590ccab839bf5eee2249d358 Mon Sep 17 00:00:00 2001 +From: Chris Leech +Date: Wed, 17 Feb 2021 13:48:25 -0800 +Subject: [PATCH] libopeniscsiusr: dont error loudly if a session isn't found + when working through iscsi_sessions_get() + +Suppress the error message from iscsi_session_get when it's being called +through iscsi_sessions_get now that it's not being treated as an error. +There's no reason to be so alarmed the session being read in isn't +specified exactly. + +Signed-off-by: Chris Leech +--- + libopeniscsiusr/session.c | 21 ++++++++++++++++----- + 1 file changed, 16 insertions(+), 5 deletions(-) + +diff --git a/libopeniscsiusr/session.c b/libopeniscsiusr/session.c +index 4a724c8..6b06241 100644 +--- a/libopeniscsiusr/session.c ++++ b/libopeniscsiusr/session.c +@@ -101,8 +101,8 @@ _iscsi_getter_func_gen(iscsi_session, address, const char *); + _iscsi_getter_func_gen(iscsi_session, port, int32_t); + _iscsi_getter_func_gen(iscsi_session, iface, struct iscsi_iface *); + +-int iscsi_session_get(struct iscsi_context *ctx, uint32_t sid, +- struct iscsi_session **se) ++int _iscsi_session_get(struct iscsi_context *ctx, uint32_t sid, ++ struct iscsi_session **se, bool verbose) + { + int rc = LIBISCSI_OK; + char *sysfs_se_dir_path = NULL; +@@ -137,8 +137,14 @@ int iscsi_session_get(struct iscsi_context *ctx, uint32_t sid, + rc = LIBISCSI_ERR_SESS_NOT_FOUND; + } + if (rc == LIBISCSI_ERR_SESS_NOT_FOUND) { +- _error(ctx, "Specified SID %" PRIu32 " does not exist", +- sid); ++ /* don't complain loudly if called through iscsi_sessions_get() ++ * the caller is not looking for a specific session, ++ * and the list could be changing as we work through it ++ */ ++ if (verbose) { ++ _error(ctx, "Specified SID %" PRIu32 " does not exist", ++ sid); ++ } + goto out; + } + +@@ -240,6 +246,11 @@ out: + return rc; + } + ++int iscsi_session_get(struct iscsi_context *ctx, uint32_t sid, ++ struct iscsi_session **se) { ++ return _iscsi_session_get(ctx, sid, se, true); ++} ++ + int iscsi_sessions_get(struct iscsi_context *ctx, + struct iscsi_session ***sessions, + uint32_t *session_count) +@@ -265,7 +276,7 @@ int iscsi_sessions_get(struct iscsi_context *ctx, + + for (i = 0; i < *session_count; ++i) { + _debug(ctx, "sid %" PRIu32, sids[i]); +- rc = iscsi_session_get(ctx, sids[i], &((*sessions)[j])); ++ rc = _iscsi_session_get(ctx, sids[i], &((*sessions)[j]), false); + if (rc == LIBISCSI_OK) { + /* if session info was successfully read from sysfs, advance the sessions pointer */ + j++; +-- +2.26.2 + diff --git a/SPECS/iscsi-initiator-utils.spec b/SPECS/iscsi-initiator-utils.spec index b1600c5..d4b93c9 100644 --- a/SPECS/iscsi-initiator-utils.spec +++ b/SPECS/iscsi-initiator-utils.spec @@ -13,7 +13,7 @@ Summary: iSCSI daemon and utility programs Name: iscsi-initiator-utils Version: 6.%{open_iscsi_version}.%{open_iscsi_build} -Release: 0.git%{shortcommit0}%{?dist} +Release: 1.git%{shortcommit0}%{?dist} Group: System Environment/Daemons License: GPLv2+ URL: http://www.open-iscsi.org @@ -44,6 +44,9 @@ Patch0020: 0020-fix-upstream-build-breakage-of-iscsiuio-LDFLAGS.patch Patch0021: 0021-use-Red-Hat-version-string-to-match-RPM-package-vers.patch Patch0022: 0022-iscsi_if.h-replace-zero-length-array-with-flexible-a.patch Patch0023: 0023-stop-using-Werror-for-now.patch +Patch0024: 0024-libopeniscsiusr-fix-error-messages.patch +Patch0025: 0025-libopeniscsiusr-skip-over-removed-sessions.patch +Patch0026: 0026-libopeniscsiusr-dont-error-loudly-if-a-session-isn-t.patch BuildRequires: flex bison doxygen kmod-devel systemd-units BuildRequires: autoconf automake libtool libmount-devel openssl-devel @@ -362,6 +365,9 @@ fi %{python3_sitearch}/* %changelog +* Fri Mar 12 2021 Chris Leech - 6.2.1.2-1.gita8fcb37 +- 1924768 iscsiadm -m sessions fails when racing against session login/logout + * Thu Aug 20 2020 Chris Leech - 6.2.0.878-5.gitd791ce0 - 1849931, 1869438 go back to MD5 CHAP only by default new CHAP modes can cause issue with some targets,