From: Mathieu Trudel-Lapierre Subject: Teardown LUKS cleartext device on slave forced removal Bug-Ubuntu: https://bugs.edge.launchpad.net/ubuntu/+source/cryptsetup/+bug/484429 Last-Update: 2010-09-22 In the event of the "forced" removal of a crypto device (e.g. simply pulled), use the luks_holder property since it is still available to figure out which underlying cleartext LUKS device to teardown, instead of scanning through all available devices (because the cleartext device already has had its properties cleaned up). Index: udisks/src/device.c =================================================================== --- udisks.orig/src/device.c 2010-09-22 15:29:55.064530022 -0400 +++ udisks/src/device.c 2010-09-22 15:29:57.984530000 -0400 @@ -11792,30 +11792,23 @@ if (device->priv->id_usage != NULL && strcmp (device->priv->id_usage, "crypto") == 0) { - GList *devices; - GList *l; + Device *d; /* look for cleartext device */ - devices = daemon_local_get_all_devices (device->priv->daemon); - for (l = devices; l != NULL; l = l->next) + d = daemon_local_find_by_object_path (device->priv->daemon, device->priv->luks_holder); + if (strcmp (d->priv->object_path, device->priv->luks_holder) == 0) { - Device *d = DEVICE (l->data); - if (d->priv->device_is_luks_cleartext && d->priv->luks_cleartext_slave != NULL - && strcmp (d->priv->luks_cleartext_slave, device->priv->object_path) == 0) + /* Check whether it is set up by us */ + if (d->priv->dm_name != NULL && g_str_has_prefix (d->priv->dm_name, "udisks-luks-uuid-")) { - /* Check whether it is set up by us */ - if (d->priv->dm_name != NULL && g_str_has_prefix (d->priv->dm_name, "udisks-luks-uuid-")) - { + g_print ("**** NOTE: Force luks teardown device %s (cleartext %s)\n", + device->priv->device_file, + d->priv->device_file); - g_print ("**** NOTE: Force luks teardown device %s (cleartext %s)\n", - device->priv->device_file, - d->priv->device_file); - - /* Gotcha */ - force_luks_teardown (device, d, callback, user_data); - goto pending; - } + /* Gotcha */ + force_luks_teardown (device, d, callback, user_data); + goto pending; } } }