From ec98a736923898ef6b8e74fb0651d38f4abf8acd Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 17 Jan 2014 10:48:40 +0200 Subject: [PATCH] Don't look at DM_UDEV_DISABLE_OTHER_RULES_FLAG. Instead, set UDISKS_IGNORE for internal LVM2 logical volumes via udev rules. Looking at DM_UDEV_DISABLE_OTHER_RULES_FLAG is not a good way to filter out unwanted device mapper happenings. For example, a pool for thinly provisioned logical volumes starts out as a regular logical volume without DM_UDEV_DISABLE_OTHER_RULES_FLAG set, and UDisks2 creates a D-Bus object for it. Later on, the udev node does get DM_UDEV_DISABLE_OTHER_RULES_FLAG set, but UDisks2 ignores this event and the D-Bus object stays around incorrectly. Another example are thinly provisioned logical volumes themselves. They always have DM_UDEV_DISABLE_OTHER_RULES_FLAG set, and thus UDisks2 never creates a D-Bus object for them. --- data/80-udisks2.rules | 3 +++ data/Makefile.am | 1 + data/lvm2-is-internal-lv | 6 ++++++ src/udiskslinuxprovider.c | 20 +++----------------- 4 files changed, 13 insertions(+), 17 deletions(-) create mode 100644 data/lvm2-is-internal-lv diff --git a/data/80-udisks2.rules b/data/80-udisks2.rules index ed093ee..0e9e5de 100644 --- a/data/80-udisks2.rules +++ b/data/80-udisks2.rules @@ -138,6 +138,9 @@ ENV{ID_VENDOR}=="Sony", ENV{ID_MODEL}=="PRS*Launcher", ENV{UDISKS_IGNORE}="1" # non-Linux software KERNEL=="sr*", ENV{ID_VENDOR}=="SanDisk", ENV{ID_MODEL}=="Cruzer", ENV{ID_FS_LABEL}=="U3_System", ENV{UDISKS_IGNORE}="1" +# Internal LVM2 logical volumes. +ENV{DM_VG_NAME}!="", ENV{DM_LV_NAME}!="", PROGRAM=="lvm2-is-internal-lv", ENV{UDISKS_IGNORE}="1" + # Content created using isohybrid (typically used on CDs and USB # sticks for bootable media) is a bit special insofar that the # interesting content is on a DOS partition with type 0x00 ... which diff --git a/data/Makefile.am b/data/Makefile.am index 0921698..4260aee 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -27,6 +27,7 @@ endif udevrulesdir = $(udevdir)/rules.d udevrules_DATA = 80-udisks2.rules +udev_SCRIPTS = lvm2-is-internal-lv polkitdir = $(datadir)/polkit-1/actions polkit_in_files = org.freedesktop.udisks2.policy.in diff --git a/data/lvm2-is-internal-lv b/data/lvm2-is-internal-lv new file mode 100644 index 0000000..3e47104 --- /dev/null +++ b/data/lvm2-is-internal-lv @@ -0,0 +1,6 @@ +#! /bin/sh + +# A device for a logical volume is internal when it does not have a +# symlink of the form /dev//. + +! expr " $DEVLINKS " : ".* /dev/$DM_VG_NAME/$DM_LV_NAME .*" >/dev/null diff --git a/src/udiskslinuxprovider.c b/src/udiskslinuxprovider.c index 0c247fe..9360ef9 100644 --- a/src/udiskslinuxprovider.c +++ b/src/udiskslinuxprovider.c @@ -861,23 +861,9 @@ handle_block_uevent (UDisksLinuxProvider *provider, } else { - if (g_udev_device_get_property_as_boolean (device->udev_device, "DM_UDEV_DISABLE_OTHER_RULES_FLAG")) - { - /* Ignore the uevent if the device-mapper layer requests - * that other rules ignore this uevent - * - * It's somewhat nasty to do this but it avoids all kinds of - * race-conditions caused by the design of device-mapper - * (such as temporary-cryptsetup nodes and cleartext devices - * without ID_FS properties properly set). - */ - } - else - { - handle_block_uevent_for_mdraid (provider, action, device); - handle_block_uevent_for_drive (provider, action, device); - handle_block_uevent_for_block (provider, action, device); - } + handle_block_uevent_for_mdraid (provider, action, device); + handle_block_uevent_for_drive (provider, action, device); + handle_block_uevent_for_block (provider, action, device); } if (g_strcmp0 (action, "add") != 0) -- 1.8.4.2