From 8e6f9e723931b6be745300ef896ae18460f4492e Mon Sep 17 00:00:00 2001 From: Martin Wilck Date: Tue, 26 Nov 2024 22:37:20 +0100 Subject: [PATCH] libmultipath: trigger uevents upon map creation in domap() If map creation succeeds, previously not multipathed devices are now multipathed. udev may not have noticed this yet, thus trigger path uevents to make it aware of the situation. Likewise, if creating a map fails, the paths in question were likely considered multipath members by udev, too. They will now be marked as failed, so trigger an event in this situation as well. Fixes: https://github.com/opensvc/multipath-tools/issues/103 Suggested-by: Benjamin Marzinski Signed-off-by: Martin Wilck --- libmultipath/configure.c | 11 ++++------- libmultipath/devmapper.c | 9 +++------ libmultipath/structs.h | 1 - 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/libmultipath/configure.c b/libmultipath/configure.c index bd71e688..2b1dfd28 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -614,8 +614,6 @@ trigger_paths_udev_change(struct multipath *mpp, bool is_mpath) vector_foreach_slot(pgp->paths, pp, j) trigger_path_udev_change(pp, is_mpath); } - - mpp->needs_paths_uevent = 0; } static int sysfs_set_max_sectors_kb(struct multipath *mpp) @@ -1002,10 +1000,10 @@ int domap(struct multipath *mpp, char *params, int is_daemon) * succeeded */ mpp->force_udev_reload = 0; - if (mpp->action == ACT_CREATE && - (remember_wwid(mpp->wwid) == 1 || - mpp->needs_paths_uevent)) + if (mpp->action == ACT_CREATE) { + remember_wwid(mpp->wwid); trigger_paths_udev_change(mpp, true); + } if (!is_daemon) { /* multipath client mode */ dm_switchgroup(mpp->alias, mpp->bestpg); @@ -1030,8 +1028,7 @@ int domap(struct multipath *mpp, char *params, int is_daemon) } dm_setgeometry(mpp); return DOMAP_OK; - } else if (r == DOMAP_FAIL && mpp->action == ACT_CREATE && - mpp->needs_paths_uevent) + } else if (r == DOMAP_FAIL && mpp->action == ACT_CREATE) trigger_paths_udev_change(mpp, false); return DOMAP_FAIL; diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index d4dd9540..55052cf5 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -537,7 +537,7 @@ static uint16_t build_udev_flags(const struct multipath *mpp, int reload) MPATH_UDEV_RELOAD_FLAG : 0); } -int dm_addmap_create (struct multipath *mpp, char * params) +int dm_addmap_create (struct multipath *mpp, char *params) { int ro; uint16_t udev_flags = build_udev_flags(mpp, 0); @@ -547,9 +547,7 @@ int dm_addmap_create (struct multipath *mpp, char * params) if (dm_addmap(DM_DEVICE_CREATE, TGT_MPATH, mpp, params, ro, udev_flags)) { - if (unmark_failed_wwid(mpp->wwid) == - WWID_FAILED_CHANGED) - mpp->needs_paths_uevent = 1; + unmark_failed_wwid(mpp->wwid); return 1; } /* @@ -570,8 +568,7 @@ int dm_addmap_create (struct multipath *mpp, char * params) break; } } - if (mark_failed_wwid(mpp->wwid) == WWID_FAILED_CHANGED) - mpp->needs_paths_uevent = 1; + mark_failed_wwid(mpp->wwid); return 0; } diff --git a/libmultipath/structs.h b/libmultipath/structs.h index 2159cb36..6a30c59d 100644 --- a/libmultipath/structs.h +++ b/libmultipath/structs.h @@ -467,7 +467,6 @@ struct multipath { int max_sectors_kb; int force_readonly; int force_udev_reload; - int needs_paths_uevent; int ghost_delay; int ghost_delay_tick; int queue_mode;