Blame SOURCES/open-iscsi-2.0.874-23-Fix-manual-LUN-scans-feature.patch

c487f3
From d5483b0df96bd2a1cf86039cf4c6822ec7d7f609 Mon Sep 17 00:00:00 2001
c487f3
From: Gorka Eguileor <geguileo@redhat.com>
c487f3
Date: Fri, 17 Mar 2017 16:00:11 +0100
c487f3
Subject: Fix manual LUN scans feature
c487f3
c487f3
The newly introduced feature to disable automatic scans should not be
c487f3
scanning *any* of the LUNs when the scan is set to manual, but it always
c487f3
scans for LUN0.
c487f3
c487f3
This patch fixes this by skipping the sysfs call altogether, as it
c487f3
should have been doing from the start.
c487f3
---
c487f3
 usr/iscsi_sysfs.c | 13 +++++++------
c487f3
 usr/iscsi_sysfs.h |  2 +-
c487f3
 2 files changed, 8 insertions(+), 7 deletions(-)
c487f3
c487f3
diff --git a/usr/iscsi_sysfs.c b/usr/iscsi_sysfs.c
c487f3
index 2f94b632baaa..0cc55b97bde9 100644
c487f3
--- a/usr/iscsi_sysfs.c
c487f3
+++ b/usr/iscsi_sysfs.c
c487f3
@@ -1883,18 +1883,19 @@ void iscsi_sysfs_rescan_device(void *data, int hostno, int target, int lun)
c487f3
 			strlen(write_buf));
c487f3
 }
c487f3
 
c487f3
-pid_t iscsi_sysfs_scan_host(int hostno, int async, int full_scan)
c487f3
+pid_t iscsi_sysfs_scan_host(int hostno, int async, int autoscan)
c487f3
 {
c487f3
 	char id[NAME_SIZE];
c487f3
-	char write_buf[6] = "- - 0";
c487f3
+	char *write_buf = "- - -";
c487f3
 	pid_t pid = 0;
c487f3
 
c487f3
-	if (full_scan)
c487f3
-		write_buf[4] = '-';
c487f3
-
c487f3
 	if (async)
c487f3
 		pid = fork();
c487f3
-	if (pid == 0) {
c487f3
+
c487f3
+	if (pid >= 0 && !autoscan) {
c487f3
+		if (pid)
c487f3
+			log_debug(4, "host%d in manual scan mode, skipping scan", hostno);
c487f3
+	} else if (pid == 0) {
c487f3
 		/* child */
c487f3
 		log_debug(4, "scanning host%d", hostno);
c487f3
 
c487f3
diff --git a/usr/iscsi_sysfs.h b/usr/iscsi_sysfs.h
c487f3
index 3492ce6e033c..cdcefa65f683 100644
c487f3
--- a/usr/iscsi_sysfs.h
c487f3
+++ b/usr/iscsi_sysfs.h
c487f3
@@ -87,7 +87,7 @@ extern void iscsi_sysfs_get_negotiated_session_conf(int sid,
c487f3
 				struct iscsi_session_operational_config *conf);
c487f3
 extern void iscsi_sysfs_get_negotiated_conn_conf(int sid,
c487f3
 				struct iscsi_conn_operational_config *conf);
c487f3
-extern pid_t iscsi_sysfs_scan_host(int hostno, int async, int full);
c487f3
+extern pid_t iscsi_sysfs_scan_host(int hostno, int async, int autoscan);
c487f3
 extern int iscsi_sysfs_get_session_state(char *state, int sid);
c487f3
 extern int iscsi_sysfs_get_host_state(char *state, int host_no);
c487f3
 extern int iscsi_sysfs_get_device_state(char *state, int host_no, int target,
c487f3
-- 
c487f3
2.9.3
c487f3