01ff50
From 8b668d4aa3305af5963162b7499b128bd71f8f29 Mon Sep 17 00:00:00 2001
01ff50
From: Lukasz Florczak <lukasz.florczak@linux.intel.com>
01ff50
Date: Thu, 22 Sep 2022 08:29:50 +0200
01ff50
Subject: [PATCH 61/83] Mdmonitor: Omit non-md devices
01ff50
01ff50
Fix segfault commit [1] introduced check whether given device is
01ff50
mddevice, but it happend to terminate Mdmonitor if at least one of given
01ff50
devices didn't fulfill that condition. In result Mdmonitor service was
01ff50
no longer started on boot (with --scan option) when config contained some
01ff50
non-existent array entry.
01ff50
01ff50
This commit introduces ommiting non-md devices so scan option can still
01ff50
be used when config is wrong and allow Mdmonitor service to run on boot.
01ff50
01ff50
Giving a list of devices to monitor containing non-existing or
01ff50
non-md devices will result in monitoring only confirmed mddevices.
01ff50
01ff50
[1] https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/commit/?id=e702f392959d1c2ad2089e595b52235ed97b4e18
01ff50
01ff50
Signed-off-by: Lukasz Florczak <lukasz.florczak@linux.intel.com>
01ff50
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
01ff50
---
01ff50
 Monitor.c | 12 ++++--------
01ff50
 1 file changed, 4 insertions(+), 8 deletions(-)
01ff50
01ff50
diff --git a/Monitor.c b/Monitor.c
01ff50
index b4e954c6..7d7dc4d2 100644
01ff50
--- a/Monitor.c
01ff50
+++ b/Monitor.c
01ff50
@@ -185,10 +185,8 @@ int Monitor(struct mddev_dev *devlist,
01ff50
 				continue;
01ff50
 			if (strcasecmp(mdlist->devname, "<ignore>") == 0)
01ff50
 				continue;
01ff50
-			if (!is_mddev(mdlist->devname)) {
01ff50
-				free_statelist(statelist);
01ff50
-				return 1;
01ff50
-			}
01ff50
+			if (!is_mddev(mdlist->devname))
01ff50
+				continue;
01ff50
 
01ff50
 			st = xcalloc(1, sizeof *st);
01ff50
 			snprintf(st->devname, MD_NAME_MAX + sizeof("/dev/md/"),
01ff50
@@ -208,10 +206,8 @@ int Monitor(struct mddev_dev *devlist,
01ff50
 		for (dv = devlist; dv; dv = dv->next) {
01ff50
 			struct state *st;
01ff50
 
01ff50
-			if (!is_mddev(dv->devname)) {
01ff50
-				free_statelist(statelist);
01ff50
-				return 1;
01ff50
-			}
01ff50
+			if (!is_mddev(dv->devname))
01ff50
+				continue;
01ff50
 
01ff50
 			st = xcalloc(1, sizeof *st);
01ff50
 			mdlist = conf_get_ident(dv->devname);
01ff50
-- 
01ff50
2.38.1
01ff50