Blame SOURCES/0026-libopeniscsiusr-dont-error-loudly-if-a-session-isn-t.patch

9a267a
From b21066fc07261e05590ccab839bf5eee2249d358 Mon Sep 17 00:00:00 2001
9a267a
From: Chris Leech <cleech@redhat.com>
9a267a
Date: Wed, 17 Feb 2021 13:48:25 -0800
9a267a
Subject: [PATCH] libopeniscsiusr: dont error loudly if a session isn't found
9a267a
 when working through iscsi_sessions_get()
9a267a
9a267a
Suppress the error message from iscsi_session_get when it's being called
9a267a
through iscsi_sessions_get now that it's not being treated as an error.
9a267a
There's no reason to be so alarmed the session being read in isn't
9a267a
specified exactly.
9a267a
9a267a
Signed-off-by: Chris Leech <cleech@redhat.com>
9a267a
---
9a267a
 libopeniscsiusr/session.c | 21 ++++++++++++++++-----
9a267a
 1 file changed, 16 insertions(+), 5 deletions(-)
9a267a
9a267a
diff --git a/libopeniscsiusr/session.c b/libopeniscsiusr/session.c
9a267a
index 4a724c8..6b06241 100644
9a267a
--- a/libopeniscsiusr/session.c
9a267a
+++ b/libopeniscsiusr/session.c
9a267a
@@ -101,8 +101,8 @@ _iscsi_getter_func_gen(iscsi_session, address, const char *);
9a267a
 _iscsi_getter_func_gen(iscsi_session, port, int32_t);
9a267a
 _iscsi_getter_func_gen(iscsi_session, iface, struct iscsi_iface *);
9a267a
 
9a267a
-int iscsi_session_get(struct iscsi_context *ctx, uint32_t sid,
9a267a
-		      struct iscsi_session **se)
9a267a
+int _iscsi_session_get(struct iscsi_context *ctx, uint32_t sid,
9a267a
+		      struct iscsi_session **se, bool verbose)
9a267a
 {
9a267a
 	int rc = LIBISCSI_OK;
9a267a
 	char *sysfs_se_dir_path = NULL;
9a267a
@@ -137,8 +137,14 @@ int iscsi_session_get(struct iscsi_context *ctx, uint32_t sid,
9a267a
 		rc = LIBISCSI_ERR_SESS_NOT_FOUND;
9a267a
 	}
9a267a
 	if (rc == LIBISCSI_ERR_SESS_NOT_FOUND) {
9a267a
-		_error(ctx, "Specified SID %" PRIu32 " does not exist",
9a267a
-		       sid);
9a267a
+		/* don't complain loudly if called through iscsi_sessions_get()
9a267a
+		 * the caller is not looking for a specific session,
9a267a
+		 * and the list could be changing as we work through it
9a267a
+		 */
9a267a
+		if (verbose) {
9a267a
+			_error(ctx, "Specified SID %" PRIu32 " does not exist",
9a267a
+			       sid);
9a267a
+		}
9a267a
 		goto out;
9a267a
 	}
9a267a
 
9a267a
@@ -240,6 +246,11 @@ out:
9a267a
 	return rc;
9a267a
 }
9a267a
 
9a267a
+int iscsi_session_get(struct iscsi_context *ctx, uint32_t sid,
9a267a
+		      struct iscsi_session **se) {
9a267a
+	return _iscsi_session_get(ctx, sid, se, true);
9a267a
+}
9a267a
+
9a267a
 int iscsi_sessions_get(struct iscsi_context *ctx,
9a267a
 		       struct iscsi_session ***sessions,
9a267a
 		       uint32_t *session_count)
9a267a
@@ -265,7 +276,7 @@ int iscsi_sessions_get(struct iscsi_context *ctx,
9a267a
 
9a267a
 	for (i = 0; i < *session_count; ++i) {
9a267a
 		_debug(ctx, "sid %" PRIu32, sids[i]);
9a267a
-		rc = iscsi_session_get(ctx, sids[i], &((*sessions)[j]));
9a267a
+		rc = _iscsi_session_get(ctx, sids[i], &((*sessions)[j]), false);
9a267a
 		if (rc == LIBISCSI_OK) {
9a267a
 			/* if session info was successfully read from sysfs, advance the sessions pointer */
9a267a
 			j++;
9a267a
-- 
9a267a
2.26.2
9a267a