fix for GitHub issue #108 and misc cleanups
Benjamin Marzinski
maintainercover fix for GitHub issue #108 and misc cleanups
This patchset has a couple of different pieces, but that main part is fixing the issue where, if a path is added while offline (for instance by doing a "multipath reconfigure" while the path is offline) It won't be able to get the SCSI device serial number (or its ALUA target port group). This meant that the GROUP_BY_SERIAL and GROUP_BY_TPG path grouping policies would not group the path correctly, even once it came back online.
Patches 1 & 2 are just a fix on top of Martin's recent device reloading work.
Patches 3, 4, & 5 are changes to need_reload. They avoid setting and checking it in cases where it won't change how multipathd behaves. The side benefit of doing this work is that it's easier to reason about what setting need_reload can and can't effect. Specifically, it will now only cause multipathd to fix incorrect device tables while in checker_finished().
Patches 6 - 11 deal with the serial and tpg_id problem from issue #108
Patch 12 is shutting up a static analyzer warning that popped up on a recent rhel build.
Patch 13 is a fix for an issue I ran into while testing this set.
Benjamin Marzinski (13):
multipathd: use symbolic values for wait_for_udev
multipathd: don't reload the map when waiting for udev
libmultipath: don't set need_reload in adopt_paths
libmultipath: remove need_reload check from select_action
libmultipath: drop return value from update_pathvec_from_dm
libmultipath: Dont scan pointless sysfs parents
libmultipath: move sysfs checks out of scsi_ioctl_pathinfo
libmultipath: rename DI_SERIAL to DI_IOCTL
libmultipath: retry DI_IOCTL functions if they were skipped
libmultipath: set need_reload when pp->serial gets set
libmultipath: set need_reload when the tpg_id gets set
libmultipath: stop static analyzer complaint in init_foreign
libmultipath: be lenient in allowing the alua-based pgpolicies
libmultipath/configure.c | 4 +- libmultipath/devmapper.c | 22 +++++--- libmultipath/discovery.c | 104 ++++++++++++++++--------------------- libmultipath/discovery.h | 7 ++- libmultipath/foreign.c | 2 +- libmultipath/propsel.c | 6 ++- libmultipath/structs.h | 15 +++++- libmultipath/structs_vec.c | 10 ++-- multipath/main.c | 2 +- multipathd/cli_handlers.c | 16 +++--- multipathd/main.c | 40 +++++++------- tests/test-lib.c | 9 +--- 12 files changed, 119 insertions(+), 118 deletions(-)
Signature · 1 line
2.46.2
Benjamin Marzinski
maintainerPATCH 1/13 multipathd: use symbolic values for wait_for_udev
--- libmultipath/configure.c | 2 +- libmultipath/structs.h | 8 +++++++- multipathd/cli_handlers.c | 16 ++++++++-------- multipathd/main.c | 35 ++++++++++++++++++----------------- 4 files changed, 34 insertions(+), 27 deletions(-)
libmultipath/configure.c +1 -1
@@ -1018,7 +1018,7 @@ int domap(struct multipath *mpp, char *params, int is_daemon) mpp->action =ACT_NOTHING ; else { conf =get_multipath_config (); - mpp->wait_for_udev =1 ; + mpp->wait_for_udev =UDEV_WAIT_STARTED ; mpp->uev_wait_tick = conf->uev_wait_timeout;put_multipath_config (conf); }
libmultipath/structs.h +7 -1
@@ -430,6 +430,12 @@ enum prio_update_type { PRIO_UPDATE_MARGINAL, }; +enum udev_wait_states { +UDEV_WAIT_DONE =0 , +UDEV_WAIT_STARTED , +UDEV_WAIT_RELOAD , +}; +struct multipath {char wwid[WWID_SIZE ];char alias_old[WWID_SIZE ];
@@ -441,7 +447,7 @@ struct multipath {int bestpg;int queuedio;int action; -int wait_for_udev; +enum udev_wait_states wait_for_udev;int uev_wait_tick;int pgfailback;int failback_tick;
multipathd/cli_handlers.c +8 -8
@@ -812,7 +812,7 @@ cli_reload(void *v, struct strbuf *reply, void *data)if (!mpp)return -ENODEV ; -if (mpp->wait_for_udev) { +if (mpp->wait_for_udev !=UDEV_WAIT_DONE ) {condlog (2 ,"%s: device not fully created, failing reload" , mpp->alias);return 1 ;
@@ -841,7 +841,7 @@ cli_resize(void *v, struct strbuf *reply, void *data)if (!mpp)return -ENODEV ; -if (mpp->wait_for_udev) { +if (mpp->wait_for_udev !=UDEV_WAIT_DONE ) {condlog (2 ,"%s: device not fully created, failing resize" , mpp->alias);return 1 ;
@@ -1046,7 +1046,7 @@ cli_suspend(void * v, struct strbuf *reply, void * data)if (!mpp)return 1 ; -if (mpp->wait_for_udev) { +if (mpp->wait_for_udev !=UDEV_WAIT_DONE ) {condlog (2 ,"%s: device not fully created, failing suspend" , mpp->alias);return 1 ;
@@ -1078,7 +1078,7 @@ cli_resume(void * v, struct strbuf *reply, void * data)return 1 ; udev_flags = (mpp->skip_kpartx)?MPATH_UDEV_NO_KPARTX_FLAG :0 ; -if (mpp->wait_for_udev) { +if (mpp->wait_for_udev !=UDEV_WAIT_DONE ) {condlog (2 ,"%s: device not fully created, failing resume" , mpp->alias);return 1 ;
@@ -1131,7 +1131,7 @@ cli_reassign (void * v, struct strbuf *reply, void * data)if (!mpp)return 1 ; -if (mpp->wait_for_udev) { +if (mpp->wait_for_udev !=UDEV_WAIT_DONE ) {condlog (2 ,"%s: device not fully created, failing reassign" , mpp->alias);return 1 ;
@@ -1406,7 +1406,7 @@ static int cli_set_marginal(void * v, struct strbuf *reply, void * data)condlog (2 ,"%s: set marginal path %s (operator)" , pp->mpp->alias, pp->dev_t); -if (pp->mpp->wait_for_udev) { +if (pp->mpp->wait_for_udev !=UDEV_WAIT_DONE ) {condlog (2 ,"%s: device not fully created, failing set marginal" , pp->mpp->alias);return 1 ;
@@ -1433,7 +1433,7 @@ static int cli_unset_marginal(void * v, struct strbuf *reply, void * data)condlog (2 ,"%s: unset marginal path %s (operator)" , pp->mpp->alias, pp->dev_t); -if (pp->mpp->wait_for_udev) { +if (pp->mpp->wait_for_udev !=UDEV_WAIT_DONE ) {condlog (2 ,"%s: device not fully created, " "failing unset marginal" , pp->mpp->alias);return 1 ;
@@ -1461,7 +1461,7 @@ static int cli_unset_all_marginal(void * v, struct strbuf *reply, void * data)if (!mpp)return -ENODEV ; -if (mpp->wait_for_udev) { +if (mpp->wait_for_udev !=UDEV_WAIT_DONE ) {condlog (2 ,"%s: device not fully created, " "failing unset all marginal" , mpp->alias);return 1 ;
multipathd/main.c +18 -17
@@ -331,7 +331,7 @@ static bool unblock_reconfigure(void)*/ void remove_map_callback (struct multipath *mpp) { -if (mpp->wait_for_udev >0 ) +if (mpp->wait_for_udev !=UDEV_WAIT_DONE )unblock_reconfigure (); }
@@ -871,7 +871,7 @@ ev_add_map (char * dev, const char * alias, struct vectors * vecs) mpp =find_mp_by_alias (vecs->mpvec, alias);if (mpp) { -if (mpp->wait_for_udev >1 ) { +if (mpp->wait_for_udev ==UDEV_WAIT_RELOAD ) {condlog (2 ,"%s: performing delayed actions" , mpp->alias);if (update_map (mpp, vecs,0 ))
@@ -882,8 +882,8 @@ ev_add_map (char * dev, const char * alias, struct vectors * vecs) reassign_maps = conf->reassign_maps;put_multipath_config (conf);dm_get_info (mpp->alias, &mpp->dmi); -if (mpp->wait_for_udev) { - mpp->wait_for_udev =0 ; +if (mpp->wait_for_udev !=UDEV_WAIT_DONE ) { + mpp->wait_for_udev =UDEV_WAIT_DONE ;if (!need_to_delay_reconfig (vecs) &&unblock_reconfigure ())return 0 ;
@@ -1241,7 +1241,7 @@ ev_add_path (struct path * pp, struct vectors * vecs, int need_do_map) }if (mpp)trigger_path_udev_change (pp, true); - if (mpp && mpp->wait_for_udev && + if (mpp && mpp->wait_for_udev != UDEV_WAIT_DONE && (pathcount(mpp, PATH_UP) > 0 || (pathcount(mpp, PATH_GHOST) > 0 && path_get_tpgs(pp) != TPGS_IMPLICIT &&
@@ -1249,7 +1249,7 @@ ev_add_path (struct path * pp, struct vectors * vecs, int need_do_map)/* if wait_for_udev is set and valid paths exist */ condlog (3 ,"%s: delaying path addition until %s is fully initialized" , pp->dev, mpp->alias); - mpp->wait_for_udev =2 ; + mpp->wait_for_udev =UDEV_WAIT_RELOAD ;orphan_path (pp,"waiting for create to complete" );return 0 ; }
@@ -1433,8 +1433,8 @@ ev_remove_path (struct path *pp, struct vectors * vecs, int need_do_map) flush_map_nopaths(mpp, vecs)) goto out; -if (mpp->wait_for_udev) { - mpp->wait_for_udev =2 ; +if (mpp->wait_for_udev !=UDEV_WAIT_DONE ) { + mpp->wait_for_udev =UDEV_WAIT_RELOAD ; retval =REMOVE_PATH_DELAY ; goto out; }
@@ -1646,8 +1646,8 @@ uev_update_path (struct uevent *uev, struct vectors * vecs)if (needs_ro_update (mpp, ro)) {condlog (2 ,"%s: update path write_protect to '%d' (uevent)" , uev->kernel, ro); -if (mpp->wait_for_udev) - mpp->wait_for_udev =2 ; +if (mpp->wait_for_udev !=UDEV_WAIT_DONE ) + mpp->wait_for_udev =UDEV_WAIT_RELOAD ;else {if (ro ==1 ) pp->mpp->force_readonly =1 ;
@@ -1661,7 +1661,7 @@ uev_update_path (struct uevent *uev, struct vectors * vecs) } }if (auto_resize !=AUTO_RESIZE_NEVER && mpp && - !mpp->wait_for_udev) { + mpp->wait_for_udev ==UDEV_WAIT_DONE ) {struct pathgroup *pgp;struct path *pp2;unsigned int i, j;
@@ -2018,13 +2018,13 @@ followover_should_failback(struct multipath *mpp)static bool missing_uev_wait_tick (struct multipath *mpp,bool *timed_out) { -if (mpp->wait_for_udev && --mpp->uev_wait_tick <=0 ) { -int wait = mpp->wait_for_udev; +if (mpp->wait_for_udev !=UDEV_WAIT_DONE && --mpp->uev_wait_tick <=0 ) { +enum udev_wait_states wait = mpp->wait_for_udev; - mpp->wait_for_udev =0 ; + mpp->wait_for_udev =UDEV_WAIT_DONE ; *timed_out = true;condlog (0 ,"%s: timeout waiting on creation uevent. enabling reloads" , mpp->alias); -return wait >1 ; +return wait ==UDEV_WAIT_RELOAD ; }return false; }
@@ -2635,7 +2635,8 @@ static bool update_mpp_prio(struct multipath *mpp)enum prio_update_type prio_update = mpp->prio_update; mpp->prio_update =PRIO_UPDATE_NONE ; -if (mpp->wait_for_udev || prio_update ==PRIO_UPDATE_NONE ) +if (mpp->wait_for_udev !=UDEV_WAIT_DONE || + prio_update ==PRIO_UPDATE_NONE )return false;condlog (4 ,"prio refresh" );
@@ -3246,7 +3247,7 @@ need_to_delay_reconfig(struct vectors * vecs)return 0 ; vector_foreach_slot(vecs->mpvec, mpp, i) { -if (mpp->wait_for_udev) +if (mpp->wait_for_udev !=UDEV_WAIT_DONE )return 1 ; }return 0 ;
Signature · 1 line
2.46.2
Benjamin Marzinski
maintainerPATCH 2/13 multipathd: don't reload the map when waiting for udev
In reply to Benjamin MarzinskiIn checker_finished(), if we are still waiting for the initial uevent, we should instead set wait_for_udev to UDEV_WAIT_RELOAD, so that we trigger a reload when we get the uevent.
--- multipathd/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
multipathd/main.c +4 -1
@@ -2978,7 +2978,10 @@ static void checker_finished(struct vectors *vecs, unsigned int ticks)continue ; } }else if (prio_reload || failback_reload || ghost_reload || inconsistent) { -if (reload_and_sync_map (mpp, vecs) ==2 ) { +if (mpp->wait_for_udev !=UDEV_WAIT_DONE ) { + mpp->need_reload = false; + mpp->wait_for_udev =UDEV_WAIT_RELOAD ; + }else if (reload_and_sync_map (mpp, vecs) ==2 ) {/* multipath device deleted */ i--;continue ;
Signature · 1 line
2.46.2
Benjamin Marzinski
maintainerPATCH 3/13 libmultipath: don't set need_reload in adopt_paths
In reply to Benjamin Marzinskiadopt_paths() is generally called when you are planning on creating or reloading a multipath device. The only time when adopt_paths() is called and mpp->action isn't explicitly set to ACT_CREATE or ACT_RELOAD afterwards is when it is called by coalesce_paths() -> add_map_with_path(). But in this case, you will only set need_reload if the path that is being adopted isn't already part of the device. Because of that, the new device that's being assembled in coalesce_paths() must be different from the existing device (it has a path that isn't in the existing device), so select_action() will select ACT_RELOAD, regardless of the need_reload state. This makes intuitive sense. When multipath adopts a new path, it should reload the device to actually add that path to the device.
--- libmultipath/structs_vec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libmultipath/structs_vec.c +1 -1
@@ -349,7 +349,7 @@ int adopt_paths(vector pathvec, struct multipath *mpp,*/ if (!current_mpp || !mp_find_path_by_devt (current_mpp, pp->dev_t)) - mpp->need_reload =set_path_max_sectors_kb (pp, mpp->max_sectors_kb) || mpp->need_reload; +set_path_max_sectors_kb (pp, mpp->max_sectors_kb); } pp->mpp = mpp;
Signature · 1 line
2.46.2
Benjamin Marzinski
maintainerPATCH 4/13 libmultipath: remove need_reload check from select_action
In reply to Benjamin Marzinskiselect_action() is only called by coalesce_paths() to determine what action to take. The only function that sets mpp->need_reload is update_pathvec_from_dm() and it only sets need_reload if there is a problem with the current device layout. If coalesce_paths() generates the same device layout for the new device, then forcing a reload will not make any difference, since nothing will change. If it generates a different device layout, then it will reload the device regardless of the need_reload value.
--- libmultipath/configure.c | 2 -- 1 file changed, 2 deletions(-)
libmultipath/configure.c +0 -2
@@ -686,8 +686,6 @@ void select_action (struct multipath *mpp, const struct vector_s *curmp, mpp->action =ACT_NOTHING ; cmpp =find_mp_by_wwid (curmp, mpp->wwid); cmpp_by_name =find_mp_by_alias (curmp, mpp->alias); -if (mpp->need_reload || (cmpp && cmpp->need_reload)) - force_reload =1 ;if (!cmpp) {if (cmpp_by_name) {
Signature · 1 line
2.46.2
Benjamin Marzinski
maintainerPATCH 5/13 libmultipath: drop return value from update_pathvec_from_dm
In reply to Benjamin MarzinskiWe finally came up with a solution for handling mpp->need_reload, and it doesn't involve checking the return value of update_pathvec_from_dm(), so drop it.
--- libmultipath/structs_vec.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
libmultipath/structs_vec.c +2 -6
@@ -92,14 +92,12 @@ static bool guess_mpp_wwid(struct multipath *mpp)* multipath maps but haven't been discovered. Check whether they * need to be added to pathvec or discarded. * -* Returns: true if immediate map reload is desirable -* * Side effects: * - may delete non-existing paths and empty pathgroups from mpp * - may set pp->wwid and / or mpp->wwid * - calls pathinfo() on existing paths is pathinfo_flags is not 0 */ -static bool update_pathvec_from_dm (vector pathvec,struct multipath *mpp, +static void update_pathvec_from_dm (vector pathvec,struct multipath *mpp,int pathinfo_flags) {int i, j;
@@ -111,7 +109,7 @@ static bool update_pathvec_from_dm(vector pathvec, struct multipath *mpp,bool pg_deleted = false;if (!mpp->pg) -return false; +return ;/* * This will initialize mpp->wwid with an educated guess,
@@ -253,7 +251,6 @@ static bool update_pathvec_from_dm(vector pathvec, struct multipath *mpp, pg_deleted = true; } mpp->need_reload = mpp->need_reload || must_reload; -return must_reload; }static bool set_path_max_sectors_kb (const struct path *pp,int max_sectors_kb)
@@ -505,7 +502,6 @@ update_multipath_table__ (struct multipath *mpp, vector pathvec, int flags,if (disassemble_status (status, mpp))condlog (2 ,"%s: cannot disassemble status" , mpp->alias); -/* FIXME: we should deal with the return value here */ update_pathvec_from_dm (pathvec, mpp, flags);return DMP_OK ;
Signature · 1 line
2.46.2
Benjamin Marzinski
maintainerPATCH 6/13 libmultipath: Dont scan pointless sysfs parents
In reply to Benjamin MarzinskiIn scsi_sysfs_pathinfo() we should just look for the parent that we want, instead of checking all the parents.
--- libmultipath/discovery.c | 27 ++++++++++----------------- tests/test-lib.c | 1 - 2 files changed, 10 insertions(+), 18 deletions(-)
libmultipath/discovery.c +10 -17
@@ -1527,23 +1527,16 @@ scsi_sysfs_pathinfo (struct path *pp, const struct vector_s *hwtable)const char *attr_path =NULL ;static const char unknown[] ="UNKNOWN" ; - parent = pp->udev; -while (parent) { -const char *subsys =udev_device_get_subsystem (parent); -if (subsys && !strncmp (subsys,"scsi" ,4 )) { - attr_path =udev_device_get_sysname (parent); -if (!attr_path) -break ; -if (sscanf (attr_path,"%i:%i:%i:%" SCNu64, - &pp->sg_id.host_no, - &pp->sg_id.channel, - &pp->sg_id.scsi_id, - &pp->sg_id.lun) ==4 ) -break ; - } - parent =udev_device_get_parent (parent); - } -if (!attr_path || pp->sg_id.host_no ==-1 ) + parent =udev_device_get_parent_with_subsystem_devtype (pp->udev,"scsi" , +"scsi_device" ); +if (!parent) +return PATHINFO_FAILED ; + attr_path =udev_device_get_sysname (parent); +if (!attr_path) +return PATHINFO_FAILED ; +if (sscanf (attr_path,"%i:%i:%i:%" SCNu64, + &pp->sg_id.host_no, + &pp->sg_id.channel, &pp->sg_id.scsi_id, &pp->sg_id.lun) !=4 )return PATHINFO_FAILED ;if (sysfs_get_vendor (parent, pp->vendor_id,SCSI_VENDOR_SIZE ) <=0 ) {
tests/test-lib.c +0 -1
@@ -282,7 +282,6 @@ struct mocked_path *mocked_path_from_path(struct mocked_path *mp,static const char hbtl[] ="4:0:3:1" ;static void mock_sysfs_pathinfo (const struct mocked_path *mp) { -will_return (__wrap_udev_device_get_subsystem,"scsi" );will_return (__wrap_udev_device_get_sysname, hbtl);will_return (__wrap_udev_device_get_sysname, hbtl);will_return (__wrap_udev_device_get_sysattr_value, mp->vendor);
Signature · 1 line
2.46.2
Benjamin Marzinski
maintainerPATCH 7/13 libmultipath: move sysfs checks out of scsi_ioctl_pathinfo
In reply to Benjamin MarzinskiThere are multiple checks in scsi_ioctl_pathinfo() that only use sysfs. pathinfo() is never called with DI_SERIAL and not DI_SYSFS, so it's safe to move them to scsi_sysfs_pathinfo(). The HCTL checking code is already there, so remove the duplicate, and split the sysfs serial checking from the ioctl serial checking.
--- libmultipath/discovery.c | 36 ++++++++---------------------------- tests/test-lib.c | 6 ------ 2 files changed, 8 insertions(+), 34 deletions(-)
libmultipath/discovery.c +8 -28
@@ -1581,6 +1581,9 @@ scsi_sysfs_pathinfo (struct path *pp, const struct vector_s *hwtable)condlog (3 ,"%s: tgt_node_name = %s" , pp->dev, pp->tgt_node_name); +if (get_vpd_sysfs (parent,0x80 , pp->serial,SERIAL_SIZE ) >0 ) +condlog (3 ,"%s: serial = %s (sysfs)" , pp->dev, pp->serial); +return PATHINFO_OK ; }
@@ -1907,8 +1910,6 @@ sysfs_pathinfo(struct path *pp, const struct vector_s *hwtable)static void scsi_ioctl_pathinfo (struct path * pp,int mask) { -struct udev_device *parent; -const char *attr_path =NULL ;int vpd_id;if (!(mask &DI_SERIAL ))
@@ -1933,34 +1934,13 @@ scsi_ioctl_pathinfo (struct path * pp, int mask) } } - parent = pp->udev; -while (parent) { -const char *subsys =udev_device_get_subsystem (parent); -if (subsys && !strncmp (subsys,"scsi" ,4 )) { - attr_path =udev_device_get_sysname (parent); -if (!attr_path) -break ; -if (sscanf (attr_path,"%i:%i:%i:%" SCNu64, - &pp->sg_id.host_no, - &pp->sg_id.channel, - &pp->sg_id.scsi_id, - &pp->sg_id.lun) ==4 ) -break ; - } - parent =udev_device_get_parent (parent); - } -if (!attr_path || pp->sg_id.host_no ==-1 ) -return ; - -if (get_vpd_sysfs (parent,0x80 , pp->serial,SERIAL_SIZE ) <=0 ) { -if (get_serial (pp->serial,SERIAL_SIZE , pp->fd)) { +if (pp->serial[0 ] =='\0' ) { +if (get_serial (pp->serial,SERIAL_SIZE , pp->fd))condlog (3 ,"%s: fail to get serial" , pp->dev); -return ; - } +else +condlog (3 ,"%s: serial = %s (ioctl)" , pp->dev, + pp->serial); } - -condlog (3 ,"%s: serial = %s" , pp->dev, pp->serial); -return ; } static void
tests/test-lib.c +0 -6
@@ -339,12 +339,6 @@ void mock_pathinfo(int mask, const struct mocked_path *mp)if (mp->flags &NEED_FD )will_return (__wrap_udev_device_get_devnode, _mocked_filename); -/* scsi_ioctl_pathinfo() */ -if (mask &DI_SERIAL ) { -will_return (__wrap_udev_device_get_subsystem,"scsi" ); -will_return (__wrap_udev_device_get_sysname, hbtl); - } -if (mask &DI_WWID ) {/* get_udev_uid() */ will_return(__wrap_udev_device_get_property_value,
Signature · 1 line
2.46.2
Benjamin Marzinski
maintainerPATCH 8/13 libmultipath: rename DI_SERIAL to DI_IOCTL
In reply to Benjamin MarzinskiDI_IOCTL is a much more sensible name for what this flag controls. All the pathinfo functions that run for DI_SERIAL use ioctls. They don't just get the serial info, and the serial info can also be gotten by functions run for DI_SYSFS.
--- libmultipath/discovery.c | 6 +++--- libmultipath/discovery.h | 7 +++---- multipath/main.c | 2 +- tests/test-lib.c | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-)
libmultipath/discovery.c +3 -3
@@ -1912,7 +1912,7 @@ scsi_ioctl_pathinfo (struct path * pp, int mask) {int vpd_id; -if (!(mask &DI_SERIAL )) +if (!(mask &DI_IOCTL ))return ;select_vpd_vendor_id (pp);
@@ -2433,13 +2433,13 @@ int pathinfo(struct path *pp, struct config *conf, int mask) goto blank; } -if (mask &DI_SERIAL ) +if (mask &DI_IOCTL )get_geometry (pp);if (path_state ==PATH_UP && pp->bus ==SYSFS_BUS_SCSI )scsi_ioctl_pathinfo (pp, mask); -if (pp->bus ==SYSFS_BUS_CCISS && mask &DI_SERIAL ) +if (pp->bus ==SYSFS_BUS_CCISS && mask &DI_IOCTL )cciss_ioctl_pathinfo (pp);if (mask &DI_CHECKER ) {
libmultipath/discovery.h +3 -4
@@ -67,7 +67,7 @@ void cleanup_udev_device_ptr(void *arg);*/ enum discovery_mode {DI_SYSFS__ , -DI_SERIAL__ , +DI_IOCTL__ ,DI_CHECKER__ ,DI_PRIO__ ,DI_WWID__ ,
@@ -77,7 +77,7 @@ enum discovery_mode { };#define DI_SYSFS (1 << DI_SYSFS__) -#define DI_SERIAL (1 << DI_SERIAL__) +#define DI_IOCTL (1 << DI_IOCTL__)#define DI_CHECKER (1 << DI_CHECKER__)#define DI_PRIO (1 << DI_PRIO__)#define DI_WWID (1 << DI_WWID__)
@@ -85,7 +85,6 @@ enum discovery_mode {#define DI_NOIO (1 << DI_NOIO__)/* Avoid IO on the device */ #define DI_NOFALLBACK (1 << DI_NOFALLBACK__)/* do not allow wwid fallback */ -#define DI_ALL (DI_SYSFS | DI_SERIAL | DI_CHECKER | DI_PRIO | \ - DI_WWID) +#define DI_ALL (DI_SYSFS | DI_IOCTL | DI_CHECKER | DI_PRIO | DI_WWID)#endif /* DISCOVERY_H_INCLUDED */
multipath/main.c +1 -1
@@ -533,7 +533,7 @@ configure (struct config *conf, enum mpath_cmds cmd,if (cmd ==CMD_LIST_LONG )/* extended path info '-ll' */ - di_flag |=DI_SYSFS |DI_CHECKER |DI_SERIAL ; + di_flag |=DI_SYSFS |DI_CHECKER |DI_IOCTL ;else if (cmd ==CMD_LIST_SHORT )/* minimum path info '-l' */ di_flag |=DI_SYSFS ;
tests/test-lib.c +1 -1
@@ -18,7 +18,7 @@#include "test-lib.h" #include "wrap64.h" -const int default_mask = (DI_SYSFS |DI_BLACKLIST |DI_WWID |DI_CHECKER |DI_PRIO |DI_SERIAL ); +const int default_mask = (DI_SYSFS |DI_BLACKLIST |DI_WWID |DI_CHECKER |DI_PRIO |DI_IOCTL );const char default_devnode[] ="sdxTEST" ;const char default_wwid[] ="TEST-WWID" ;/* default_wwid should be a substring of default_wwid_1! */
Signature · 1 line
2.46.2
Benjamin Marzinski
maintainerPATCH 9/13 libmultipath: retry DI_IOCTL functions if they were skipped
In reply to Benjamin Marzinskipathinfo() shouldn't call any of the DI_IOCTL functions if path_state is not PATH_UP (It only actually checked this for scsi_ioctl_pathinfo). But since pathinfo() is rarely called with the DI_IOCTL flag, this information might never be gathered if a path is added, and pathinfo is first called, while it's offline. Make paths remember if they skipped the DI_IOCTL calls because the path was offline, and try again on future pathinfo() calls that don't set DI_NOIO.
Also make dm_setgeometry check all paths, since it's possible that set_geometry() was skipped (in the past, the ioctls would just fail for the offline device, with the same result).
--- libmultipath/devmapper.c | 22 ++++++++++++++-------- libmultipath/discovery.c | 24 ++++++++++++------------ libmultipath/structs.h | 7 +++++++ 3 files changed, 33 insertions(+), 20 deletions(-)
libmultipath/devmapper.c +14 -8
@@ -1704,7 +1704,10 @@ int dm_reassign(const char *mapname)int dm_setgeometry (struct multipath *mpp) {struct dm_task __attribute__((cleanup (cleanup_dm_task))) *dmt =NULL ; +struct pathgroup *pgp;struct path *pp; +int i, j; +bool found = false;char heads[4 ], sectors[4 ];char cylinders[10 ], start[32 ];int r =0 ;
@@ -1712,15 +1715,18 @@ int dm_setgeometry(struct multipath *mpp)if (!mpp)return 1 ; - pp =first_path (mpp); -if (!pp) { -condlog (3 ,"%s: no path for geometry" , mpp->alias); -return 1 ; + vector_foreach_slot (mpp->pg, pgp, i) { + vector_foreach_slot (pgp->paths, pp, j) { +if (pp->geom.cylinders !=0 && + pp->geom.heads !=0 && + pp->geom.sectors !=0 ) { + found = true; +break ; + } + } } -if (pp->geom.cylinders ==0 || - pp->geom.heads ==0 || - pp->geom.sectors ==0 ) { -condlog (3 ,"%s: invalid geometry on %s" , mpp->alias, pp->dev); +if (!found) { +condlog (3 ,"%s: no path with valid geometry" , mpp->alias);return 1 ; }
libmultipath/discovery.c +12 -12
@@ -1908,13 +1908,10 @@ sysfs_pathinfo(struct path *pp, const struct vector_s *hwtable) }static void -scsi_ioctl_pathinfo (struct path * pp,int mask) +scsi_ioctl_pathinfo (struct path * pp) {int vpd_id; -if (!(mask &DI_IOCTL )) -return ; -select_vpd_vendor_id (pp); vpd_id = pp->vpd_vendor_id;
@@ -2433,14 +2430,17 @@ int pathinfo(struct path *pp, struct config *conf, int mask) goto blank; } -if (mask &DI_IOCTL ) -get_geometry (pp); - -if (path_state ==PATH_UP && pp->bus ==SYSFS_BUS_SCSI ) -scsi_ioctl_pathinfo (pp, mask); - -if (pp->bus ==SYSFS_BUS_CCISS && mask &DI_IOCTL ) -cciss_ioctl_pathinfo (pp); +if (mask &DI_IOCTL || pp->ioctl_info ==IOCTL_INFO_SKIPPED ) { +if (path_state ==PATH_UP ) { +get_geometry (pp); +if (pp->bus ==SYSFS_BUS_SCSI ) +scsi_ioctl_pathinfo (pp); +else if (pp->bus ==SYSFS_BUS_CCISS ) +cciss_ioctl_pathinfo (pp); + pp->ioctl_info =IOCTL_INFO_COMPLETED ; + }else if (pp->ioctl_info ==IOCTL_INFO_NOT_REQUESTED ) + pp->ioctl_info =IOCTL_INFO_SKIPPED ; + }if (mask &DI_CHECKER ) {if (path_state ==PATH_UP ) {
libmultipath/structs.h +7 -0
@@ -353,6 +353,12 @@ struct hd_geometry {#define GROUP_ID_UNDEF -1 +enum ioctl_info_states { +IOCTL_INFO_NOT_REQUESTED =0 , +IOCTL_INFO_SKIPPED , +IOCTL_INFO_COMPLETED , +}; +struct path {char dev[FILE_NAME_SIZE ];char dev_t[BLK_DEV_SIZE ];
@@ -412,6 +418,7 @@ struct path {vector hwe;struct gen_path generic_path;int tpg_id; +enum ioctl_info_states ioctl_info; };typedef int (pgpolicyfn ) (struct multipath *,vector );
Signature · 1 line
2.46.2
Benjamin Marzinski
maintainerPATCH 10/13 libmultipath: set need_reload when pp->serial gets set
In reply to Benjamin MarzinskiIf a multipath device has a path grouping policy of "group_by_serial" and pp->serial wasn't previously set, set need_reload. If the multipath device hasn't been created yet, need_reload will get cleared when the device is created. If the multipath device already exists, the path likely wasn't in the correct pathgroup, since it was unable to set pp->serial before the paths were grouped.
--- libmultipath/discovery.c | 9 +++++++++ 1 file changed, 9 insertions(+)
libmultipath/discovery.c +9 -0
@@ -2317,6 +2317,7 @@ get_uid (struct path * pp, int path_state, struct udev_device *udev,int pathinfo (struct path *pp,struct config *conf,int mask) {int path_state; +bool need_serial_recheck = false;if (!pp || !conf)return PATHINFO_FAILED ;
@@ -2357,6 +2358,10 @@ int pathinfo(struct path *pp, struct config *conf, int mask) pp->dev) > 0)return PATHINFO_SKIPPED ; +if (pp->mpp && pp->mpp->pgpolicyfn == (pgpolicyfn *)group_by_serial && + pp->serial[0 ] =='\0' ) + need_serial_recheck = true; +condlog (4 ,"%s: mask = 0x%x" , pp->dev, mask);/*
@@ -2415,6 +2420,8 @@ int pathinfo(struct path *pp, struct config *conf, int mask) pp->state ==PATH_UNCHECKED || pp->state == PATH_WILD) pp->chkrstate = pp->state = path_state; +if (need_serial_recheck && pp->serial[0 ] !='\0' ) + pp->mpp->need_reload = true;return PATHINFO_OK ; }
@@ -2524,6 +2531,8 @@ int pathinfo(struct path *pp, struct config *conf, int mask)if ((mask &DI_ALL ) ==DI_ALL ) pp->initialized =INIT_OK ; +if (need_serial_recheck && pp->serial[0 ] !='\0' ) + pp->mpp->need_reload = true;return PATHINFO_OK ; blank:
Signature · 1 line
2.46.2
Benjamin Marzinski
maintainerPATCH 11/13 libmultipath: set need_reload when the tpg_id gets set
In reply to Benjamin MarzinskiIf a multipath device has a path grouping policy of "group_by_tpg" and pp->tpg_id wasn't previously set, set need_reload. If the multipath device hasn't been created yet, need_reload will get cleared when the device is created. If the multipath device already exists, the path likely wasn't in the correct pathgroup, since it was unable to set pp->tpg_id before the paths were grouped.
--- libmultipath/discovery.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
libmultipath/discovery.c +7 -1
@@ -34,6 +34,7 @@#include "configure.h" #include "print.h" #include "strbuf.h" +#include "pgpolicies.h" #define VPD_BUFLEN 4096
@@ -1097,8 +1098,13 @@ detect_alua(struct path * pp)int path_get_tpgs (struct path *pp) { -if (pp->tpgs ==TPGS_UNDEF ) +if (pp->tpgs ==TPGS_UNDEF ) {detect_alua (pp); +if (pp->tpgs !=TPGS_UNDEF && pp->tpg_id !=GROUP_ID_UNDEF && + pp->mpp && + pp->mpp->pgpolicyfn == (pgpolicyfn *)group_by_tpg) + pp->mpp->need_reload = true; + }return pp->tpgs; }
Signature · 1 line
2.46.2
Benjamin Marzinski
maintainerPATCH 12/13 libmultipath: stop static analyzer complaint in init_foreign
In reply to Benjamin MarzinskiThis change doesn't actually fix anything. The code was already safe.
--- libmultipath/foreign.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libmultipath/foreign.c +1 -1
@@ -129,7 +129,7 @@ static void free_pre(void *arg)static int _init_foreign (const char *enable) {char pathbuf[PATH_MAX ]; -struct dirent **di; +struct dirent **di =NULL ;struct scandir_result sr;int r, i;regex_t *enable_re =NULL ;
Signature · 1 line
2.46.2
Benjamin Marzinski
maintainerPATCH 13/13 libmultipath: be lenient in allowing the alua-based pgpolicies
In reply to Benjamin Marzinskimultipath wouldn't autodetect the GROUP_BY_PRIO path grouping policy or allow the GROUP_BY_TPG policy if there was a path that didn't have its prioritizer selected (for instance because multipathd was reconfigured while it was offline). To avoid this, make verify_alua_prio() assume an alua multipath device if all the paths with a prioritizer selected (there must be at least one) use an alua-based prioritizer.
--- libmultipath/propsel.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
libmultipath/propsel.c +5 -1
@@ -255,14 +255,18 @@ verify_alua_prio(struct multipath *mp) {int i;struct path *pp; +bool assume_alua = false; vector_foreach_slot(mp->paths, pp, i) {const char *name =prio_name (&pp->prio); +if (!prio_selected (&pp->prio)) +continue ;if (strncmp (name,PRIO_ALUA ,PRIO_NAME_LEN ) &&strncmp (name,PRIO_SYSFS ,PRIO_NAME_LEN ))return false; + assume_alua = true; } -return true; +return assume_alua; }int select_detect_pgpolicy (struct config *conf,struct multipath *mp)
Signature · 1 line
2.46.2
Quoted 54 lines · Benjamin Marzinski
This patchset has a couple of different pieces, but that main part is fixing the issue where, if a path is added while offline (for instance by doing a "multipath reconfigure" while the path is offline)
It won't be able to get the SCSI device serial number (or its ALUA target port group). This meant that theGROUP_BY_SERIALandGROUP_BY_TPGpath grouping policies would not group the path correctly,
even once it came back online.Patches 1 & 2 are just a fix on top of Martin's recent device reloading
work.Patches 3, 4, & 5 are changes to
need_reload. They avoid setting and checking it in cases where it won't change how multipathd behaves. The side benefit of doing this work is that it's easier to reason about
what settingneed_reloadcan and can't effect. Specifically, it will now
only cause multipathd to fix incorrect device tables while inchecker_finished().Patches 6 - 11 deal with the serial and
tpg_idproblem from issue #108Patch 12 is shutting up a static analyzer warning that popped up on a recent rhel build.
Patch 13 is a fix for an issue I ran into while testing this set.
Benjamin Marzinski (13):
multipathd: use symbolic values forwait_for_udev
multipathd: don't reload the map when waiting for udev
libmultipath: don't setneed_reloadinadopt_paths
libmultipath: removeneed_reloadcheck fromselect_action
libmultipath: drop return value fromupdate_pathvec_from_dm
libmultipath: Dont scan pointless sysfs parents
libmultipath: move sysfs checks out ofscsi_ioctl_pathinfo
libmultipath: renameDI_SERIALtoDI_IOCTL
libmultipath: retryDI_IOCTLfunctions if they were skipped
libmultipath: setneed_reloadwhenpp->serialgets set
libmultipath: setneed_reloadwhen thetpg_idgets set
libmultipath: stop static analyzer complaint ininit_foreign
libmultipath: be lenient in allowing the alua-based pgpolicieslibmultipath/configure.c | 4 +- libmultipath/devmapper.c | 22 +++++--- libmultipath/discovery.c | 104 ++++++++++++++++------------------- -- libmultipath/discovery.h | 7 ++- libmultipath/foreign.c | 2 +- libmultipath/propsel.c | 6 ++- libmultipath/structs.h | 15 +++++-
Quoted 7 lines
libmultipath/structs_vec.c | 10 ++--
multipath/main.c | 2 +-
multipathd/cli_handlers.c | 16 +++---
multipathd/main.c | 40 +++++++-------
tests/test-lib.c | 9 +---12 files changed, 119 insertions(+), 118 deletions(-)
For the set: