All of lore.kernel.org
 help / color / mirror / Atom feed
From: mwilck@suse.com
To: Christophe Varoqui <christophe.varoqui@opensvc.com>,
	Benjamin Marzinski <bmarzins@redhat.com>
Cc: dm-devel@redhat.com, Martin Wilck <mwilck@suse.com>
Subject: [PATCH 75/80] multipathd: uev_trigger(): handle incomplete ADD events
Date: Thu,  9 Jul 2020 13:03:25 +0200	[thread overview]
Message-ID: <20200709110330.9917-2-mwilck@suse.com> (raw)
In-Reply-To: <20200709110330.9917-1-mwilck@suse.com>

From: Martin Wilck <mwilck@suse.com>

Udev may be killed after handling the ADD event for a multipath map,
but before handling the subsequent CHANGE event that populates the
udev data base with the device properties (e.g. during initrd processing).
If this happens, the ADD uevent sent during coldplug will only provide a
subset of the device properties. We need another CHANGE event to make the map
available to the system.

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 multipathd/main.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/multipathd/main.c b/multipathd/main.c
index 66ca4e3..29227cd 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -1508,6 +1508,31 @@ uev_trigger (struct uevent * uev, void * trigger_data)
 			uev_pathfail_check(uev, vecs);
 		} else if (!strncmp(uev->action, "remove", 6)) {
 			r = uev_remove_map(uev, vecs);
+		} else if (!strncmp(uev->action, "add", 3)) {
+			const char *ev_name;
+			char *dm_name;
+			int major = -1, minor = -1;
+
+			/*
+			 * If DM_NAME is not set for a valid map, trigger a
+			 * change event. This can happen during coldplug
+			 * if udev was killed between handling the 'add' and
+			 * 'change' events before.
+			 */
+			ev_name = uevent_get_dm_name(uev);
+			if (!ev_name) {
+				major = uevent_get_major(uev);
+				minor = uevent_get_minor(uev);
+				dm_name = dm_mapname(major, minor);
+				if (dm_name && *dm_name) {
+					condlog(2, "%s: received incomplete 'add' uevent, triggering change",
+						dm_name);
+					udev_device_set_sysattr_value(uev->udev,
+								      "uevent",
+								      "change");
+					free(dm_name);
+				}
+			}
 		}
 		goto out;
 	}
-- 
2.26.2

  reply	other threads:[~2020-07-09 11:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-09 11:03 [PATCH 00/80] multipath-tools series part VI: incomplete udev initialization mwilck
2020-07-09 11:03 ` mwilck [this message]
2020-07-09 11:03 ` [PATCH 76/80] libmultipath: select_action(): force udev reload for uninitialized maps mwilck
2020-07-20  3:44   ` Benjamin Marzinski
2020-08-05 20:54     ` Martin Wilck
2020-07-09 11:03 ` [PATCH 77/80] libmultipath: log dm_task_run() errors mwilck
2020-07-09 11:03 ` [PATCH 78/80] libmultipath: move reload_map() to multipathd mwilck
2020-07-09 11:03 ` [PATCH 79/80] multipathd: rename update_path_groups() -> reload_and_sync_map() mwilck
2020-07-09 11:03 ` [PATCH 80/80] libmultipath: select_action(): don't drop map if alias clashes mwilck
2020-07-20 21:20 ` [PATCH 00/80] multipath-tools series part VI: incomplete udev initialization Benjamin Marzinski

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=20200709110330.9917-2-mwilck@suse.com \
    --to=mwilck@suse.com \
    --cc=bmarzins@redhat.com \
    --cc=christophe.varoqui@opensvc.com \
    --cc=dm-devel@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.