Skip to content

Commit

Permalink
libmultipath: trigger uevents upon map creation in domap()
Browse files Browse the repository at this point in the history
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: opensvc#103
Suggested-by: Benjamin Marzinski <[email protected]>
Signed-off-by: Martin Wilck <[email protected]>
  • Loading branch information
mwilck committed Nov 27, 2024
1 parent 27987ab commit 8e6f9e7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
11 changes: 4 additions & 7 deletions libmultipath/configure.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down
9 changes: 3 additions & 6 deletions libmultipath/devmapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}
/*
Expand All @@ -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;
}

Expand Down
1 change: 0 additions & 1 deletion libmultipath/structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8e6f9e7

Please sign in to comment.