discover: Rescan SCSI devices on reinit
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>
Wed, 30 May 2018 05:36:45 +0000 (15:36 +1000)
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>
Tue, 12 Jun 2018 03:03:55 +0000 (13:03 +1000)
Explicitly rescan SCSI devices on reinit rather than just remounting
them in case a device did not init properly on boot.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
configure.ac
discover/device-handler.c
lib/system/system.c
lib/system/system.h
utils/Makefile.am
utils/scsi-rescan [new file with mode: 0755]

index bdd7f70011ce47014cbcba8b510b6a969cf73f3a..9eb08552910c0e79fdf08634157d12eea8d599a0 100644 (file)
@@ -343,6 +343,7 @@ DEFINE_HOST_PROG(VGCHANGE, vgchange, [/usr/sbin/vgchange])
 DEFINE_HOST_PROG(PB_PLUGIN, pb-plugin, [/usr/sbin/pb-plugin])
 DEFINE_HOST_PROG(PB_EXEC, pb-exec, [/usr/sbin/pb-exec])
 DEFINE_HOST_PROG(SH, sh, [/bin/sh])
+DEFINE_HOST_PROG(SCSI_RESCAN, scsi-rescan, [/usr/sbin/scsi-rescan])
 
 AC_ARG_WITH(
     [tftp],
index 569e65290bd7e98cef518b078a16f76547ecb564..aa61bd25ae92eb7fc28d0b0bc8e3177fb368f9b4 100644 (file)
@@ -451,6 +451,9 @@ void device_handler_reinit(struct device_handler *handler)
                discover_server_notify_config(handler->server, config);
        }
 
+       /* Force rediscovery on SCSI devices */
+       process_run_simple(handler, pb_system_apps.scsi_rescan, NULL);
+
        device_handler_reinit_sources(handler);
 }
 
index b1121a17a4df6e59ccc9f66541845ed14c49ecb0..6dafcb0868765ceb22a5910a50ddd81e1baf5040 100644 (file)
@@ -33,6 +33,7 @@ const struct pb_system_apps pb_system_apps = {
        .pb_plugin      = HOST_PROG_PB_PLUGIN,
        .pb_exec        = HOST_PROG_PB_EXEC,
        .sh             = HOST_PROG_SH,
+       .scsi_rescan    = HOST_PROG_SCSI_RESCAN,
 };
 
 #ifndef TFTP_TYPE
index d27c2cd4d79d89b342587831e3b3dde6f74b6fa8..38fe392a8054522425f2caaf5eddd6058e164e11 100644 (file)
@@ -18,6 +18,7 @@ struct pb_system_apps {
        const char *pb_plugin;
        const char *pb_exec;
        const char *sh;
+       const char *scsi_rescan;
 };
 
 extern const struct pb_system_apps pb_system_apps;
index c9015a0282581ae730de4438594ba4ae90f8bd5e..a523430b54df4c50787a6e625a1aa926dd2e86c3 100644 (file)
@@ -12,7 +12,8 @@
 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #
 
-dist_sbin_SCRIPTS += utils/pb-udhcpc utils/pb-plugin utils/pb-sos utils/pb-exec
+dist_sbin_SCRIPTS += utils/pb-udhcpc utils/pb-plugin utils/pb-sos \
+                    utils/pb-exec utils/scsi-rescan
 dist_pkglibexec_SCRIPTS = utils/pb-console
 sbin_PROGRAMS += utils/pb-event utils/pb-config
 
diff --git a/utils/scsi-rescan b/utils/scsi-rescan
new file mode 100755 (executable)
index 0000000..1d1cb1b
--- /dev/null
@@ -0,0 +1,5 @@
+#/bin/sh
+
+for host in /sys/class/scsi_host/host*; do
+       echo "- - -" > ${host}/scan
+done