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 Desktop
Packages, which is subscribed to udisks2 in Ubuntu.
https://bugs.launchpad.net/bugs/1460602

Title:
  Erasing disk failed: Error wiping newly created partition

Status in udisks:
  Confirmed
Status in udisks2 package in Ubuntu:
  Confirmed
Status in udisks2 package in Debian:
  Confirmed

Bug description:
  I tried to erase a normal 8GB USB stick on up to date Ubuntu 15.04.
  This dialog appeared:

  org.freedesktop.DBus.Python.GLib.Error: Traceback (most recent call last):
    File "/usr/lib/python3/dist-packages/dbus/service.py", line 707, in 
_message_cb
      retval = candidate_method(self, *args, **keywords)
    File "/usr/share/usb-creator/usb-creator-helper", line 287, in Format
      partition = table.call_create_partition_sync(0, size, '0x0c', '', 
no_options, None)
  GLib.Error: udisks-error-quark: 
GDBus.Error:org.freedesktop.UDisks2.Error.Failed: Error wiping newly created 
partition /dev/sdc1: Command-line `wipefs -a "/dev/sdc1"' exited with non-zero 
exit status 1: wipefs: error: /dev/sdc1: probing initialization failed: No such 
file or directory
   (0)

  ProblemType: Bug
  DistroRelease: Ubuntu 15.04
  Package: usb-creator-gtk 0.2.67ubuntu0.1
  ProcVersionSignature: Ubuntu 3.19.0-18.18-generic 3.19.6
  Uname: Linux 3.19.0-18-generic x86_64
  NonfreeKernelModules: nvidia
  ApportVersion: 2.17.2-0ubuntu1.1
  Architecture: amd64
  CurrentDesktop: X-Cinnamon
  Date: Mon Jun  1 13:20:30 2015
  EcryptfsInUse: Yes
  InstallationDate: Installed on 2015-02-12 (108 days ago)
  InstallationMedia: Ubuntu 14.10 "Utopic Unicorn" - Release amd64 (20141022.1)
  SourcePackage: usb-creator
  UDisksDump: Error: [Errno 2] No such file or directory: 'udisks'
  UpgradeStatus: Upgraded to vivid on 2015-05-12 (19 days ago)

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

-- 
Mailing list: https://launchpad.net/~desktop-packages
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~desktop-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to