Skip to contentSkip to conversation

udev: adapt rules to systemd v247

PATCH Applied Mariusz Tkaczyk 2 participants 5 messages Jan 14, 2022 – Mar 31, 2022 MD RAID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 udev: adapt rules to systemd v247

New events have been added in kernel 4.14 ("bind" and "unbind"). Systemd maintainer suggests to modify "add|change" branches. This patches implements their suggestions. There is no issue yet because new event types are not used in md.

Please see systemd announcement for details[1].

[1] https://lists.freedesktop.org/archives/systemd-devel/2020-November/045646.html

---
 udev-md-raid-arrays.rules        | 2 +-
 udev-md-raid-assembly.rules      | 5 +++--
 udev-md-raid-safe-timeouts.rules | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)
udev-md-raid-arrays.rules +1 -1
index 13c9076e..2967ace1 100644
@@ -3,7 +3,7 @@
 SUBSYSTEM!="block", GOTO="md_end"
 
 # handle md arrays
-ACTION!="add|change", GOTO="md_end"
+ACTION=="remove", GOTO="md_end"
 KERNEL!="md*", GOTO="md_end"
 
 # partitions have no md/{array_state,metadata_version}, but should not
udev-md-raid-assembly.rules +3 -2
index d668cddd..39b4344b 100644
@@ -30,8 +30,9 @@ LABEL="md_inc"
 
 # remember you can limit what gets auto/incrementally assembled by
 # mdadm.conf(5)'s 'AUTO' and selectively whitelist using 'ARRAY'
-ACTION=="add|change", IMPORT{program}="BINDIR/mdadm --incremental --export $devnode --offroot $env{DEVLINKS}"
-ACTION=="add|change", ENV{MD_STARTED}=="*unsafe*", ENV{MD_FOREIGN}=="no", ENV{SYSTEMD_WANTS}+="mdadm-last-resort@$env{MD_DEVICE}.timer"
+ACTION!="remove", IMPORT{program}="BINDIR/mdadm --incremental --export $devnode --offroot $env{DEVLINKS}"
+ACTION!="remove", ENV{MD_STARTED}=="*unsafe*", ENV{MD_FOREIGN}=="no", ENV{SYSTEMD_WANTS}+="mdadm-last-resort@$env{MD_DEVICE}.timer"
+
 ACTION=="remove", ENV{ID_PATH}=="?*", RUN+="BINDIR/mdadm -If $name --path $env{ID_PATH}"
 ACTION=="remove", ENV{ID_PATH}!="?*", RUN+="BINDIR/mdadm -If $name"
 
udev-md-raid-safe-timeouts.rules +1 -1
index 12bdcaa8..2e185cee 100644
@@ -50,7 +50,7 @@ ENV{DEVTYPE}!="partition", GOTO="md_timeouts_end"
 
 IMPORT{program}="/sbin/mdadm --examine --export $devnode"
 
-ACTION=="add|change", \
+ACTION!="remove", \
   ENV{ID_FS_TYPE}=="linux_raid_member", \
   ENV{MD_LEVEL}=="raid[1-9]*", \
   TEST=="/sys/block/$parent/device/timeout", \
Signature · 1 line
2.26.2
#1 lore raw
Quoted 10 lines · Mariusz Tkaczyk

New events have been added in kernel 4.14 ("bind" and "unbind"). Systemd maintainer suggests to modify "add|change" branches. This patches implements their suggestions. There is no issue yet because new event types are not used in md.

Please see systemd announcement for details[1].

[1] https://lists.freedesktop.org/archives/systemd-devel/2020-November/045646.html

Hi Mariusz,

It looks fine to me, but it does raise the question how does this change affect anyone building mdadm running an older systemd since you're removing most of the add|change triggers in this patch?

Thanks,
Jes

Quoted 49 lines
---
 udev-md-raid-arrays.rules        | 2 +-
 udev-md-raid-assembly.rules      | 5 +++--
 udev-md-raid-safe-timeouts.rules | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)
udev-md-raid-arrays.rules +1 -1
index 13c9076e..2967ace1 100644
@@ -3,7 +3,7 @@
 SUBSYSTEM!="block", GOTO="md_end"
 
 # handle md arrays
-ACTION!="add|change", GOTO="md_end"
+ACTION=="remove", GOTO="md_end"
 KERNEL!="md*", GOTO="md_end"
 
 # partitions have no md/{array_state,metadata_version}, but should not
udev-md-raid-assembly.rules +3 -2
index d668cddd..39b4344b 100644
@@ -30,8 +30,9 @@ LABEL="md_inc"
 
 # remember you can limit what gets auto/incrementally assembled by
 # mdadm.conf(5)'s 'AUTO' and selectively whitelist using 'ARRAY'
