linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lukasz Florczak <lukasz.florczak@linux.intel.com>
To: linux-raid@vger.kernel.org
Cc: jes@trained-monkey.org, colyli@suse.de
Subject: [PATCH] Mdmonitor: Omit non-md devices
Date: Thu, 22 Sep 2022 08:29:50 +0200	[thread overview]
Message-ID: <20220922062950.9709-1-lukasz.florczak@linux.intel.com> (raw)

Fix segfault commit [1] introduced check whether given device is
mddevice, but it happend to terminate Mdmonitor if at least one of given
devices didn't fulfill that condition. In result Mdmonitor service was
no longer started on boot (with --scan option) when config contained some
non-existent array entry.

This commit introduces ommiting non-md devices so scan option can still
be used when config is wrong and allow Mdmonitor service to run on boot.

Giving a list of devices to monitor containing non-existing or
non-md devices will result in monitoring only confirmed mddevices.

[1] https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/commit/?id=e702f392959d1c2ad2089e595b52235ed97b4e18

Signed-off-by: Lukasz Florczak <lukasz.florczak@linux.intel.com>
---
 Monitor.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/Monitor.c b/Monitor.c
index b4e954c6..7d7dc4d2 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -185,10 +185,8 @@ int Monitor(struct mddev_dev *devlist,
 				continue;
 			if (strcasecmp(mdlist->devname, "<ignore>") == 0)
 				continue;
-			if (!is_mddev(mdlist->devname)) {
-				free_statelist(statelist);
-				return 1;
-			}
+			if (!is_mddev(mdlist->devname))
+				continue;
 
 			st = xcalloc(1, sizeof *st);
 			snprintf(st->devname, MD_NAME_MAX + sizeof("/dev/md/"),
@@ -208,10 +206,8 @@ int Monitor(struct mddev_dev *devlist,
 		for (dv = devlist; dv; dv = dv->next) {
 			struct state *st;
 
-			if (!is_mddev(dv->devname)) {
-				free_statelist(statelist);
-				return 1;
-			}
+			if (!is_mddev(dv->devname))
+				continue;
 
 			st = xcalloc(1, sizeof *st);
 			mdlist = conf_get_ident(dv->devname);
-- 
2.26.2


             reply	other threads:[~2022-09-22  6:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-22  6:29 Lukasz Florczak [this message]
2022-09-29 15:12 ` [PATCH] Mdmonitor: Omit non-md devices Jes Sorensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220922062950.9709-1-lukasz.florczak@linux.intel.com \
    --to=lukasz.florczak@linux.intel.com \
    --cc=colyli@suse.de \
    --cc=jes@trained-monkey.org \
    --cc=linux-raid@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).