multipath udev rules changes for dm rules V3
v2 cover multipath udev rules changes for dm rules V3
This patch set adapts the multipath rules to the pending changes for device mapper rules that update DM_UDEV_RULES_VSN to 3, and applies some additional clean-ups to the rules files.
Changes v1 -> v2:
All changes suggested by Benjamin Marzinski except the last one.
* multiple patches: check DM_UDEV_RULES_VSN agains "1|2" rather than "3".
* 01/11: this patch was wrong as discussed, dropped code changes and added some comments instead, lest I make the same mistake again.
* 02/11: fix label name in comment to match an existing label
* 04/11: added missing "\" at end of line
Comments welcome.
Martin Wilck (11):
11-dm-mpath.rules: explain logic for device becoming ready while
suspended
11-dm-mpath.rules: don't import DM_NOSCAN from udev db 11-dm-mpath.rules: don't import ID_FS_VERSION from udev db 11-dm-mpath.rules: adapt MPATH_DEVICE_READY=0 logic to 10-dm.rules
update
11-dm-mpath.rules: adapt coldplug event handling ro 10-dm.rules update 11-dm-mpath.rules: don't import properties with new 13-dm-disk.rules 11-dm-mpath.rules: replace DM_SUSPENDED by .DM_SUSPENDED 11-dm-mpath.rules: replace DM_NOSCAN by .DM_NOSCAN 11-dm-mpath.rules: simplify PATH_FAILED case 11-dm-mpath.rules: make label names more intuitive kpartx.rules: ignore DM_SUSPENDED
kpartx/kpartx.rules | 2 +- multipath/11-dm-mpath.rules.in | 86 ++++++++++++++++++++-------------- 2 files changed, 52 insertions(+), 36 deletions(-)
Signature · 1 line
2.44.0
PATCH v2 1/11 11-dm-mpath.rules: explain logic for device becoming ready while suspended
Add a comment to explain why we must set MPATH_DEVICE_READY=0 when we see a device becoming ready (number of active paths 0 -> 1) while the device is suspended.
--- multipath/11-dm-mpath.rules.in | 2 ++ 1 file changed, 2 insertions(+)
multipath/11-dm-mpath.rules.in +2 -0
@@ -98,6 +98,8 @@ ENV{MPATH_DEVICE_READY}=="0", \ # If the device comes back online, set DM_ACTIVATION so that # upper layers do a rescan. If the device is currently suspended, # we have to postpone the activation until the next event. +# In this case, we have to set MPATH_DEVICE_READY=0; otherwise, the +# MPATH_UNCHANGED logic will cause later rules to skipped in the next event. ENV{MPATH_DEVICE_READY}=="0", GOTO="dont_activate" ENV{.MPATH_DEVICE_READY_OLD}!="0", GOTO="dont_activate" ENV{DM_SUSPENDED}=="1", ENV{MPATH_DEVICE_READY}="0", GOTO="dont_activate"
Signature · 1 line
2.44.0
Re: [PATCH v2 01/11] 11-dm-mpath.rules: explain logic for device becoming ready while suspended
Quoted 5 lines · Martin Wilck
Add a comment to explain why we must set MPATH_DEVICE_READY=0 when we see a device becoming ready (number of active paths 0 -> 1) while the device is suspended.
Signed-off-by Martin Wilck <[email protected]>
Quoted 19 lines
--- multipath/11-dm-mpath.rules.in | 2 ++ 1 file changed, 2 insertions(+)multipath/11-dm-mpath.rules.in +2
-0@@ -98,6 +98,8 @@ ENV{MPATH_DEVICE_READY}=="0", \ # If the device comes back online, set DM_ACTIVATION so that # upper layers do a rescan. If the device is currently suspended, # we have to postpone the activation until the next event. +# In this case, we have to set MPATH_DEVICE_READY=0; otherwise, the +# MPATH_UNCHANGED logic will cause later rules to skipped in the next event. ENV{MPATH_DEVICE_READY}=="0", GOTO="dont_activate" ENV{.MPATH_DEVICE_READY_OLD}!="0", GOTO="dont_activate" ENV{DM_SUSPENDED}=="1", ENV{MPATH_DEVICE_READY}="0", GOTO="dont_activate"Signature · 1 line
2.44.0
PATCH v2 2/11 11-dm-mpath.rules: don't import DM_NOSCAN from udev db
In reply to Martin WilckDM_NOSCAN is our "output" flag for 13-dm-disk.rules, and it should be treated the same way as DM_UDEV_DISABLE_OTHER_RULES_FLAG, which isn't imported from the udev database. The state that we need to remember is MPATH_DEVICE_READY, which we've already imported above, and we will set the "output" flags accordingly in the "force_activation" code path further down.
--- multipath/11-dm-mpath.rules.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
multipath/11-dm-mpath.rules.in +4 -2
@@ -18,9 +18,11 @@ ACTION=="add", ENV{DM_ACTIVATION}=="1", ENV{DM_SUSPENDED}!="1", ENV{DISK_RO}!="1 # If this uevent didn't come from dm, don't try to update the # device state +# Note that .MPATH_DEVICE_READY_OLD=="" here. Thus we won't activate the +# device below at force_activation, which is correct. ENV{DM_COOKIE}!="?*", ENV{DM_ACTION}!="PATH_*", \ - IMPORT{db}="DM_NOSCAN", IMPORT{db}="DM_COLDPLUG_SUSPENDED", \ - GOTO="scan_import" + IMPORT{db}="DM_COLDPLUG_SUSPENDED", \ + GOTO="force_activation" ENV{.MPATH_DEVICE_READY_OLD}="$env{MPATH_DEVICE_READY}"
Signature · 1 line
2.44.0
Re: [PATCH v2 02/11] 11-dm-mpath.rules: don't import DM_NOSCAN from udev db
Quoted 8 lines · Martin Wilck
DM_NOSCANis our "output" flag for 13-dm-disk.rules, and it should be treated the same way asDM_UDEV_DISABLE_OTHER_RULES_FLAG, which isn't imported from the udev database. The state that we need to remember isMPATH_DEVICE_READY, which we've already imported above, and we will set the "output" flags accordingly in the "force_activation" code path further down.Signed-off-by Martin Wilck <[email protected]>
Quoted 24 lines
--- multipath/11-dm-mpath.rules.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)multipath/11-dm-mpath.rules.in +4
-2@@ -18,9 +18,11 @@ ACTION=="add", ENV{DM_ACTIVATION}=="1", ENV{DM_SUSPENDED}!="1", ENV{DISK_RO}!="1 # If this uevent didn't come from dm, don't try to update the # device state +# Note that .MPATH_DEVICE_READY_OLD=="" here. Thus we won't activate the +# device below at force_activation, which is correct. ENV{DM_COOKIE}!="?*", ENV{DM_ACTION}!="PATH_*", \ - IMPORT{db}="DM_NOSCAN", IMPORT{db}="DM_COLDPLUG_SUSPENDED", \ - GOTO="scan_import" + IMPORT{db}="DM_COLDPLUG_SUSPENDED", \ + GOTO="force_activation" ENV{.MPATH_DEVICE_READY_OLD}="$env{MPATH_DEVICE_READY}"Signature · 1 line
2.44.0
PATCH v2 3/11 11-dm-mpath.rules: don't import ID_FS_VERSION from udev db
In reply to Martin WilckUse the same set of properties to import as 13-dm-disk.rules. ID_FS_VERSION isn't used in any udev rule I am aware of.
--- multipath/11-dm-mpath.rules.in | 1 - 1 file changed, 1 deletion(-)
multipath/11-dm-mpath.rules.in +0 -1
@@ -126,7 +126,6 @@ IMPORT{db}="ID_FS_TYPE" IMPORT{db}="ID_FS_USAGE" IMPORT{db}="ID_FS_UUID_ENC" IMPORT{db}="ID_FS_LABEL_ENC" -IMPORT{db}="ID_FS_VERSION" IMPORT{db}="ID_PART_ENTRY_NAME" IMPORT{db}="ID_PART_ENTRY_UUID" IMPORT{db}="ID_PART_ENTRY_SCHEME"
Signature · 1 line
2.44.0
PATCH v2 4/11 11-dm-mpath.rules: adapt MPATH_DEVICE_READY=0 logic to 10-dm.rules update
In reply to Martin WilckWith the late patches for 10-dm.rules, DM_UDEV_DISABLE_OTHER_RULES_FLAG isn't restored from the udev database any more, so we don't need to restore the flag to its original state before it is saved to the db.
--- multipath/11-dm-mpath.rules.in | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
multipath/11-dm-mpath.rules.in +12 -10
@@ -19,7 +19,7 @@ ACTION=="add", ENV{DM_ACTIVATION}=="1", ENV{DM_SUSPENDED}!="1", ENV{DISK_RO}!="1 # If this uevent didn't come from dm, don't try to update the # device state # Note that .MPATH_DEVICE_READY_OLD=="" here. Thus we won't activate the -# device below at force_activation, which is correct. +# device below at mpath_is_ready, which is correct. ENV{DM_COOKIE}!="?*", ENV{DM_ACTION}!="PATH_*", \ IMPORT{db}="DM_COLDPLUG_SUSPENDED", \ GOTO="force_activation"
@@ -84,25 +84,27 @@ ENV{DM_ACTION}=="PATH_FAILED|PATH_REINSTATED", \ LABEL="force_activation" +ENV{MPATH_DEVICE_READY}!="0", GOTO="mpath_is_ready" # Do not initiate scanning if no path is available, # otherwise there would be a hang or IO error on access. # We'd like to avoid this, especially within udev processing. -ENV{MPATH_DEVICE_READY}=="0", ENV{DM_NOSCAN}="1" - -# Skip all foreign rules if no path is available. +# This is communicated to later rules in DM_NOSCAN. +# Likewise, skip all foreign rules if no path is available. # Use DM_UDEV_DISABLE_OTHER_RULES_FLAG to communicate this -# to upper layers. The original value will be restored in a late -# udev rule. -ENV{MPATH_DEVICE_READY}=="0", \ - ENV{.MPATH_SAVE_DISABLE_OTHER_RULES_FLAG}="$env{DM_UDEV_DISABLE_OTHER_RULES_FLAG}", \ - ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1" +# to upper layers. With dm rules < v3, save the original value here; +# it will be restored in a late udev rule. +ENV{DM_UDEV_RULES_VSN}=="1|2", \ + ENV{.MPATH_SAVE_DISABLE_OTHER_RULES_FLAG}="$env{DM_UDEV_DISABLE_OTHER_RULES_FLAG}" +ENV{DM_NOSCAN}="1", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1" +GOTO="dont_activate" + +LABEL="mpath_is_ready" # If the device comes back online, set DM_ACTIVATION so that # upper layers do a rescan. If the device is currently suspended, # we have to postpone the activation until the next event. # In this case, we have to set MPATH_DEVICE_READY=0; otherwise, the # MPATH_UNCHANGED logic will cause later rules to skipped in the next event. -ENV{MPATH_DEVICE_READY}=="0", GOTO="dont_activate" ENV{.MPATH_DEVICE_READY_OLD}!="0", GOTO="dont_activate" ENV{DM_SUSPENDED}=="1", ENV{MPATH_DEVICE_READY}="0", GOTO="dont_activate"
Signature · 1 line
2.44.0
Re: [PATCH v2 04/11] 11-dm-mpath.rules: adapt MPATH_DEVICE_READY=0 logic to 10-dm.rules update
Quoted 5 lines · Martin Wilck
With the late patches for 10-dm.rules,
DM_UDEV_DISABLE_OTHER_RULES_FLAGisn't restored from the udev database any more, so we don't need to restore the flag to its original state before it is saved to the db.Signed-off-by Martin Wilck <[email protected]>
Quoted 56 lines
--- multipath/11-dm-mpath.rules.in | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)multipath/11-dm-mpath.rules.in +12
-10@@ -19,7 +19,7 @@ ACTION=="add", ENV{DM_ACTIVATION}=="1", ENV{DM_SUSPENDED}!="1", ENV{DISK_RO}!="1 # If this uevent didn't come from dm, don't try to update the # device state # Note that .MPATH_DEVICE_READY_OLD=="" here. Thus we won't activate the -# device below at force_activation, which is correct. +# device below at mpath_is_ready, which is correct. ENV{DM_COOKIE}!="?*", ENV{DM_ACTION}!="PATH_*", \ IMPORT{db}="DM_COLDPLUG_SUSPENDED", \ GOTO="force_activation"@@ -84,25 +84,27 @@ ENV{DM_ACTION}=="PATH_FAILED|PATH_REINSTATED", \ LABEL="force_activation" +ENV{MPATH_DEVICE_READY}!="0", GOTO="mpath_is_ready" # Do not initiate scanning if no path is available, # otherwise there would be a hang or IO error on access. # We'd like to avoid this, especially within udev processing. -ENV{MPATH_DEVICE_READY}=="0", ENV{DM_NOSCAN}="1" - -# Skip all foreign rules if no path is available. +# This is communicated to later rules in DM_NOSCAN. +# Likewise, skip all foreign rules if no path is available. # Use DM_UDEV_DISABLE_OTHER_RULES_FLAG to communicate this -# to upper layers. The original value will be restored in a late -# udev rule. -ENV{MPATH_DEVICE_READY}=="0", \ - ENV{.MPATH_SAVE_DISABLE_OTHER_RULES_FLAG}="$env{DM_UDEV_DISABLE_OTHER_RULES_FLAG}", \ - ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1" +# to upper layers. With dm rules < v3, save the original value here; +# it will be restored in a late udev rule. +ENV{DM_UDEV_RULES_VSN}=="1|2", \ + ENV{.MPATH_SAVE_DISABLE_OTHER_RULES_FLAG}="$env{DM_UDEV_DISABLE_OTHER_RULES_FLAG}" +ENV{DM_NOSCAN}="1", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1" +GOTO="dont_activate" + +LABEL="mpath_is_ready" # If the device comes back online, set DM_ACTIVATION so that # upper layers do a rescan. If the device is currently suspended, # we have to postpone the activation until the next event. # In this case, we have to set MPATH_DEVICE_READY=0; otherwise, the # MPATH_UNCHANGED logic will cause later rules to skipped in the next event. -ENV{MPATH_DEVICE_READY}=="0", GOTO="dont_activate" ENV{.MPATH_DEVICE_READY_OLD}!="0", GOTO="dont_activate" ENV{DM_SUSPENDED}=="1", ENV{MPATH_DEVICE_READY}="0", GOTO="dont_activate"Signature · 1 line
2.44.0
PATCH v2 5/11 11-dm-mpath.rules: adapt coldplug event handling ro 10-dm.rules update
In reply to Martin WilckWith late late patches for 10-dm.rules, DM_UDEV_DISABLE_OTHER_RULES_FLAG is never restored from the udev db. Thus we don't need to clear it here any more for coldplug events. Also, we must use .DM_SUSPENDED instead of DM_SUSPENDED as input flag with the v3 rule set (other occurences of DM_SUSPENDED will be replaced in a follow-up patch).
--- multipath/11-dm-mpath.rules.in | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
multipath/11-dm-mpath.rules.in +7 -2
@@ -9,12 +9,17 @@ ACTION=="add", ENV{DM_ACTIVATION}=="1", ENV{DM_SUSPENDED}=="1", \ PROGRAM="/bin/logger -t 11-dm-mpath.rules -p daemon.warning \"Coldplug event for suspended device\"", \ ENV{DM_COLDPLUG_SUSPENDED}="1", GOTO="scan_import" -# Coldplug event. DM_UDEV_DISABLE_OTHER_RULES_FLAG has been restored +# Coldplug event. Import previously set properties. +ACTION!="add", GOTO="mpath_coldplug_end" +ENV{DM_ACTIVATION}!="1", GOTO="mpath_coldplug_end" +ENV{DM_UDEV_RULES_VSN}!="1|2", ENV{.DM_SUSPENDED}!="1", GOTO="scan_import" +# With DM rules < v3, DM_UDEV_DISABLE_OTHER_RULES_FLAG has been restored # from DB in 10-dm.rules. If the device is not suspended, clear the flag. # This is safe for multipath where DM_UDEV_DISABLE_OTHER_RULES_FLAG is basically # equivalent to DM_SUSPENDED==1 || DISK_RO==1 -ACTION=="add", ENV{DM_ACTIVATION}=="1", ENV{DM_SUSPENDED}!="1", ENV{DISK_RO}!="1", \ +ENV{DM_UDEV_RULES_VSN}=="1|2", ENV{DM_SUSPENDED}!="1", ENV{DISK_RO}!="1", \ ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="", GOTO="scan_import" +LABEL="mpath_coldplug_end" # If this uevent didn't come from dm, don't try to update the # device state
Signature · 1 line
2.44.0
Re: [PATCH v2 05/11] 11-dm-mpath.rules: adapt coldplug event handling ro 10-dm.rules update
Quoted 7 lines · Martin Wilck
With late late patches for 10-dm.rules,
DM_UDEV_DISABLE_OTHER_RULES_FLAGis never restored from the udev db. Thus we don't need to clear it here any more for coldplug events. Also, we must use .DM_SUSPENDED instead ofDM_SUSPENDEDas input flag with the v3 rule set (other occurences ofDM_SUSPENDEDwill be replaced in a follow-up patch).Signed-off-by Martin Wilck <[email protected]>
Quoted 30 lines
--- multipath/11-dm-mpath.rules.in | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)multipath/11-dm-mpath.rules.in +7
-2@@ -9,12 +9,17 @@ ACTION=="add", ENV{DM_ACTIVATION}=="1", ENV{DM_SUSPENDED}=="1", \ PROGRAM="/bin/logger -t 11-dm-mpath.rules -p daemon.warning \"Coldplug event for suspended device\"", \ ENV{DM_COLDPLUG_SUSPENDED}="1", GOTO="scan_import" -# Coldplug event. DM_UDEV_DISABLE_OTHER_RULES_FLAG has been restored +# Coldplug event. Import previously set properties. +ACTION!="add", GOTO="mpath_coldplug_end" +ENV{DM_ACTIVATION}!="1", GOTO="mpath_coldplug_end" +ENV{DM_UDEV_RULES_VSN}!="1|2", ENV{.DM_SUSPENDED}!="1", GOTO="scan_import" +# With DM rules < v3, DM_UDEV_DISABLE_OTHER_RULES_FLAG has been restored # from DB in 10-dm.rules. If the device is not suspended, clear the flag. # This is safe for multipath where DM_UDEV_DISABLE_OTHER_RULES_FLAG is basically # equivalent to DM_SUSPENDED==1 || DISK_RO==1 -ACTION=="add", ENV{DM_ACTIVATION}=="1", ENV{DM_SUSPENDED}!="1", ENV{DISK_RO}!="1", \ +ENV{DM_UDEV_RULES_VSN}=="1|2", ENV{DM_SUSPENDED}!="1", ENV{DISK_RO}!="1", \ ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="", GOTO="scan_import" +LABEL="mpath_coldplug_end" # If this uevent didn't come from dm, don't try to update the # device stateSignature · 1 line
2.44.0
PATCH v2 6/11 11-dm-mpath.rules: don't import properties with new 13-dm-disk.rules
In reply to Martin WilckWith the late changes to 13-dm-disk.rules, we don't need to import any blkid-generated properties from the udev database, because they will be imported later.
Except for ID_FS_TYPE, this actually holds since lvm2 commit 94f77a4 ("udev:
import previous results of blkid when in suspended state"), included in lvm2 2.03.19, but we have no simple way to detect the version of the lvm2 rules.
--- multipath/11-dm-mpath.rules.in | 4 ++++ 1 file changed, 4 insertions(+)
multipath/11-dm-mpath.rules.in +4 -0
@@ -126,6 +126,10 @@ LABEL="scan_import" # have never been properly set. Don't import them. ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}!="1", GOTO="import_end" +# DM rules v3 will import missing properties on 13-dm-disk.rules. +# No need to do it here. +ENV{DM_UDEV_RULES_VSN}!="1|2", GOTO="import_end" + # Don't import the properties from db if we will run blkid later. ENV{DM_NOSCAN}!="1", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}!="1", GOTO="import_end"
Signature · 1 line
2.44.0
Re: [PATCH v2 06/11] 11-dm-mpath.rules: don't import properties with new 13-dm-disk.rules
Quoted 9 lines · Martin Wilck
With the late changes to 13-dm-disk.rules, we don't need to import any blkid-generated properties from the udev database, because they will be imported later.
Except for
ID_FS_TYPE, this actually holds since lvm2 commit 94f77a4 ("udev:
import previous results of blkid when in suspended state"), included in lvm2 2.03.19, but we have no simple way to detect the version of the lvm2 rules.Signed-off-by Martin Wilck <[email protected]>
Quoted 21 lines
--- multipath/11-dm-mpath.rules.in | 4 ++++ 1 file changed, 4 insertions(+)multipath/11-dm-mpath.rules.in +4
-0@@ -126,6 +126,10 @@ LABEL="scan_import" # have never been properly set. Don't import them. ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}!="1", GOTO="import_end" +# DM rules v3 will import missing properties on 13-dm-disk.rules. +# No need to do it here. +ENV{DM_UDEV_RULES_VSN}!="1|2", GOTO="import_end" + # Don't import the properties from db if we will run blkid later. ENV{DM_NOSCAN}!="1", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}!="1", GOTO="import_end"Signature · 1 line
2.44.0
PATCH v2 7/11 11-dm-mpath.rules: replace DM_SUSPENDED by .DM_SUSPENDED
In reply to Martin WilckWith the late changes to the device mapper rules, DM_SUSPENDED is not exported any more. Use .DM_SUSPENDED instead.
Note that although 11-dm-mpath.rules is not a part of lvm2, it can be considered as part of the device-mapper layer (everything before 13-dm-disk.rules can), and is thus allowed to use .DM_SUSPENDED. In practice .DM_SUSPENDED is equivalent to DM_UDEV_DISABLE_OTHER_RULES_FLAG for multipath devices, but using .DM_SUSPENDED here makes the intention more obvious.
--- multipath/11-dm-mpath.rules.in | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
multipath/11-dm-mpath.rules.in +8 -5
@@ -4,8 +4,11 @@ ENV{DM_UUID}!="mpath-?*", GOTO="mpath_end" IMPORT{db}="MPATH_DEVICE_READY" +# device-mapper rules v2 compatibility +ENV{.DM_SUSPENDED}!="?*", ENV{.DM_SUSPENDED}="$env{DM_SUSPENDED}" + # Coldplug event while device is suspended (e.g. during a reload) -ACTION=="add", ENV{DM_ACTIVATION}=="1", ENV{DM_SUSPENDED}=="1", \ +ACTION=="add", ENV{DM_ACTIVATION}=="1", ENV{.DM_SUSPENDED}=="1", \ PROGRAM="/bin/logger -t 11-dm-mpath.rules -p daemon.warning \"Coldplug event for suspended device\"", \ ENV{DM_COLDPLUG_SUSPENDED}="1", GOTO="scan_import"
@@ -17,7 +20,7 @@ ENV{DM_UDEV_RULES_VSN}!="1|2", ENV{.DM_SUSPENDED}!="1", GOTO="scan_import" # from DB in 10-dm.rules. If the device is not suspended, clear the flag. # This is safe for multipath where DM_UDEV_DISABLE_OTHER_RULES_FLAG is basically # equivalent to DM_SUSPENDED==1 || DISK_RO==1 -ENV{DM_UDEV_RULES_VSN}=="1|2", ENV{DM_SUSPENDED}!="1", ENV{DISK_RO}!="1", \ +ENV{DM_UDEV_RULES_VSN}=="1|2", ENV{.DM_SUSPENDED}!="1", ENV{DISK_RO}!="1", \ ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="", GOTO="scan_import" LABEL="mpath_coldplug_end"
@@ -68,7 +71,7 @@ LABEL="mpath_action" # Activation might have been partially skipped. Activate the device now, # i.e. disable the MPATH_UNCHANGED logic and set DM_ACTIVATION=1. IMPORT{db}="DM_COLDPLUG_SUSPENDED" -ENV{DM_COLDPLUG_SUSPENDED}=="1", ENV{DM_SUSPENDED}!="1", \ +ENV{DM_COLDPLUG_SUSPENDED}=="1", ENV{.DM_SUSPENDED}!="1", \ ENV{DM_ACTIVATION}="1", ENV{MPATH_UNCHANGED}="0", \ PROGRAM="/bin/logger -t 11-dm-mpath.rules -p daemon.notice \"Forcing activation of previously suspended device\"", \ GOTO="force_activation"
@@ -111,7 +114,7 @@ LABEL="mpath_is_ready" # In this case, we have to set MPATH_DEVICE_READY=0; otherwise, the # MPATH_UNCHANGED logic will cause later rules to skipped in the next event. ENV{.MPATH_DEVICE_READY_OLD}!="0", GOTO="dont_activate" -ENV{DM_SUSPENDED}=="1", ENV{MPATH_DEVICE_READY}="0", GOTO="dont_activate" +ENV{.DM_SUSPENDED}=="1", ENV{MPATH_DEVICE_READY}="0", GOTO="dont_activate" ENV{DM_ACTIVATION}="1", ENV{MPATH_UNCHANGED}="0" LABEL="dont_activate"
@@ -145,7 +148,7 @@ IMPORT{db}="ID_PART_GPT_AUTO_ROOT" LABEL="import_end" # Reset previous DM_COLDPLUG_SUSPENDED if activation happens now -ENV{DM_SUSPENDED}!="1", ENV{DM_ACTIVATION}=="1", ENV{DM_COLDPLUG_SUSPENDED}="" +ENV{.DM_SUSPENDED}!="1", ENV{DM_ACTIVATION}=="1", ENV{DM_COLDPLUG_SUSPENDED}="" # Multipath maps should take precedence over their members. ENV{DM_UDEV_LOW_PRIORITY_FLAG}!="1", OPTIONS+="link_priority=50"
Signature · 1 line
2.44.0
Re: [PATCH v2 07/11] 11-dm-mpath.rules: replace DM_SUSPENDED by .DM_SUSPENDED
Quoted 11 lines · Martin Wilck
With the late changes to the device mapper rules,
DM_SUSPENDEDis not exported any more. Use .DM_SUSPENDED instead.Note that although 11-dm-mpath.rules is not a part of lvm2, it can be considered as part of the device-mapper layer (everything before 13-dm-disk.rules can), and is thus allowed to use .DM_SUSPENDED. In practice .DM_SUSPENDED is equivalent to
DM_UDEV_DISABLE_OTHER_RULES_FLAGfor multipath devices, but using .DM_SUSPENDED here makes the intention more obvious.Signed-off-by Martin Wilck <[email protected]>
Quoted 59 lines
--- multipath/11-dm-mpath.rules.in | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)multipath/11-dm-mpath.rules.in +8
-5@@ -4,8 +4,11 @@ ENV{DM_UUID}!="mpath-?*", GOTO="mpath_end" IMPORT{db}="MPATH_DEVICE_READY" +# device-mapper rules v2 compatibility +ENV{.DM_SUSPENDED}!="?*", ENV{.DM_SUSPENDED}="$env{DM_SUSPENDED}" + # Coldplug event while device is suspended (e.g. during a reload) -ACTION=="add", ENV{DM_ACTIVATION}=="1", ENV{DM_SUSPENDED}=="1", \ +ACTION=="add", ENV{DM_ACTIVATION}=="1", ENV{.DM_SUSPENDED}=="1", \ PROGRAM="/bin/logger -t 11-dm-mpath.rules -p daemon.warning \"Coldplug event for suspended device\"", \ ENV{DM_COLDPLUG_SUSPENDED}="1", GOTO="scan_import"@@ -17,7 +20,7 @@ ENV{DM_UDEV_RULES_VSN}!="1|2", ENV{.DM_SUSPENDED}!="1", GOTO="scan_import" # from DB in 10-dm.rules. If the device is not suspended, clear the flag. # This is safe for multipath where DM_UDEV_DISABLE_OTHER_RULES_FLAG is basically # equivalent to DM_SUSPENDED==1 || DISK_RO==1 -ENV{DM_UDEV_RULES_VSN}=="1|2", ENV{DM_SUSPENDED}!="1", ENV{DISK_RO}!="1", \ +ENV{DM_UDEV_RULES_VSN}=="1|2", ENV{.DM_SUSPENDED}!="1", ENV{DISK_RO}!="1", \ ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="", GOTO="scan_import" LABEL="mpath_coldplug_end"@@ -68,7 +71,7 @@ LABEL="mpath_action" # Activation might have been partially skipped. Activate the device now, # i.e. disable the MPATH_UNCHANGED logic and set DM_ACTIVATION=1. IMPORT{db}="DM_COLDPLUG_SUSPENDED" -ENV{DM_COLDPLUG_SUSPENDED}=="1", ENV{DM_SUSPENDED}!="1", \ +ENV{DM_COLDPLUG_SUSPENDED}=="1", ENV{.DM_SUSPENDED}!="1", \ ENV{DM_ACTIVATION}="1", ENV{MPATH_UNCHANGED}="0", \ PROGRAM="/bin/logger -t 11-dm-mpath.rules -p daemon.notice \"Forcing activation of previously suspended device\"", \ GOTO="force_activation"@@ -111,7 +114,7 @@ LABEL="mpath_is_ready" # In this case, we have to set MPATH_DEVICE_READY=0; otherwise, the # MPATH_UNCHANGED logic will cause later rules to skipped in the next event. ENV{.MPATH_DEVICE_READY_OLD}!="0", GOTO="dont_activate" -ENV{DM_SUSPENDED}=="1", ENV{MPATH_DEVICE_READY}="0", GOTO="dont_activate" +ENV{.DM_SUSPENDED}=="1", ENV{MPATH_DEVICE_READY}="0", GOTO="dont_activate" ENV{DM_ACTIVATION}="1", ENV{MPATH_UNCHANGED}="0" LABEL="dont_activate"@@ -145,7 +148,7 @@ IMPORT{db}="ID_PART_GPT_AUTO_ROOT" LABEL="import_end" # Reset previous DM_COLDPLUG_SUSPENDED if activation happens now -ENV{DM_SUSPENDED}!="1", ENV{DM_ACTIVATION}=="1", ENV{DM_COLDPLUG_SUSPENDED}="" +ENV{.DM_SUSPENDED}!="1", ENV{DM_ACTIVATION}=="1", ENV{DM_COLDPLUG_SUSPENDED}="" # Multipath maps should take precedence over their members. ENV{DM_UDEV_LOW_PRIORITY_FLAG}!="1", OPTIONS+="link_priority=50"Signature · 1 line
2.44.0
PATCH v2 8/11 11-dm-mpath.rules: replace DM_NOSCAN by .DM_NOSCAN
In reply to Martin WilckWe don't need to restore DM_NOSCAN from the db anymore, so we can rename it to .DM_NOSCAN, making it a temporary property.
--- multipath/11-dm-mpath.rules.in | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
multipath/11-dm-mpath.rules.in +6 -3
@@ -96,14 +96,14 @@ ENV{MPATH_DEVICE_READY}!="0", GOTO="mpath_is_ready" # Do not initiate scanning if no path is available, # otherwise there would be a hang or IO error on access. # We'd like to avoid this, especially within udev processing. -# This is communicated to later rules in DM_NOSCAN. +# This is communicated to later rules in .DM_NOSCAN. # Likewise, skip all foreign rules if no path is available. # Use DM_UDEV_DISABLE_OTHER_RULES_FLAG to communicate this # to upper layers. With dm rules < v3, save the original value here; # it will be restored in a late udev rule. ENV{DM_UDEV_RULES_VSN}=="1|2", \ ENV{.MPATH_SAVE_DISABLE_OTHER_RULES_FLAG}="$env{DM_UDEV_DISABLE_OTHER_RULES_FLAG}" -ENV{DM_NOSCAN}="1", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1" +ENV{.DM_NOSCAN}="1", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1" GOTO="dont_activate" LABEL="mpath_is_ready"
@@ -134,7 +134,7 @@ ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}!="1", GOTO="import_end" ENV{DM_UDEV_RULES_VSN}!="1|2", GOTO="import_end" # Don't import the properties from db if we will run blkid later. -ENV{DM_NOSCAN}!="1", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}!="1", GOTO="import_end" +ENV{.DM_NOSCAN}!="1", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}!="1", GOTO="import_end" IMPORT{db}="ID_FS_TYPE" IMPORT{db}="ID_FS_USAGE"
@@ -150,6 +150,9 @@ LABEL="import_end" # Reset previous DM_COLDPLUG_SUSPENDED if activation happens now ENV{.DM_SUSPENDED}!="1", ENV{DM_ACTIVATION}=="1", ENV{DM_COLDPLUG_SUSPENDED}="" +# device-mapper rules v2 compatibility for 13-dm-disk.rules +ENV{DM_UDEV_RULES_VSN}!="3", ENV{DM_NOSCAN}="$env{.DM_NOSCAN}" + # Multipath maps should take precedence over their members. ENV{DM_UDEV_LOW_PRIORITY_FLAG}!="1", OPTIONS+="link_priority=50"
Signature · 1 line
2.44.0
Benjamin Marzinski
maintainerRe: [PATCH v2 08/11] 11-dm-mpath.rules: replace DM_NOSCAN by .DM_NOSCAN
Quoted 39 lines · Martin Wilck
We don't need to restore
DM_NOSCANfrom the db anymore, so we can rename it to .DM_NOSCAN, making it a temporary property.Signed-off-by Martin Wilck <[email protected]>--- multipath/11-dm-mpath.rules.in | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)multipath/11-dm-mpath.rules.in +3
-3@@ -96,14 +96,14 @@ ENV{MPATH_DEVICE_READY}!="0", GOTO="mpath_is_ready" # Do not initiate scanning if no path is available, # otherwise there would be a hang or IO error on access. # We'd like to avoid this, especially within udev processing. -# This is communicated to later rules in DM_NOSCAN. +# This is communicated to later rules in .DM_NOSCAN. # Likewise, skip all foreign rules if no path is available. # Use DM_UDEV_DISABLE_OTHER_RULES_FLAG to communicate this # to upper layers. With dm rules < v3, save the original value here; # it will be restored in a late udev rule. ENV{DM_UDEV_RULES_VSN}=="1|2", \ ENV{.MPATH_SAVE_DISABLE_OTHER_RULES_FLAG}="$env{DM_UDEV_DISABLE_OTHER_RULES_FLAG}" -ENV{DM_NOSCAN}="1", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1" +ENV{.DM_NOSCAN}="1", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1" GOTO="dont_activate" LABEL="mpath_is_ready"@@ -134,7 +134,7 @@ ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}!="1", GOTO="import_end" ENV{DM_UDEV_RULES_VSN}!="1|2", GOTO="import_end" # Don't import the properties from db if we will run blkid later. -ENV{DM_NOSCAN}!="1", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}!="1", GOTO="import_end" +ENV{.DM_NOSCAN}!="1", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}!="1", GOTO="import_end" IMPORT{db}="ID_FS_TYPE" IMPORT{db}="ID_FS_USAGE"
multipath/11-dm-mpath.rules.in LABEL="import_end" · line 155
Quoted 6 lines
multipath/11-dm-mpath.rules.in +3
-0@@ -150,6 +150,9 @@ LABEL="import_end" # Reset previous DM_COLDPLUG_SUSPENDED if activation happens now ENV{.DM_SUSPENDED}!="1", ENV{DM_ACTIVATION}=="1", ENV{DM_COLDPLUG_SUSPENDED}="" +# device-mapper rules v2 compatibility for 13-dm-disk.rules +ENV{DM_UDEV_RULES_VSN}!="3", ENV{DM_NOSCAN}="$env{.DM_NOSCAN}" +
You missed a DM_UDEV_RULES_VSN change here.
-Ben
Quoted 5 lines
multipath/11-dm-mpath.rules.in +0
-0# Multipath maps should take precedence over their members. ENV{DM_UDEV_LOW_PRIORITY_FLAG}!="1", OPTIONS+="link_priority=50"Signature · 1 line
2.44.0
Re: [PATCH v2 08/11] 11-dm-mpath.rules: replace DM_NOSCAN by .DM_NOSCAN
Quoted 6 lines · Benjamin Marzinski
multipath/11-dm-mpath.rules.in LABEL="import_end" · line 155
Quoted 4 lines
multipath/11-dm-mpath.rules.in +3
-0+# device-mapper rules v2 compatibility for 13-dm-disk.rules +ENV{DM_UDEV_RULES_VSN}!="3", ENV{DM_NOSCAN}="$env{.DM_NOSCAN}" +You missed a
DM_UDEV_RULES_VSNchange here.
Thanks!
Martin
PATCH v2 9/11 11-dm-mpath.rules: simplify PATH_FAILED case
In reply to Martin WilckThis combination of a GOTO and a simple rule can be combined into a single rule.
--- multipath/11-dm-mpath.rules.in | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
multipath/11-dm-mpath.rules.in +4 -8
@@ -56,14 +56,10 @@ PROGRAM=="@BINDIR@/multipath -U -v1 %k", GOTO="paths_ok" ENV{MPATH_DEVICE_READY}="0", GOTO="mpath_action" LABEL="paths_ok" -# Don't mark a device ready on a PATH_FAILED event. even if -# DM_NR_VALID_PATHS is greater than 0. Just keep the existing -# value -ENV{DM_ACTION}=="PATH_FAILED", GOTO="mpath_action" - -# This event is either a PATH_REINSTATED or a table reload where -# there are active paths. Mark the device ready -ENV{MPATH_DEVICE_READY}="1" +# For PATH_FAILED events, keep the existing value of MPATH_DEVICE_READY. +# If it's not PATH_FAILED, this event is either a PATH_REINSTATED or a +# table reload where there are active paths. Mark the device ready. +ENV{DM_ACTION}!="PATH_FAILED", ENV{MPATH_DEVICE_READY}="1" LABEL="mpath_action"
Signature · 1 line
2.44.0
PATCH v2 10/11 11-dm-mpath.rules: make label names more intuitive
In reply to Martin WilckThe labels "dont_activate" and "scan_import" denote the same code line. Remove "dont_activate". Improve two misleading label names.
Substitutions:
dont_activate -> scan_import
force_activation -> check_mpath_ready
mpath_action -> check_mpath_unchanged
--- multipath/11-dm-mpath.rules.in | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
multipath/11-dm-mpath.rules.in +11 -11
@@ -30,7 +30,7 @@ LABEL="mpath_coldplug_end" # device below at mpath_is_ready, which is correct. ENV{DM_COOKIE}!="?*", ENV{DM_ACTION}!="PATH_*", \ IMPORT{db}="DM_COLDPLUG_SUSPENDED", \ - GOTO="force_activation" + GOTO="check_mpath_ready" ENV{.MPATH_DEVICE_READY_OLD}="$env{MPATH_DEVICE_READY}"
@@ -38,13 +38,13 @@ ENV{.MPATH_DEVICE_READY_OLD}="$env{MPATH_DEVICE_READY}" # table with no active devices. If this happens, mark the # device not ready ENV{DM_SUBSYSTEM_UDEV_FLAG2}=="1", ENV{MPATH_DEVICE_READY}="0", \ - GOTO="mpath_action" + GOTO="check_mpath_unchanged" # If the last path has failed mark the device not ready # Note that DM_NR_VALID_PATHS is only set for PATH_FAILED|PATH_REINSTATED # events. # This may not be reliable, as events aren't necessarily received in order. -ENV{DM_NR_VALID_PATHS}=="0", ENV{MPATH_DEVICE_READY}="0", GOTO="mpath_action" +ENV{DM_NR_VALID_PATHS}=="0", ENV{MPATH_DEVICE_READY}="0", GOTO="check_mpath_unchanged" # Don't run multipath -U during "coldplug" after switching root, # because paths are just being added to the udev db.
@@ -53,7 +53,8 @@ ACTION=="add", ENV{.MPATH_DEVICE_READY_OLD}=="1", GOTO="paths_ok" # Check the map state directly with multipath -U. # This doesn't attempt I/O on the device. PROGRAM=="@BINDIR@/multipath -U -v1 %k", GOTO="paths_ok" -ENV{MPATH_DEVICE_READY}="0", GOTO="mpath_action" +ENV{MPATH_DEVICE_READY}="0", GOTO="check_mpath_unchanged" + LABEL="paths_ok" # For PATH_FAILED events, keep the existing value of MPATH_DEVICE_READY.
@@ -61,7 +62,7 @@ LABEL="paths_ok" # table reload where there are active paths. Mark the device ready. ENV{DM_ACTION}!="PATH_FAILED", ENV{MPATH_DEVICE_READY}="1" -LABEL="mpath_action" +LABEL="check_mpath_unchanged" # A previous coldplug event occurred while the device was suspended. # Activation might have been partially skipped. Activate the device now,
@@ -70,7 +71,7 @@ IMPORT{db}="DM_COLDPLUG_SUSPENDED" ENV{DM_COLDPLUG_SUSPENDED}=="1", ENV{.DM_SUSPENDED}!="1", \ ENV{DM_ACTIVATION}="1", ENV{MPATH_UNCHANGED}="0", \ PROGRAM="/bin/logger -t 11-dm-mpath.rules -p daemon.notice \"Forcing activation of previously suspended device\"", \ - GOTO="force_activation" + GOTO="check_mpath_ready" # DM_SUBSYSTEM_UDEV_FLAG0 is the "RELOAD" flag for multipath subsystem. # Drop the DM_ACTIVATION flag here as mpath reloads tables if any of its
@@ -86,7 +87,7 @@ ENV{DM_SUBSYSTEM_UDEV_FLAG0}=="1", \ ENV{DM_ACTION}=="PATH_FAILED|PATH_REINSTATED", \ ENV{DM_ACTIVATION}="0", ENV{MPATH_UNCHANGED}="1" -LABEL="force_activation" +LABEL="check_mpath_ready" ENV{MPATH_DEVICE_READY}!="0", GOTO="mpath_is_ready" # Do not initiate scanning if no path is available,
@@ -100,7 +101,7 @@ ENV{MPATH_DEVICE_READY}!="0", GOTO="mpath_is_ready" ENV{DM_UDEV_RULES_VSN}=="1|2", \ ENV{.MPATH_SAVE_DISABLE_OTHER_RULES_FLAG}="$env{DM_UDEV_DISABLE_OTHER_RULES_FLAG}" ENV{.DM_NOSCAN}="1", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1" -GOTO="dont_activate" +GOTO="scan_import" LABEL="mpath_is_ready"
@@ -109,11 +110,10 @@ LABEL="mpath_is_ready" # we have to postpone the activation until the next event. # In this case, we have to set MPATH_DEVICE_READY=0; otherwise, the # MPATH_UNCHANGED logic will cause later rules to skipped in the next event. -ENV{.MPATH_DEVICE_READY_OLD}!="0", GOTO="dont_activate" -ENV{.DM_SUSPENDED}=="1", ENV{MPATH_DEVICE_READY}="0", GOTO="dont_activate" +ENV{.MPATH_DEVICE_READY_OLD}!="0", GOTO="scan_import" +ENV{.DM_SUSPENDED}=="1", ENV{MPATH_DEVICE_READY}="0", GOTO="scan_import" ENV{DM_ACTIVATION}="1", ENV{MPATH_UNCHANGED}="0" -LABEL="dont_activate" # The code to check multipath state ends here. We need to set # properties and symlinks regardless whether the map is usable or
Signature · 1 line
2.44.0
PATCH v2 11/11 kpartx.rules: ignore DM_SUSPENDED
In reply to Martin WilckDM_SUSPENDED=1 implies DM_UDEV_DISABLE_OTHER_RULES_FLAG=1, no need to check it again. The DM_NOSCAN check needs to remain in order to keep compatibility with dm rules v2.
--- kpartx/kpartx.rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kpartx/kpartx.rules +1 -1
@@ -27,7 +27,7 @@ ENV{DM_SUBSYSTEM_UDEV_FLAG1}=="1", GOTO="mpath_kpartx_end" ENV{MPATH_UNCHANGED}=="1", GOTO="mpath_kpartx_end" # Don't run kpartx now if we know it will fail or hang. -ENV{DM_SUSPENDED}=="1", GOTO="mpath_kpartx_end" +# This is required for device mapper rules v2 compatibility. ENV{DM_NOSCAN}=="1", GOTO="mpath_kpartx_end" # Run kpartx
Signature · 1 line
2.44.0