From 4b0a8f860a11aab406336c8b6c4257015d336465 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Wed, 22 Jan 2014 13:29:50 +0200 Subject: [PATCH] Treat certain device mapper udev events as "remove"... ...instead of ignoring them. This matters when the flag is added in a "change" event later on in the life of a device. --- src/udiskslinuxprovider.c | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/src/udiskslinuxprovider.c b/src/udiskslinuxprovider.c index 0c247fe..fda76de 100644 --- a/src/udiskslinuxprovider.c +++ b/src/udiskslinuxprovider.c @@ -852,32 +852,28 @@ handle_block_uevent (UDisksLinuxProvider *provider, * * objects. Ensure that drive and mdraid objects are added before * and removed after block objects. + * + * We treat the uevent as "remove" 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). */ - if (g_strcmp0 (action, "remove") == 0) + + if (g_strcmp0 (action, "remove") == 0 + || g_udev_device_get_property_as_boolean (device->udev_device, "DM_UDEV_DISABLE_OTHER_RULES_FLAG")) { - handle_block_uevent_for_block (provider, action, device); - handle_block_uevent_for_drive (provider, action, device); - handle_block_uevent_for_mdraid (provider, action, device); + handle_block_uevent_for_block (provider, "remove", device); + handle_block_uevent_for_drive (provider, "remove", device); + handle_block_uevent_for_mdraid (provider, "remove", device); } 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