Skip to content

Commit

Permalink
udev: change action check from ACTION!="add|change" to ACTION=="remove"
Browse files Browse the repository at this point in the history
For DM devices, the add/change/remove can appear as action for genuine
udev events.

However, there are more action types (bind, unbind, move, online, offline)
which never appear as actions for genuine DM udev events, but they can
still be synthesized (e.g. by writing "<action>" to "/sys/.../uevent" file
or by calling "udevadm trigger --action=<action>").

Let's also process these extra action types so that the udev-related content
is not lost completely, keeping all the symlinks and udev db entries just like
this was a synthetic udev event with "change" action.

Related to https://gitlab.com/lvmteam/lvm2/-/issues/4.
  • Loading branch information
prajnoha authored and Peter Rajnoha committed Mar 25, 2024
1 parent 71bac6f commit 48188d7
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion udev/10-dm.rules.in
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ KERNEL!="dm-[0-9]*", GOTO="dm_end"
# (e.g. /dev/mapper) are created in right time after a device has its table
# loaded and is properly resumed. For this reason, direct use of dm-X nodes
# is not recommended.
ACTION!="add|change", GOTO="dm_end"
ACTION=="remove", GOTO="dm_end"

# Decode udev control flags and set environment variables appropriately.
# These flags are encoded in DM_COOKIE variable that was introduced in
Expand Down
2 changes: 1 addition & 1 deletion udev/11-dm-lvm.rules.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# DM_LV_LAYER - logical volume layer (blank if not set)

# "add" event is processed on coldplug only!
ACTION!="add|change", GOTO="lvm_end"
ACTION=="remove", GOTO="lvm_end"
ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="lvm_end"
ENV{DM_UUID}!="LVM-?*", GOTO="lvm_end"

Expand Down
2 changes: 1 addition & 1 deletion udev/12-dm-permissions.rules
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# DM_LV_LAYER - logical volume layer (not set if LVM device not present)

# "add" event is processed on coldplug only!
ACTION!="add|change", GOTO="dm_end"
ACTION=="remove", GOTO="dm_end"
ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="dm_end"

# A few demonstrational examples...
Expand Down
2 changes: 1 addition & 1 deletion udev/13-dm-disk.rules.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# suspended.

# "add" event is processed on coldplug only!
ACTION!="add|change", GOTO="dm_end"
ACTION=="remove", GOTO="dm_end"
ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="dm_end"
ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}=="1", GOTO="dm_end"

Expand Down

0 comments on commit 48188d7

Please sign in to comment.