fix issue of multipathd not tracking device
Benjamin Marzinski
maintainerv3 cover fix issue of multipathd not tracking device
I ran into an issue where multipathd wasn't tracking a multipath device that was created by the multipath command. It turns out that if multipathd fully initialized a path device, and that device later goes offline and then a multipath device that could use that path is created by multipath, multipathd will attempt to reload the device to use the offline path, which will fail. This will cause it to not track the multipath device at all.
The first patch fixes this. The second patch is prep work. The third patch allows mutipathd to track these offline paths that should belong to a device, and add them to device once they come back online. The third fourth is just a cleanup.
changes from v2
- 0002: New patch to avoid duplicating the code to determine if we can recheck the paths wwid.
- 0003: Always recheck WWID when path comes back online if capable (suggested by Martin Wilck). Fixed holdover code from v1 to set pp->initialized = INIT_OK when the path came back online. Fixed typo in documentation.
changes from v1
- 0002: Switch from tracking this state with pp->initialized to a new variable, as suggested by Martin Wilck. To make is so that multipathd can still show paths in this state without adding a new wildcard for it, add [offline] as a possible output for the %m (multipath device) path wildcard, for paths that couldn't be added to a multipath device because they are offline. Also constify a function parameter and add an explanitory comment as suggested by Martin.
Benjamin Marzinski (4):
multipathd: monitor new multipath dev even if we can't update it
libmultipath: add helper function check_path_wwid_change
multipathd: re-add paths skipped because they were offline
multipathd: don't update paths in INIT_MISSING_UDEV
libmultipath/discovery.c | 12 ++++++- libmultipath/discovery.h | 2 +- libmultipath/libmultipath.version | 5 +++ libmultipath/print.c | 5 ++- libmultipath/propsel.c | 4 +-- libmultipath/structs.h | 1 + libmultipath/structs_vec.c | 5 +++ multipathd/main.c | 59 +++++++++++++++++++++++++++++-- multipathd/multipathd.8.in | 5 +-- 9 files changed, 87 insertions(+), 11 deletions(-)
Signature · 1 line
2.48.1
Benjamin Marzinski
maintainerPATCH v3 1/4 multipathd: monitor new multipath dev even if we can't update it
If a multipath device was created by the multipath command, multipathd might not agree with how the device was created. ev_add_map() can reload the device with a different table by calling add_map_without_path() -> update_map(). If this reloading of the map failed, multipathd was simply ignoring the multipath device, even though it still existed.
One way that reloading can fail is if a path that multipathd already has initialized goes offline. If a multipath device is created by the multipath command while the path is offline, it will not use the offline path, since multipath won't be able to get the necessary pathinfo. However, multipathd will already have the pathinfo for the path, and may not even know that it's offline, since the path is an orphan. When it tries to reload the device, it will include the offline path, and the reload will fail.
Instead of ignoring the device if it can't reload it, multipathd should just montior it as it is. When the path device is no longer offline, it can be added back to the multipath device by calling "multipathd reconfigure" or "multipathd add path <path>".
--- multipathd/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
multipathd/main.c +1 -1
@@ -679,7 +679,7 @@ retry: } fail: -if (new_map && (retries <0 ||wait_for_events (mpp, vecs))) { +if (new_map &&wait_for_events (mpp, vecs)) {condlog (0 ,"%s: failed to create new map" , mpp->alias);remove_map (mpp, vecs->pathvec, vecs->mpvec);return 1 ;
Signature · 1 line
2.48.1
Benjamin Marzinski
maintainerPATCH v3 2/4 libmultipath: add helper function check_path_wwid_change
In reply to Benjamin MarzinskiWrap some code from select_recheck_wwid() in a helper function. A future patch will call this code from a different function.
--- libmultipath/discovery.c | 12 +++++++++++- libmultipath/discovery.h | 2 +- libmultipath/propsel.c | 4 +--- 3 files changed, 13 insertions(+), 5 deletions(-)
libmultipath/discovery.c +11 -1
@@ -2245,7 +2245,7 @@ static ssize_t uid_fallback(struct path *pp, int path_state,return len; } -bool has_uid_fallback (struct path *pp) +static bool has_uid_fallback (const struct path *pp) {/* * Falling back to direct WWID determination is dangerous
@@ -2266,6 +2266,16 @@ bool has_uid_fallback(struct path *pp) !strcmp(pp->uid_attribute, "")))); } +bool can_recheck_wwid (const struct path *pp) +{ +/* +* check_path_wwid_change() only works for scsi devices, and it +* is only guaranteed to give the same WWID if the path uses +* the default uid_attribute +*/ +return (pp->bus ==SYSFS_BUS_SCSI &&has_uid_fallback (pp)); +} +int get_uid (struct path * pp,int path_state,struct udev_device *udev,int allow_fallback)
libmultipath/discovery.h +1 -1
@@ -55,7 +55,7 @@ ssize_t sysfs_get_inquiry(struct udev_device *udev, unsigned char *buff, size_t len);int sysfs_get_asymmetric_access_state (struct path *pp,char *buff,int buflen); -bool has_uid_fallback (struct path *pp); +bool can_recheck_wwid (const struct path *pp);int get_uid (struct path * pp,int path_state,struct udev_device *udev,int allow_fallback);bool is_vpd_page_supported (int fd,int pg);
libmultipath/propsel.c +1 -3
@@ -739,9 +739,7 @@ int select_recheck_wwid(struct config *conf, struct path * pp)pp_set_conf (recheck_wwid);pp_set_default (recheck_wwid,DEFAULT_RECHECK_WWID ); out: -if (pp->recheck_wwid ==RECHECK_WWID_ON && - (pp->bus !=SYSFS_BUS_SCSI || - !has_uid_fallback (pp))) { +if (pp->recheck_wwid ==RECHECK_WWID_ON && !can_recheck_wwid (pp)) { pp->recheck_wwid =RECHECK_WWID_OFF ; origin ="(setting: unsupported by device type/config)" ; }
Signature · 1 line
2.48.1
Benjamin Marzinski
maintainerPATCH v3 3/4 multipathd: re-add paths skipped because they were offline
In reply to Benjamin MarzinskiWhen a new device is added by the multipath command, multipathd may know of other paths that cannot be added to the device because they are currently offline. Instead of ignoring these paths, multipathd will now re-add them when they come back online. To do this, it multipathd needs a new path variable add_when_online, to track devices that could not be added to an existing multipath device because they were offline. These paths are handled along with the other uninitialized paths.
--- libmultipath/libmultipath.version | 5 +++ libmultipath/print.c | 5 ++- libmultipath/structs.h | 1 + libmultipath/structs_vec.c | 5 +++ multipathd/main.c | 58 +++++++++++++++++++++++++++++-- multipathd/multipathd.8.in | 5 +-- 6 files changed, 74 insertions(+), 5 deletions(-)
libmultipath/libmultipath.version +5 -0
@@ -245,3 +245,8 @@ global: local: *; }; + +LIBMULTIPATH_29.1.0 { +global: + can_recheck_wwid; +} LIBMULTIPATH_29.0.0;
libmultipath/print.c +4 -1
@@ -658,8 +658,11 @@ snprint_path_serial (struct strbuf *buff, const struct path * pp)static int snprint_path_mpp (struct strbuf *buff,const struct path * pp) { -if (!pp->mpp) +if (!pp->mpp) { +if (pp->add_when_online) +return append_strbuf_str (buff,"[offline]" );return append_strbuf_str (buff,"[orphan]" ); + }if (!pp->mpp->alias)return append_strbuf_str (buff,"[unknown]" );return snprint_str (buff, pp->mpp->alias);
libmultipath/structs.h +1 -0
@@ -413,6 +413,7 @@ struct path {int eh_deadline;enum check_path_states is_checked;bool can_use_env_uid; +bool add_when_online;unsigned int checker_timeout;/* configlet pointers */ vector hwe;
libmultipath/structs_vec.c +5 -0
@@ -389,6 +389,9 @@ static void orphan_paths(vector pathvec, struct multipath *mpp, const char *reasfree_path (pp); }else orphan_path (pp, reason); + }else if (pp->add_when_online && +strncmp (mpp->wwid, pp->wwid,WWID_SIZE ) ==0 ) { + pp->add_when_online = false; } } }
@@ -595,6 +598,8 @@ void sync_paths(struct multipath *mpp, vector pathvec) found =0 ; vector_foreach_slot(mpp->pg, pgp, j) {if (find_slot (pgp->paths, (void *)pp) !=-1 ) { +if (pp->add_when_online) + pp->add_when_online = false; found =1 ;break ; }
multipathd/main.c +56 -2
99 lines not on this page · raw message
multipathd/multipathd.8.in +3 -2
@@ -595,8 +595,9 @@ The device serial number. The device marginal state, either \fImarginal\fR or \fInormal\fR. .TP .B %m -The multipath device that this device is a path of, or \fI[orphan]\fR if -it is not part of any multipath device. +The multipath device that this device is a path of, or \fI[offline]\fR +if this device could not be added to a device because it is offline or +\fI[orphan]\fR if it is not part of any multipath device. .TP .B %N The host World Wide Node Name (WWNN) of the device, if any.
Signature · 1 line
2.48.1
Benjamin Marzinski
maintainerPATCH v3 4/4 multipathd: don't update paths in INIT_MISSING_UDEV
In reply to Benjamin MarzinskiThere is nothing for update_uninitialized_path() to do for paths in the INIT_MISSING_UDEV state. In fact, there shouldn't be any paths in this state when update_uninitialized_path() is called, since they will have switched to a different state in check_uninitialized_path().
--- multipathd/main.c | 1 - 1 file changed, 1 deletion(-)
multipathd/main.c +0 -1
@@ -2890,7 +2890,6 @@ update_uninitialized_path(struct vectors * vecs, struct path * pp)struct config *conf;if (pp->initialized !=INIT_NEW && pp->initialized !=INIT_FAILED && - pp->initialized !=INIT_MISSING_UDEV && !(pp->initialized ==INIT_OK && pp->add_when_online))return CHECK_PATH_SKIPPED ;
Signature · 1 line
2.48.1
Quoted 49 lines · Benjamin Marzinski
I ran into an issue where multipathd wasn't tracking a multipath device that was created by the multipath command. It turns out that if
multipathd fully initialized a path device, and that device later goes offline and then a multipath device that could use that path is created by multipath, multipathd will attempt to reload the device to use the offline path, which will fail. This will cause it to not track the multipath device at all.The first patch fixes this. The second patch is prep work. The third patch allows mutipathd to track these offline paths that should belong
to a device, and add them to device once they come back online. The third fourth is just a cleanup.changes from v2
- 0002: New patch to avoid duplicating the code to determine if we can recheck the paths wwid.
- 0003: Always recheck WWID when path comes back online if capable (suggested by Martin Wilck). Fixed holdover code from v1 to setpp->initialized=INIT_OKwhen the path came back online. Fixed typo in documentation.changes from v1
- 0002: Switch from tracking this state withpp->initializedto a new variable, as suggested by Martin Wilck. To make is so that multipathd can still show paths in this state without adding a new wildcard for it, add [offline] as a possible output for the %m (multipath device) path wildcard, for paths that couldn't be added to a multipath device because they are offline. Also constify a function parameter and add an explanitory comment as suggested by Martin.Benjamin Marzinski (4):
multipathd: monitor new multipath dev even if we can't update it
libmultipath: add helper functioncheck_path_wwid_change
multipathd: re-add paths skipped because they were offline
multipathd: don't update paths inINIT_MISSING_UDEVlibmultipath/discovery.c | 12 ++++++-
libmultipath/discovery.h | 2 +-
libmultipath/libmultipath.version | 5 +++
libmultipath/print.c | 5 ++-
libmultipath/propsel.c | 4 +--
libmultipath/structs.h | 1 +
libmultipath/structs_vec.c | 5 +++
multipathd/main.c | 59
+++++++++++++++++++++++++++++--
multipathd/multipathd.8.in | 5 +--
Quoted 1 line
9 files changed, 87 insertions(+), 11 deletions(-)
For the series: