multipath udev rules changes for dm rules V3
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.
Comments welcome.
Martin Wilck (11):
11-dm-mpath.rules: don't set MPATH_DEVICE_READY=0 for suspended
devices
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 | 84 ++++++++++++++++++++-------------- 2 files changed, 50 insertions(+), 36 deletions(-)
Signature · 1 line
2.43.2
PATCH 1/11 11-dm-mpath.rules: don't set MPATH_DEVICE_READY=0 for suspended devices
MPATH_DEVICE_READY is an internal property, not to be consumed by later rules. It means that there are no usable paths. Being suspended is a different, independent property of a map.
Don't set MPATH_DEVICE_READY=0 for suspended devices.
--- multipath/11-dm-mpath.rules.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
multipath/11-dm-mpath.rules.in +1 -1
@@ -100,7 +100,7 @@ ENV{MPATH_DEVICE_READY}=="0", \ # we have to postpone the activation until 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" +ENV{DM_SUSPENDED}=="1", GOTO="dont_activate" ENV{DM_ACTIVATION}="1", ENV{MPATH_UNCHANGED}="0" LABEL="dont_activate"
Signature · 1 line
2.43.2
Benjamin Marzinski
maintainerRe: [PATCH 01/11] 11-dm-mpath.rules: don't set MPATH_DEVICE_READY=0 for suspended devices
Quoted 16 lines · Martin Wilck
MPATH_DEVICE_READYis an internal property, not to be consumed by later rules. It means that there are no usable paths. Being suspended is a different, independent property of a map.Don't set MPATH_DEVICE_READY=0 for suspended devices.
Signed-off-by Martin Wilck <[email protected]>--- multipath/11-dm-mpath.rules.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)multipath/11-dm-mpath.rules.in +0
-0
multipath/11-dm-mpath.rules.in ENV{MPATH_DEVICE_READY}=="0", \ · line 103
Quoted 5 lines
multipath/11-dm-mpath.rules.in +1
-1@@ -100,7 +100,7 @@ ENV{MPATH_DEVICE_READY}=="0", \ # we have to postpone the activation until 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" +ENV{DM_SUSPENDED}=="1", GOTO="dont_activate"
I need to clarify this one. I thought that the point of setting ENV{MPATH_DEVICE_READY} to "0" here was that ENV{.MPATH_DEVICE_READY_OLD} must be "0" and ENV{MPATH_DEVICE_READY} must be "1" here, so we want to set DM_ACTIVATE. Unfortunately, the device is suspended, so we want to postpone the activation till the next event, like the command above this codeblock says. To do that, we set ENV{MPATH_DEVICE_READY} back to "0", so that on the next event, ENV{.MPATH_DEVICE_READY_OLD} will be "0".
Is that not necessary for some reason? Perhaps because we're going to get an actual DM generated event when we resume, so DM_ACTIVATE will already be set when we get the next event where DM_SUSPENDED != "1". If that's the case we should probably change the comment over this code block.
-Ben
Quoted 5 lines
multipath/11-dm-mpath.rules.in +0
-0ENV{DM_ACTIVATION}="1", ENV{MPATH_UNCHANGED}="0" LABEL="dont_activate"Signature · 1 line
2.43.2
Re: [PATCH 01/11] 11-dm-mpath.rules: don't set MPATH_DEVICE_READY=0 for suspended devices
Quoted 37 lines · Benjamin Marzinski
Quoted 19 lines · Martin Wilck
MPATH_DEVICE_READYis an internal property, not to be consumed by later rules. It means that there are no usable paths. Being suspended
is a different, independent property of a map.Don't set MPATH_DEVICE_READY=0 for suspended devices.
Signed-off-by Martin Wilck <[email protected]>---
multipath/11-dm-mpath.rules.in | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)multipath/11-dm- renamed from multipath/11-dm-mpath.rules.in +0
-0mpath.rules.in
index d9585ab..3f23108 100644multipath/11-dm-mpath.rules.in +0
-0@@ -100,7 +100,7 @@ ENV{MPATH_DEVICE_READY}=="0", \ # we have to postpone the activation until the next event.Quoted 5 lines
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"
+ENV{DM_SUSPENDED}=="1", GOTO="dont_activate"I need to clarify this one. I thought that the point of setting ENV{MPATH_DEVICE_READY} to "0" here was that ENV{.MPATH_DEVICE_READY_OLD} must be "0" and ENV{MPATH_DEVICE_READY} must be "1" here, so we want to set
DM_ACTIVATE. Unfortunately, the device is suspended, so we want to postpone the activation till the next
event, like the command above this codeblock says. To do that, we set
ENV{MPATH_DEVICE_READY} back to "0", so that on the next event, ENV{.MPATH_DEVICE_READY_OLD} will be "0".
Quoted 5 lines
Is that not necessary for some reason? Perhaps because we're going to get an actual DM generated event when we resume, so
DM_ACTIVATEwill already be set when we get the next event whereDM_SUSPENDED!= "1". If that's the case we should probably change the comment over this block.
You are right. We must set ENV{MPATH_DEVICE_READY}="0" here to remember the state until the next event is received.
Thanks for catching this.
Martin
PATCH 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 mpath_is_ready, 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.43.2
Benjamin Marzinski
maintainerRe: [PATCH 02/11] 11-dm-mpath.rules: don't import DM_NOSCAN from udev db
Quoted 17 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]>--- multipath/11-dm-mpath.rules.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)multipath/11-dm-mpath.rules.in +0
-0
multipath/11-dm-mpath.rules.in ACTION=="add", ENV{DM_ACTIVATION}=="1", ENV{DM_SUSPENDED}!="1", ENV{DISK_RO}!="1 · line 22
Quoted 5 lines
multipath/11-dm-mpath.rules.in +2
-0@@ -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 mpath_is_ready, which is correct.
Do you mean "force_activation" instead of "mpath_is_ready"?
-Ben
Quoted 10 lines
multipath/11-dm-mpath.rules.in +2
-2ENV{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.43.2
Re: [PATCH 02/11] 11-dm-mpath.rules: don't import DM_NOSCAN from udev db
Quoted 19 lines · Benjamin Marzinski
Quoted 18 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]>--- multipath/11-dm-mpath.rules.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)multipath/11-dm-mpath.rules.in +0
-0@@ -18,9 +18,11 @@ ACTION=="add", ENV{DM_ACTIVATION}=="1", ENV{DM_SUSPENDED}!="1", ENV{DISK_RO}!="1
Quoted 6 lines
multipath/11-dm-mpath.rules.in ACTION=="add", ENV{DM_ACTIVATION}=="1", ENV{DM_SUSPENDED}!="1", ENV{DISK_RO}!="1 · line 22
Quoted 4 lines
multipath/11-dm-mpath.rules.in +2
-0# 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 mpath_is_ready, which is correct.Do you mean "
force_activation" instead of "mpath_is_ready"?
I see that this label is added two commits later. I don't have a problem with a comment being confusing for two commits, so if you don't feel like changing it,
Quoted 14 lines
-Ben
Quoted 10 lines
multipath/11-dm-mpath.rules.in +2
-2ENV{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.43.2
Re: [PATCH 02/11] 11-dm-mpath.rules: don't import DM_NOSCAN from udev db
Quoted 34 lines · Benjamin Marzinski
Quoted 17 lines · Benjamin Marzinski
Quoted 16 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]>---
multipath/11-dm-mpath.rules.in | 6 ++++--1 file changed, 4 insertions(+), 2 deletions(-)Quoted 15 lines
Quoted 9 lines
multipath/11-dm- renamed from multipath/11-dm-mpath.rules.in +0
-0mpath.rules.in
index 3f23108..11b5adf 100644multipath/11-dm-mpath.rules.in +0
-0@@ -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 theQuoted 4 lines
# device state +# Note that .MPATH_DEVICE_READY_OLD=="" here. Thus we won't activate the +# device below at mpath_is_ready, which is correct.Do you mean "
force_activation" instead of "mpath_is_ready"?
Quoted 4 lines
I see that this label is added two commits later. I don't have a problem
with a comment being confusing for two commits, so if you don't feel like changing it,
Good catch, thanks. A few too many rebases, I guess. I will fix it.
Martin
Quoted 19 lines
Reviewed-by Benjamin Marzinski <[email protected]>Quoted 15 lines
-Ben
Quoted 11 lines
ENV{DM_COOKIE}!="?*", ENV{DM_ACTION}!="PATH_*", \
multipath/11-dm-mpath.rules.in +0
-1- IMPORT{db}="DM_NOSCAN",IMPORT{db}="DM_COLDPLUG_SUSPENDED", \
multipath/11-dm-mpath.rules.in +2
-1- GOTO="scan_import" + IMPORT{db}="DM_COLDPLUG_SUSPENDED", \ + GOTO="force_activation"ENV{.MPATH_DEVICE_READY_OLD}="$env{MPATH_DEVICE_READY}"
Signature · 1 line
2.43.2
PATCH 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
@@ -124,7 +124,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.43.2
Re: [PATCH 03/11] 11-dm-mpath.rules: don't import ID_FS_VERSION from udev db
Quoted 4 lines · Martin Wilck
Use the same set of properties to import as 13-dm-disk.rules.
ID_FS_VERSIONisn't used in any udev rule I am aware of.Signed-off-by Martin Wilck <[email protected]>
Quoted 18 lines
--- multipath/11-dm-mpath.rules.in | 1 - 1 file changed, 1 deletion(-)multipath/11-dm-mpath.rules.in +0
-1@@ -124,7 +124,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.43.2
PATCH 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 | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
multipath/11-dm-mpath.rules.in +11 -9
@@ -84,23 +84,25 @@ 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}!="3", + 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. -ENV{MPATH_DEVICE_READY}=="0", GOTO="dont_activate" ENV{.MPATH_DEVICE_READY_OLD}!="0", GOTO="dont_activate" ENV{DM_SUSPENDED}=="1", GOTO="dont_activate"
Signature · 1 line
2.43.2
Benjamin Marzinski
maintainerRe: [PATCH 04/11] 11-dm-mpath.rules: adapt MPATH_DEVICE_READY=0 logic to 10-dm.rules update
Quoted 25 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]>--- multipath/11-dm-mpath.rules.in | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)multipath/11-dm-mpath.rules.in +2
-3@@ -84,23 +84,25 @@ 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.
multipath/11-dm-mpath.rules.in ENV{DM_ACTION}=="PATH_FAILED|PATH_REINSTATED", \ · line 96
Quoted 10 lines
multipath/11-dm-mpath.rules.in +4
-5+# 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}!="3",
Can't we do something like:
ENV{DM_UDEV_RULES_VSN}=="1|2",
instead, that wouldn't break on future version number bumps.
Quoted 15 lines
multipath/11-dm-mpath.rules.in +5
-1+ 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. -ENV{MPATH_DEVICE_READY}=="0", GOTO="dont_activate" ENV{.MPATH_DEVICE_READY_OLD}!="0", GOTO="dont_activate" ENV{DM_SUSPENDED}=="1", GOTO="dont_activate"Signature · 1 line
2.43.2
Re: [PATCH 04/11] 11-dm-mpath.rules: adapt MPATH_DEVICE_READY=0 logic to 10-dm.rules update
Quoted 10 lines · Benjamin Marzinski
Quoted 2 lines · Martin Wilck
+ENV{DM_UDEV_RULES_VSN}!="3",
Can't we do something like:
ENV{DM_UDEV_RULES_VSN}=="1|2",
instead, that wouldn't break on future version number bumps.
Excellent idea, thanks!
Martin
PATCH 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}=="3", 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}!="3", 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.43.2
Benjamin Marzinski
maintainerRe: [PATCH 05/11] 11-dm-mpath.rules: adapt coldplug event handling ro 10-dm.rules update
Quoted 20 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]>--- multipath/11-dm-mpath.rules.in | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)multipath/11-dm-mpath.rules.in +0
-1@@ -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
multipath/11-dm-mpath.rules.in ACTION=="add", ENV{DM_ACTIVATION}=="1", ENV{DM_SUSPENDED}=="1", \ · line 20
Quoted 10 lines
multipath/11-dm-mpath.rules.in +6
-1+# 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}=="3", 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}!="3", ENV{DM_SUSPENDED}!="1", ENV{DISK_RO}!="1", \
Again, I'd prefer ENV{DM_UDEV_RULES_VSN}="1|2"
Quoted 7 lines
multipath/11-dm-mpath.rules.in +1
-0ENV{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.43.2
PATCH 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
@@ -124,6 +124,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}=="3", 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.43.2
Benjamin Marzinski
maintainerRe: [PATCH 06/11] 11-dm-mpath.rules: don't import properties with new 13-dm-disk.rules
Quoted 18 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]>--- multipath/11-dm-mpath.rules.in | 4 ++++ 1 file changed, 4 insertions(+)multipath/11-dm-mpath.rules.in +0
-0
multipath/11-dm-mpath.rules.in LABEL="scan_import" · line 129
Quoted 6 lines
multipath/11-dm-mpath.rules.in +3
-0@@ -124,6 +124,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}=="3", GOTO="import_end"
Again, I'd rather
ENV{DM_UDEV_RULES_VSN}!="1|2"
Quoted 6 lines
multipath/11-dm-mpath.rules.in +1
-0+ # 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.43.2
PATCH 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}=="3", 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}!="3", ENV{DM_SUSPENDED}!="1", ENV{DISK_RO}!="1", \ +ENV{DM_UDEV_RULES_VSN}!="3", 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"
@@ -109,7 +112,7 @@ LABEL="mpath_is_ready" # upper layers do a rescan. If the device is currently suspended, # we have to postpone the activation until the next event. ENV{.MPATH_DEVICE_READY_OLD}!="0", GOTO="dont_activate" -ENV{DM_SUSPENDED}=="1", GOTO="dont_activate" +ENV{.DM_SUSPENDED}=="1", GOTO="dont_activate" ENV{DM_ACTIVATION}="1", ENV{MPATH_UNCHANGED}="0" LABEL="dont_activate"
@@ -143,7 +146,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.43.2
Benjamin Marzinski
maintainerRe: [PATCH 07/11] 11-dm-mpath.rules: replace DM_SUSPENDED by .DM_SUSPENDED
Quoted 42 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]>--- multipath/11-dm-mpath.rules.in | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)multipath/11-dm-mpath.rules.in +5
-2@@ -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}=="3", 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}!="3", ENV{DM_SUSPENDED}!="1", ENV{DISK_RO}!="1", \ +ENV{DM_UDEV_RULES_VSN}!="3", ENV{.DM_SUSPENDED}!="1", ENV{DISK_RO}!="1", \ ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="", GOTO="scan_import" LABEL="mpath_coldplug_end"
multipath/11-dm-mpath.rules.in LABEL="mpath_action" · line 74
Quoted 5 lines
multipath/11-dm-mpath.rules.in +1
-1@@ -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", \
When I reviewed patch 0001, I wondered if it was o.k. to not force DM_ACTIVATION to "1" if a device had previously been suspended when MPATH_DEVICE_READY switched to "1". I thought it might it might be o.k. because there would be another event when the device resumed, which would have DM_ACTIVATION set to "1". But if that's the case then we shouldn't need to worry about a device being suspended when a coldplug happens. We will get an event when the device resumes, and there's not much we can do until it gets resumed at any rate. So either patch 0001 is wrong or we can remove this DM_COLDPLUG_SUSPENDED forced activation code or I'm missing some important difference between the two.
-Ben
Quoted 23 lines
multipath/11-dm-mpath.rules.in +2
-2ENV{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"@@ -109,7 +112,7 @@ LABEL="mpath_is_ready" # upper layers do a rescan. If the device is currently suspended, # we have to postpone the activation until the next event. ENV{.MPATH_DEVICE_READY_OLD}!="0", GOTO="dont_activate" -ENV{DM_SUSPENDED}=="1", GOTO="dont_activate" +ENV{.DM_SUSPENDED}=="1", GOTO="dont_activate" ENV{DM_ACTIVATION}="1", ENV{MPATH_UNCHANGED}="0" LABEL="dont_activate"@@ -143,7 +146,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.43.2
Re: [PATCH 07/11] 11-dm-mpath.rules: replace DM_SUSPENDED by .DM_SUSPENDED
Quoted 65 lines · Benjamin Marzinski
Quoted 54 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]>---
multipath/11-dm-mpath.rules.in | 13 ++++++++-----1 file changed, 8 insertions(+), 5 deletions(-)multipath/11-dm- renamed from multipath/11-dm-mpath.rules.in +0
-0mpath.rules.in
index 8f22954..c4b5685 100644multipath/11-dm-mpath.rules.in +0
-0@@ -4,8 +4,11 @@ ENV{DM_UUID}!="mpath-?*", GOTO="mpath_end"
IMPORT{db}="MPATH_DEVICE_READY"multipath/11-dm-mpath.rules.in +3
-0+# 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)
multipath/11-dm-mpath.rules.in +1
-1-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"multipath/11-dm-mpath.rules.in +0
-0@@ -17,7 +20,7 @@ ENV{DM_UDEV_RULES_VSN}=="3",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}!="3", ENV{DM_SUSPENDED}!="1", ENV{DISK_RO}!="1", \ +ENV{DM_UDEV_RULES_VSN}!="3", ENV{.DM_SUSPENDED}!="1", ENV{DISK_RO}!="1", \ ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="", GOTO="scan_import" LABEL="mpath_coldplug_end"multipath/11-dm-mpath.rules.in +0
-0@@ -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"
multipath/11-dm-mpath.rules.in LABEL="mpath_action" · line 74
Quoted 2 lines
multipath/11-dm-mpath.rules.in +1
-1-ENV{DM_COLDPLUG_SUSPENDED}=="1", ENV{DM_SUSPENDED}!="1", \ +ENV{DM_COLDPLUG_SUSPENDED}=="1", ENV{.DM_SUSPENDED}!="1", \When I reviewed patch 0001, I wondered if it was o.k. to not force
DM_ACTIVATIONto "1" if a device had previously been suspended whenMPATH_DEVICE_READYswitched to "1". I thought it might it might be o.k.
because there would be another event when the device resumed, which would haveDM_ACTIVATIONset to "1". But if that's the case then we shouldn't need to worry about a device being suspended when a
Quoted 8 lines
coldplug
happens. We will get an event when the device resumes, and there's not
much we can do until it gets resumed at any rate. So either patch 0001
is wrong or we can remove thisDM_COLDPLUG_SUSPENDEDforced activation
code or I'm missing some important difference between the two.
I tried to explain this in 02bbc17 ("11-dm-mpath.rules: handle reloads during coldplug events"). But I just needed to recall the logic again myself, it's subtle.
We will indeed get another change event when the device is resumed. But because of our MPATH_UNCHANGED logic, we may see that the the properties of the device haven't changed, and unset DM_ACTIVATION. Thus follow-up rules won't get executed, neither in coldplug event itself (device suspended) nor in the follow-up change event (device unchanged). I hope this makes sense.
The problem that you pointed out for 0001 for this series is similar, but it handles a different case where the device switched from 0 to one usable path while the device was suspended. Patch 0001 of this series is really broken, and it breaks a patch that I'd just created a month ago, which is truly embarrassing. udev rules are confusing :-/
Regards
Martin
PATCH 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}!="3", 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"
@@ -132,7 +132,7 @@ ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}!="1", GOTO="import_end" ENV{DM_UDEV_RULES_VSN}=="3", 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"
@@ -148,6 +148,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.43.2
Benjamin Marzinski
maintainerRe: [PATCH 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}!="3", 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"@@ -132,7 +132,7 @@ ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}!="1", GOTO="import_end" ENV{DM_UDEV_RULES_VSN}=="3", 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 153
Quoted 6 lines
multipath/11-dm-mpath.rules.in +3
-0@@ -148,6 +148,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}" +
Again, I'd prefer
ENV{DM_UDEV_RULES_VSN}="1|2"
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.43.2
PATCH 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.43.2
Re: [PATCH 09/11] 11-dm-mpath.rules: simplify PATH_FAILED case
Quoted 4 lines · Martin Wilck
This combination of a GOTO and a simple rule can be combined into a single rule.
Signed-off-by Martin Wilck <[email protected]>
Quoted 29 lines
--- 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.43.2
PATCH 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,18 +101,17 @@ ENV{MPATH_DEVICE_READY}!="0", GOTO="mpath_is_ready" ENV{DM_UDEV_RULES_VSN}!="3", 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" # 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. -ENV{.MPATH_DEVICE_READY_OLD}!="0", GOTO="dont_activate" -ENV{.DM_SUSPENDED}=="1", GOTO="dont_activate" +ENV{.MPATH_DEVICE_READY_OLD}!="0", GOTO="scan_import" +ENV{.DM_SUSPENDED}=="1", 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.43.2
Re: [PATCH 10/11] 11-dm-mpath.rules: make label names more intuitive
Quoted 9 lines · Martin Wilck
The 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_unchangedSigned-off-by Martin Wilck <[email protected]>
Quoted 94 lines
--- 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,18 +101,17 @@ ENV{MPATH_DEVICE_READY}!="0", GOTO="mpath_is_ready" ENV{DM_UDEV_RULES_VSN}!="3", 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" # 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. -ENV{.MPATH_DEVICE_READY_OLD}!="0", GOTO="dont_activate" -ENV{.DM_SUSPENDED}=="1", GOTO="dont_activate" +ENV{.MPATH_DEVICE_READY_OLD}!="0", GOTO="scan_import" +ENV{.DM_SUSPENDED}=="1", 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 orSignature · 1 line
2.43.2
PATCH 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.43.2
Re: [PATCH 11/11] kpartx.rules: ignore DM_SUSPENDED
Quoted 5 lines · Martin Wilck
DM_SUSPENDED=1 implies DM_UDEV_DISABLE_OTHER_RULES_FLAG=1, no need to check it again. The
DM_NOSCANcheck needs to remain in order to keep compatibility with dm rules v2.Signed-off-by Martin Wilck <[email protected]>
Quoted 19 lines
--- 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 kpartxSignature · 1 line
2.43.2