iscsi-initiator-utils/SOURCES/0026-libopeniscsiusr-dont-error-loudly-if-a-session-isn-t.patch

73 lines
2.5 KiB
Diff
Raw Normal View History

From b21066fc07261e05590ccab839bf5eee2249d358 Mon Sep 17 00:00:00 2001
From: Chris Leech <cleech@redhat.com>
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 <cleech@redhat.com>
---
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