Issues with addon-storage

David Zeuthen david at fubar.dk
Thu Dec 21 09:35:13 PST 2006


On Sun, 2006-12-17 at 12:48 +0100, Thomas Petazzoni wrote:
> However, when I unplug the USB key, it sometimes doesn't work:
> hald-addon-storage fails at opening /dev/sda, and loops forever trying
> to open /dev/sda every two seconds. However, this doesn't happen all
> the time: it sometimes work, sometimes not. The logs of hald
> --daemon=no --verbose=yes where the first unplug of the USB key
> triggered the problem are available at
> http://lolut.utbm.info/~thomas/hal.log. The message is:
> 
> [15395]: 11:55:59.179 [E] addon-storage.c:423: open failed
> for /dev/sda: No such file or directory
> 
> My understanding may be completely wrong, but I think it's something
> with udev removing the /dev/sda entry upon removal of the USB key.
> Sometimes, the /dev/sda entry is removed before hald-addon-storage had
> the time to open() it (and it that case, hald-addon-storage loops
> forever). Sometimes, the /dev/sda entry is removed after
> hald-addon-storage open()ed it, and in that case it works.
> 
> And of course, once hald is waiting for hald-addon-storage to exit or
> do something, it doesn't handle the other plugging/unplugging events.

What happens is that when you remove a USB key is this

 1. the kernel emits uevents to remove all the kobjects in the device
    chain, e.g.

    - usb device
     - usb interface
      - scsi host
       - scsi device
        - main block device
         - partition1
         - partition2
         - partition3
         - ....

 2. udev catches these, deletes the /dev-file and sends them on to hald

 3. hald receives the uevents and removes device objects. This includes
    killing the addons running for a device object.

You can check this using udevmonitor / lshal. 

My guess is that something is still mounted and that prevents the kernel
from emitting the uevents for device removal. Does hald receive the
uevents for device removal at all? Is something mounted?

> BTW, I made a quick look at the addon-storage.c code, and I don't
> understand why close(fd) is called when fd is certainly < 0. See
> attached patch (not compiled, not tested).

I committed Danny's reworked version of your patch. Thanks!

      David




More information about the hal mailing list