On 3/1/24 23:40, Martin Wilck wrote: > DM_UDEV_DISABLE_OTHER_RULES_FLAG is used as the "output" flag of the > device-mapper rules, to be consumed by non-dm rules. It is a logical OR of > several conditions that might make dm devices inaccessible. 10-dm.rules > calculates it for every uevent, whether it's genuine or spurious. > > DM_SUBSYSTEM_UDEV_FLAG0 is just another flag that needs to be or'd in. We > don't need to restore the previous state of DM_UDEV_DISABLE_OTHER_RULES_FLAG. > Actually, doing so is wrong if the flag has previously been set because the > device was suspended, and the device isn't suspended anymore. > > Signed-off-by: Martin Wilck <mwilck@xxxxxxxx> > --- > udev/11-dm-lvm.rules.in | 13 +++++-------- > 1 file changed, 5 insertions(+), 8 deletions(-) > > diff --git a/udev/11-dm-lvm.rules.in b/udev/11-dm-lvm.rules.in > index 7c58994..0b77fe2 100644 > --- a/udev/11-dm-lvm.rules.in > +++ b/udev/11-dm-lvm.rules.in > @@ -26,14 +26,11 @@ IMPORT{program}="(DM_EXEC)/dmsetup splitname --nameprefixes --noheadings --rows > # to zero any stale metadata found within the LV data area. Such stale > # metadata could cause false claim of the LV device, keeping it open etc. > # > -# If the NOSCAN flag is present, backup selected existing flags used to > -# disable rules, then set them firmly so those selected rules are surely skipped. > -# Restore these flags once the NOSCAN flag is dropped (which is normally any > -# uevent that follows for this LV, even an artificially generated one). > -ENV{DM_SUBSYSTEM_UDEV_FLAG0}=="1", ENV{DM_NOSCAN}="1", ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}="$env{DM_UDEV_DISABLE_OTHER_RULES_FLAG}", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1" > -ENV{DM_SUBSYSTEM_UDEV_FLAG0}!="1", IMPORT{db}="DM_NOSCAN", IMPORT{db}="DM_DISABLE_OTHER_RULES_FLAG_OLD" > -ENV{DM_SUBSYSTEM_UDEV_FLAG0}!="1", ENV{DM_NOSCAN}=="1", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="$env{DM_DISABLE_OTHER_RULES_FLAG_OLD}", \ > - ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}="", ENV{DM_NOSCAN}="" > +# If the NOSCAN flag is present, set DM_UDEV_DISABLE_OTHER_RULES_FLAG > +# so those selected rules are surely skipped. > +# We don't need to save and restore the previous of DM_UDEV_DISABLE_OTHER_RULES_FLAG, > +# that's taken care of in 10-dm.rules. > +ENV{DM_SUBSYSTEM_UDEV_FLAG0}=="1", ENV{DM_NOSCAN}="1", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1" > > ENV{DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG}=="1", GOTO="lvm_end" > Looks good too, I gave it a quick test run and haven't noticed an issue so far. Nice cleanup! -- Peter