From 48188d7181f735d816e0dac73a7a121ecc667f9b Mon Sep 17 00:00:00 2001 From: Peter Rajnoha Date: Thu, 7 Mar 2024 09:48:49 +0100 Subject: [PATCH] udev: change action check from ACTION!="add|change" to ACTION=="remove" 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 "" to "/sys/.../uevent" file or by calling "udevadm trigger --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. --- udev/10-dm.rules.in | 2 +- udev/11-dm-lvm.rules.in | 2 +- udev/12-dm-permissions.rules | 2 +- udev/13-dm-disk.rules.in | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/udev/10-dm.rules.in b/udev/10-dm.rules.in index f8f823e5e..94c4140c0 100644 --- a/udev/10-dm.rules.in +++ b/udev/10-dm.rules.in @@ -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 diff --git a/udev/11-dm-lvm.rules.in b/udev/11-dm-lvm.rules.in index d0a563794..cfc022489 100644 --- a/udev/11-dm-lvm.rules.in +++ b/udev/11-dm-lvm.rules.in @@ -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" diff --git a/udev/12-dm-permissions.rules b/udev/12-dm-permissions.rules index 22a285f1e..9624ddc5e 100644 --- a/udev/12-dm-permissions.rules +++ b/udev/12-dm-permissions.rules @@ -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... diff --git a/udev/13-dm-disk.rules.in b/udev/13-dm-disk.rules.in index 7989871b0..496dd06c5 100644 --- a/udev/13-dm-disk.rules.in +++ b/udev/13-dm-disk.rules.in @@ -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"