multipathd: recheck WWIDs of re-added paths with the device
v5 cover multipathd: recheck WWIDs of re-added paths with the device
During an array controller failover on an iSCSI host, multipathd briefly put a path to one LUN into the map of another LUN, and I/O meant for the first LUN landed on the second. See the v1 cover letter for the full sequence.
In short: a change uevent reported the wrong WWID for one path. The removal of the path from its map then blocked for 4.4 seconds while the map was suspended, and the re-add used that same, by then 4.4 second old, uevent to put the path into the wrong map. The next INQUIRY on the path, 140 ms after the re-add, returned the correct WWID.
Changes in v5, after Martin's and Ben's review of v4:
- The check only runs for paths that are up, as Ben suggested. A path that isn't up is checked by recheck_wwid when it comes up, so this is no riskier than the existing recheck_wwid checks.
- PATH_ADD_REINIT is passed only when udev reported a changed WWID. The re-add after a udev retrigger (INIT_REQUESTED_UDEV) takes the normal path, so the fresh udev data is trusted and a persistently wrong ID_SERIAL isn't checked over and over.
- If the device doesn't confirm the new WWID, or its WWID can't be read, the path is left out. v4 kept the path when the SG_IO read failed. check_path_wwid() now reports a mismatch and a failure separately; check_path_wwid_change() still returns true only on a mismatch, so its other callers behave as before.
- When the path is left out, pp->tick is set to retrigger_delay, as pathinfo() does, and the message is logged at level 2 instead of 0.
- multipath.conf(5) now says that the check is for up paths and that an unreadable WWID counts as unconfirmed.
Left for follow-ups, as discussed in the v4 thread: resetting pp->retriggers once a path has a confirmed WWID, rescanning the path (possibly asynchronously) when its WWID changed, and a mode in which multipathd never trusts udev for the WWID.
We've seen the problem once and haven't reproduced it. We have been running a v1-style patch on our test initiators since then without a recurrence, which at this rate doesn't prove much either way.
Brian Bunker (1):
multipathd: recheck WWIDs of re-added paths with the device
multipath/multipath.conf.5.in | 8 ++-- multipathd/cli_handlers.c | 2 +- multipathd/main.c | 74 +++++++++++++++++++++++++++-------- multipathd/main.h | 13 +++++- 4 files changed, 75 insertions(+), 22 deletions(-)
Signature · 1 line
2.56.0
PATCH v5 1/1 multipathd: recheck WWIDs of re-added paths with the device
multipathd takes a path's WWID from udev. When a change uevent reports a different WWID, uev_update_path() removes the path from its map and re-adds it through uev_add_path(), which places it in whatever map owns the new WWID. The removal can block for seconds while the map is suspended, so by the time the path is re-added, the WWID in the uevent may no longer be what the device reports. If it is wrong, the path goes into the map of a different LUN and I/O for one LUN is silently sent to another.
If recheck_wwid is set and the path is up, confirm the WWID with the device over SG_IO before such a re-add puts the path into a map, as recheck_wwid already does when a failed path comes back. If the device doesn't confirm it, or its WWID can't be read, leave the path out of the map: orphan it, clear its WWID and mark it INIT_MISSING_UDEV, so the checker retriggers udev after retrigger_delay and the path is re-added from fresh data. A path that isn't up is checked by recheck_wwid once it comes up.
To tell these re-adds from ordinary adds, turn the need_do_map argument of uev_add_path() and ev_add_path() into enum path_add_mode, with a new PATH_ADD_REINIT value that behaves like PATH_ADD_MAP. It is passed only for the re-add at the end of uev_update_path() after udev reported a changed WWID. The re-add after a udev retrigger, and ordinary adds, are unchanged, so udev data obtained by a retrigger is trusted.
Split check_path_wwid() out of check_path_wwid_change() so that a failure to read the device's WWID can be told apart from a match. check_path_wwid_change() still returns true only on a mismatch.
Document the new case under recheck_wwid in multipath.conf(5).
--- multipath/multipath.conf.5.in | 8 ++-- multipathd/cli_handlers.c | 2 +- multipathd/main.c | 74 +++++++++++++++++++++++++++-------- multipathd/main.h | 13 +++++- 4 files changed, 75 insertions(+), 22 deletions(-)
multipath/multipath.conf.5.in +5 -3
@@ -1382,9 +1382,11 @@ The default is: \fB\(dqNONE\(dq\fR If set to \fIyes\fR, when a failed path is restored, its wwid is rechecked. If the wwid has changed, the path is removed from the current multipath device, and re-added as a new path. Multipathd will also recheck a path's wwid if it is -manually re-added. This option only works for SCSI devices that are configured -to use the default uid_attribute, \fIID_SERIAL\fR, or sysfs for getting their -wwid. +manually re-added, and before re-adding an up path whose wwid udev reported as +changed. If the device doesn't confirm the new wwid, or its wwid can't be read, +the path is left out of the multipath device and udev is asked to report its +wwid again. This option only works for SCSI devices that are configured to use +the default uid_attribute, \fIID_SERIAL\fR, or sysfs for getting their wwid. .RS .TP The default is: \fBno\fR
multipathd/cli_handlers.c +1 -1
@@ -673,7 +673,7 @@ cli_add_path (void *v, struct strbuf *reply, void *data)return 1 ; } } -return ev_add_path (pp, vecs,1 ); +return ev_add_path (pp, vecs,PATH_ADD_MAP ); blacklisted:append_strbuf_str (reply,"blacklisted\n" );condlog (2 ,"%s: path blacklisted" , param);
multipathd/main.c +57 -17
177 lines not on this page · raw message
multipathd/main.h +12 -1
@@ -36,7 +36,18 @@ enum daemon_status wait_for_state_change_if(enum daemon_status oldstate, unsigned long ms);void schedule_reconfigure (enum force_reload_types requested_type);int need_to_delay_reconfig (struct vectors *); -int ev_add_path (struct path *,struct vectors *,int ); +/* +* PATH_ADD_REINIT is PATH_ADD_MAP for a path that is being re-added +* because udev reported a different WWID than it had before. If +* recheck_wwid is set and the path is up, its WWID is confirmed with +* the device before the path is put into a map. +*/ +enum path_add_mode { +PATH_ADD_NO_MAP , +PATH_ADD_MAP , +PATH_ADD_REINIT , +}; +int ev_add_path (struct path *,struct vectors *,enum path_add_mode );int ev_remove_path (struct path *,struct vectors *,int );int ev_add_map (char *,const char *,struct vectors *);int flush_map (struct multipath *,struct vectors *);
Signature · 1 line
2.56.0
Benjamin Marzinski
maintainerQuoted 25 lines · Brian Bunker
multipathd takes a path's WWID from udev. When a change uevent reports a different WWID,
uev_update_path()removes the path from its map and re-adds it throughuev_add_path(), which places it in whatever map owns the new WWID. The removal can block for seconds while the map is suspended, so by the time the path is re-added, the WWID in the uevent may no longer be what the device reports. If it is wrong, the path goes into the map of a different LUN and I/O for one LUN is silently sent to another.If
recheck_wwidis set and the path is up, confirm the WWID with the device overSG_IObefore such a re-add puts the path into a map, asrecheck_wwidalready does when a failed path comes back. If the device doesn't confirm it, or its WWID can't be read, leave the path out of the map: orphan it, clear its WWID and mark itINIT_MISSING_UDEV, so the checker retriggers udev afterretrigger_delayand the path is re-added from fresh data. A path that isn't up is checked byrecheck_wwidonce it comes up.To tell these re-adds from ordinary adds, turn the
need_do_mapargument ofuev_add_path()andev_add_path()into enumpath_add_mode, with a newPATH_ADD_REINITvalue that behaves likePATH_ADD_MAP. It is passed only for the re-add at the end ofuev_update_path()after udev reported a changed WWID. The re-add after a udev retrigger, and ordinary adds, are unchanged, so udev data obtained by a retrigger is trusted.
Quoted 5 lines
Split
check_path_wwid()out ofcheck_path_wwid_change()so that a failure to read the device's WWID can be told apart from a match.check_path_wwid_change()still returns true only on a mismatch.Document the new case under
recheck_wwidinmultipath.conf(5).
Look pretty good. One minor possible change below. Feel free to tell me I'm trying to abuse path_add_mode.
Quoted 12 lines
Signed-off-by Brian Bunker <[email protected]>--- multipath/multipath.conf.5.in | 8 ++-- multipathd/cli_handlers.c | 2 +- multipathd/main.c | 74 +++++++++++++++++++++++++++-------- multipathd/main.h | 13 +++++- 4 files changed, 75 insertions(+), 22 deletions(-)multipathd/main.c +0
-0
[...]
multipathd/main.c uev_update_path (struct uevent *uev, struct vectors * vecs) · line 1697
Quoted 5 lines
multipathd/main.c +1
-0@@ -1656,6 +1694,7 @@ uev_update_path (struct uevent *uev, struct vectors * vecs)struct path * pp;struct config *conf;int needs_reinit =0 ; +enum path_add_mode reinit_mode =PATH_ADD_MAP ;
Since we're tracking the reinit_mode with a path_add_mode enum, it seems to me like needs_reinit is unnecessary. We could just default reinit_mode to PATH_ADD_NO_MAP, and either set it to PATH_ADD_MAP for a INIT_REQUESTED_UDEV path or PATH_ADD_REINIT for a changed wwid path. Then, instead of checking need_reinit at the end of the function, we could just check (reinit_mode != PATH_ADD_NO_MAP). Obviously other callers of uev_add_path() do pass in PATH_ADD_NO_MAP as a mode, so if people think this usage is confusing and not worth removing a redundant variable, that's fine.
-Ben