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

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