On Mon, 2026-11-16 at 14:46 -0500, Benjamin Marzinski wrote:
> On Fri, Nov 13, 2026 at 09:52:23PM +0100, Martin Wilck wrote:
> > On Fri, 2026-11-13 at 13:00 -0500, Benjamin Marzinski wrote:
> > > On Thu, Nov 12, 2026 at 11:24:32PM +0100, Martin Wilck wrote:
> > > >
> > > > > }
> > > > > + /*
> > > > > + * This path is being re-added because its udev data
> > > > > was
> > > > > missing or
> > > > > + * changed. The uevent may have been queued long
> > > > > before
> > > > > we got here,
> > > > > + * and adding a path to the map of a different LUN
> > > > > corrupts data. If
> > > > > + * recheck_wwid is set, confirm the WWID with the
> > > > > device
> > > > > first. On a
> > > > > + * mismatch, leave the path out and let the checker
> > > > > retrigger udev
> > > > > + * to get a fresh WWID.
> > > > > + */
> > > > > + if (mode == PATH_ADD_REINIT && pp->recheck_wwid ==
> > > > > RECHECK_WWID_ON &&
> > > > > + check_path_wwid_change(pp)) {
> > > >
> > > > check_path_wwid_change() returns false when it fails, is it
> > > > correct
> > > > to keep the
> > > > path in that case? IMHO we should treat this like the
> > > > strlen(pp-
> > > > > wwid) == 0 case
> > > > above.
> > >
> > > Not sure I agree with this. It's a paranoia check. If it fails, I
> > > don't
> > > have a problem with just trusting the data that was given to us.
> > > I'm
> > > willing to be convinced otherwise, however.
> >
> > In my mind, a changed WWID followed by a failure to obtain the WWID
> > from the device shows that something is really fishy about the path
> > in
> > question.
> >
> > Moreover:
> >
> > I realize that uev_update_path() calls get_uid() with
> > allow_fallback=0.
> > This goes back to your commit ffaf947 ("multipathd: Don't use
> > fallback
> > code after getting wwid"), where the rationale you provided was
> >
> > > once the
> > > devices are set up, udev is the definitive source of this
> > > information
> > > ...
> > > Working under the assumption that udev will either never give us
> > > this
> > > information, or that it usually will.
> >
> > We have given up this assumption, at least partly. In view of the
> > late
> > discussions, it seems reasonable to me to allow fallback to SG_IO
> > if
> > udev failed, at least if pp->wwid was non-zero before.
> >
> > Then, if the fallback failed, the situation would really be almost
> > identical to the failing paranoia check.
>
> I wrote my objection assuming that this code would also be called
> when
> when we simply hadn't gotten the WWID on the first uevent. If we
> retrigger a uevent and then get the WWID, but the SG_IO fails, we
> could
> end up not creating the multipath device at all, despite the the path
> existing with a WWID (albeit with some issues). Perhaps that's the
> correct answer for an obviously flakey device. If this code was only
> run
> when we got a wwid before and then it changed, then requiring a
> matching
> WWID from the device seems much more reasonable.
>
> > >
> > > makes sense.
> > >
> > > > But more generally: as this indicates a possible mismatch
> > > > between
> > > > kernel and device
> > > > state, should we handle this similar to
> > > > handle_path_wwid_change()
> > > > instead,
> > > > i.e. also call rescan_path()? I guess that would need to be
> > > > done in
> > > > uev_update_path(),
> > > > i.e. it would touch the regular "wwid changed in uevent" path.
> > >
> > > Is this not another place were we are opening ourselves up for
> > > commands
> > > blocking? If we want to do a rescan and it can block, it makes
> > > more
> > > sense to do it only if recheck_wwids is set, and we know that the
> > > path
> > > is up.
> > >
> >
> > Right, I didn't consider that rescan_path() may block. But still,
> > why
> > do we need to rescan in handle_path_wwid_change(), but not here?
> >
> > AFAICS, the likelihood that the kernel is using stale information
> > is
> > quite high when we handle this situation. I'm not sure if testing
> > whether the path is up makes much sense. There are many situations
> > in
> > which the path would be down, but rescan/inquiry would still work.
> > The
> > only thing that would really hurt us are timeouts during the
> > kernel's
> > probing procedure, but I am not aware of an easy way to predict
> > whether
> > that will happen.
> >
> > I suppose we could rescan asynchronously in this case. After all,
> > we
> > already have obtained the real WWID from the device, therefore we
> > don't
> > need to wait for the rescan to finish.
>
> I'm not against the rescan, I just thought it made more sense in
> ev_add_path(), although running it asynchronously works too.
For now, doing it in ev_add_path() is fine. It's conditional on the
recheck_wwid option, anyway.
> > > > >
> > > > > + }
> > > > > mpp = find_mp_by_wwid(vecs->mpvec, pp->wwid);
> > > > > if (mpp && pp->size && mpp->size != pp->size) {
> > > > > condlog(0, "%s: failed to add new path %s,
> > > > > device size mismatch", mpp->alias, pp->dev);
> > > > > @@ -1375,7 +1390,7 @@ rescan:
> > > > > if (ro == 1)
> > > > > mpp->force_readonly = 1;
> > > > >
> > > > > - if (!need_do_map)
> > > > > + if (mode == PATH_ADD_NO_MAP)
> > > > > return 0;
> > > > >
> > > > > if (!dm_map_present(mpp->alias)) {
> > > > > @@ -1789,7 +1804,7 @@ out:
> > > > > }
> > > > > /* pp->initialized must not be INIT_PARTIAL if
> > > > > needs_reinit is set */
> > > > > if (needs_reinit)
> > > > > - retval = uev_add_path(uev, vecs, 1);
> > > > > + retval = uev_add_path(uev, vecs,
> > > > > PATH_ADD_REINIT);
> > > >
> > > > Is it correct to take this branch also if needs_reinit is set
> > > > because
> > > > INIT_REQUESTED_UDEV was set? I don't think so.
> > >
> > > This is a little tricky. I agree that we don't need to add the
> > > extra
> > > layer of paranoid checking when the path never got a wwid. In
> > > that
> > > case,
> > > what most likely what happened is that the udev worker thread
> > > timed
> > > out
> > > on the previous uevent, so we couldn't get the WWID from uevent
> > > variables. However, if we don't recheck on INIT_REQUESTED_UDEV,
> > > then
> > > we
> > > can get into a situation where:
> > > 1. uev_update_path() notices that the wwid has changed
> > > 2. ev_add_path() confirms that the wwid we got from udev doesn't
> > > match
> > > the wwid we get directly asking the device
> > > 3. We trigger a new uevent
> > > 4. We blindly trust udev's wwid.
> >
> > We need to trust udev at some point, don't we? Assume
> >
> > 4. we double check again
> > 5. ev_add_path() confirms that the wwid we got from udev doesn't
> > match
> > 6. goto 3
> >
> > At least we'd need to avoid getting stuck in a loop.
>
> This will only loop for retrigger_tries. Then it will give up and
> trust
> udev without double-checking. Athough we never reset pp->retriggers
> once
> we have a reasonable WWID, so we only get retrigger_tries for the
> entire
> lifetime of the path. It seems like the retries when we couldn't get
> a
> WWID from udev are different than the retries when the WWIDs don't
> match.
Right, I forgot about retrigger_tries. Thanks for the correction.
About the different types of retrigger_tries - yes, we use the same
counter, and actually the entire "retrigger" logic, for two different
things now. I don't see an issue with resetting retrigger_tries once
the issues with path's WWID are sorted out, in both cases.
>
> > AFAICS there are 2 reasons to do the SG_IO check:
> >
> > 1) vpd info from sysfs may be stale (affects SUSE only)
> > 2) something changed between the VPD detection in udev rules and
> > our
> > event handling
> >
> > Then there is
> >
> > 3) a bug e.g. in an udev rule causes ID_SERIAL to be consistently
> > wrong.
> >
> > Case 1) would be fixed triggering a rescan (see above). In case 2),
> > it
> > makes a certain amount of sense to trust udev the next time. Case
> > 3)
> > would cause an infinite loop if we keep double-checking.
> >
> > > Perhaps we need more initialization states or a path device flag
> > > to
> > > distinguish between the two cases (never having gotten a WWID, or
> > > having
> > > our WWID . Or we can decide that we are o.k. with extra checking
> > > whenever something goes wrong with getting the wwid from udev
> > > (when
> > > you
> > > have recheck_wwid set). Or am I misunderstanding something about
> > > why
> > > doing this is wrong? Are we intentionally only double-checking
> > > once
> > > here?
> >
> > I don't like the idea of checking the first time around very much,
> > but
> > I agree it isn't a big deal. OTOH, see above.
>
> If it's fine to only do one double-check before trusting udev, then
> PATH_ADD_REINIT is just for that one recheck, and what to do in that
> case is less ambiguous.
>
> > Yet another possibility is to introduce a new mode where we just
> > never
> > trust udev. That'd be a 180" turn, but it might be worth trying.
> > The longer we discuss this, the more attractive it seems to me.
> > Rather
> > than guessing whether or not we can trust udev, just use a "zero
> > trust"
> > model :-)
>
> I wouldn't be against it. Device WWIDs could potentially switch
> between
> modes. But as long as users know that they would need to be careful
> when
> switching modes, that should be fine. Were you thinking of always
> getting the wwid through SG_IO, or were you thinking of using
> something
> like sysfs that could still potentially give you a stale value?
I had SG_IO in mind, but I haven't thought it through. That would be
large change, so we might as well provide both options.
Martin
--
Dr. Martin Wilck <[email protected]>
SUSE Software Solutions Germany GmbH, Frankenstr. 146, 90461 Nürnberg,
Germany
Geschäftsführer: Stefan Gaiser, Jochen Jaser, Abhinav Puri (HRB
36809,AG Nürnberg)