Here's my understanding of this issue:

In src/udiskslinuxpartitiontable.c, handle_create_partition():

1- New partition is created by calling parted
2- udisks_linux_block_object_trigger_uevent() is called to trigger udev
3- Wait for partition to show up by using wait_for_partition()
4- Wipe new partition by calling wipefs
5- udisks_linux_block_object_trigger_uevent() is called to trigger udev

The problem arises because #2 and #5 aren't done synchronously. When
udev processes the device change request, it removes the newly created
partition device (ie: sdb1), and then adds it back again. This happens
in a race with #4, and results in wipefs being called while the device
is removed.

This issue can be solved in a few ways, from best to worst:

1- Create a sync version of udisks_linux_block_object_trigger_uevent() that 
waits until the device is actually handled in #2 and #5
2- Make sure there are no pending events in the udev queue after #2 and #5
3- Adding an artificial delay after #2 and #5 to wait until the device has 
settled down (some places in the code add a 
udisks_linux_block_object_reread_partition_table(), which I assume results in 
enough delay to not hit the race most of the time.)

I've tried removing #2 and #5 altogether, and that appeared to work
also, but then gnome-disks crashes because udev hasn't added the device
back fast enough after the wipefs.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1460602

Title:
  Erasing disk failed: Error wiping newly created partition

To manage notifications about this bug go to:
https://bugs.launchpad.net/udisks/+bug/1460602/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to