-ACTION=="add|change", IMPORT{program}="BINDIR/mdadm --incremental --export $devnode --offroot $env{DEVLINKS}"
-ACTION=="add|change", ENV{MD_STARTED}=="*unsafe*", ENV{MD_FOREIGN}=="no", ENV{SYSTEMD_WANTS}+="mdadm-last-resort@$env{MD_DEVICE}.timer"
+ACTION!="remove", IMPORT{program}="BINDIR/mdadm --incremental --export $devnode --offroot $env{DEVLINKS}"
+ACTION!="remove", ENV{MD_STARTED}=="*unsafe*", ENV{MD_FOREIGN}=="no", ENV{SYSTEMD_WANTS}+="mdadm-last-resort@$env{MD_DEVICE}.timer"
+
 ACTION=="remove", ENV{ID_PATH}=="?*", RUN+="BINDIR/mdadm -If $name --path $env{ID_PATH}"
 ACTION=="remove", ENV{ID_PATH}!="?*", RUN+="BINDIR/mdadm -If $name"
 
udev-md-raid-safe-timeouts.rules +1 -1
index 12bdcaa8..2e185cee 100644
@@ -50,7 +50,7 @@ ENV{DEVTYPE}!="partition", GOTO="md_timeouts_end"
 
 IMPORT{program}="/sbin/mdadm --examine --export $devnode"
 
-ACTION=="add|change", \
+ACTION!="remove", \
   ENV{ID_FS_TYPE}=="linux_raid_member", \
   ENV{MD_LEVEL}=="raid[1-9]*", \
   TEST=="/sys/block/$parent/device/timeout", \
#2 lore raw
Quoted 11 lines · On Wed, 19 Jan 2022 08:22:14 -0500 Jes Sorensen <[email protected]> wrote:
Quoted 10 lines · Mariusz Tkaczyk

New events have been added in kernel 4.14 ("bind" and "unbind"). Systemd maintainer suggests to modify "add|change" branches. This patches implements their suggestions. There is no issue yet because new event types are not used in md.

Please see systemd announcement for details[1].

[1]
https://lists.freedesktop.org/archives/systemd-devel/2020-November/045646.html

Quoted 8 lines
Quoted 1 line

Hi Mariusz,

It looks fine to me, but it does raise the question how does this change affect anyone building mdadm running an older systemd since you're removing most of the add|change triggers in this patch?

Hi Jes,

Before 4.14 we had tree types of events:
add, change, remove

After 4.14 we have five types of events:
add, change, remove, bind, unbind

I just changed "add|change" to != "remove". Instead verifying positive cases, I excluded the negative one. The result is the same. I can't see any risk of regression here for older systemd.

Thanks,
Mariusz

#3 lore raw

Hi Coly,
Could you review?

Thanks,
Mariusz

Quoted 36 lines · On Thu, 20 Jan 2022 08:58:20 +0100 Mariusz Tkaczyk…
Quoted 11 lines · On Wed, 19 Jan 2022 08:22:14 -0500 Jes Sorensen <[email protected]> wrote:
Quoted 10 lines · Mariusz Tkaczyk

New events have been added in kernel 4.14 ("bind" and "unbind"). Systemd maintainer suggests to modify "add|change" branches. This patches implements their suggestions. There is no issue yet because new event types are not used in md.

Please see systemd announcement for details[1].

[1]
https://lists.freedesktop.org/archives/systemd-devel/2020-November/045646.html

Quoted 8 lines
Quoted 1 line

Hi Mariusz,

It looks fine to me, but it does raise the question how does this change affect anyone building mdadm running an older systemd since you're removing most of the add|change triggers in this patch?

Hi Jes,

Before 4.14 we had tree types of events:
add, change, remove

After 4.14 we have five types of events:
add, change, remove, bind, unbind

I just changed "add|change" to != "remove". Instead verifying positive cases, I excluded the negative one. The result is the same. I can't see any risk of regression here for older systemd.

Thanks,
Mariusz

Applied
#4 lore raw
In reply to Mariusz Tkaczyk
Quoted 10 lines · Mariusz Tkaczyk

New events have been added in kernel 4.14 ("bind" and "unbind"). Systemd maintainer suggests to modify "add|change" branches. This patches implements their suggestions. There is no issue yet because new event types are not used in md.

Please see systemd announcement for details[1].

[1] https://lists.freedesktop.org/archives/systemd-devel/2020-November/045646.html

Applied!

Thanks,
Jes