FS#6030 - [hal] Removal of usb device without unmount freezes hal's usb.

Attached to Project: Arch Linux
Opened by Bradley (beejayzed) - Monday, 18 December 2006, 02:37 GMT
Last edited by Aaron Griffin (phrakture) - Friday, 14 December 2007, 18:51 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Jan de Groot (JGC)
Architecture not specified
Severity Medium
Priority Normal
Reported Version 0.7.2 Gimmick
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

I think this is the same or a similar bug: http://bugs.archlinux.org/task/5582 , except I've found the problem has nothing to do with ivman.
When a sub storage device is plugged in, hal picks it up and ivman mounts it. If it is unmounted the unplugged, everything works fine.
If it is removed without being unmounted though, it is not removed from hal's database. It also remains in /etc/mtab and /proc/mounts. The /dev/sd* entry is removed.
When it is plugged back in, even though the e.g /dev/sda* entry is removed, a /dev/sdb* entry is made. The previous stale entry remains in hal's database (in this case /dev/sda).

I launched hald with --daemon=no --verbose=yes to see if anything interesting comes up.
Hald was started when the usb storage device was already plugged in. The entry for it is /dev/sdb. I mounted it using thunar, then unplugged it.
I have attached a file with the parts after:
06:31:59.573 [I] hald.c:619: Device probing completed
06:31:59.573 [I] hald_dbus.c:4074: entering

(application/octet-stream)    hald (7.5 KiB)
This task depends upon

Closed by  Aaron Griffin (phrakture)
Friday, 14 December 2007, 18:51 GMT
Reason for closing:  None
Additional comments about closing:  No response to status request
Comment by Jan de Groot (JGC) - Tuesday, 19 December 2006, 07:41 GMT
How should hal, or your kernel, be able to recover from such a bad action? How would your system continue to run if you hotplug your rootdevice for example?
Comment by Roman Kyrylych (Romashka) - Tuesday, 19 December 2006, 10:20 GMT
Hmm... but kernel do know about removing device, and udev removes /dev node. So I suppose there should be a way for hal to "unmount" (so it will be just removed from mtab etc. though it doesn't exist already, so it's not a real unmount) device when it disappears from /dev, but this is upstream issue of course.
Comment by Jan de Groot (JGC) - Tuesday, 19 December 2006, 10:32 GMT
Ok, run a test then:

- stop hal
- insert a USB stick (set the write-protect tab to be sure you don't wreck the contents)
- mount it
- go inside the mountpoint
- pull the stick out
- run "ls"
- if that works, try to cd out of the directory and umount the lost USB stick
- report what happens then

I guess you'll get a shitload of I/O errors and you're unable to umount it, because the kernel just lost a mountpoint.
Comment by Roman Kyrylych (Romashka) - Tuesday, 19 December 2006, 10:46 GMT
Yeah, I know that.
I'm just thinking of idea of making use of the fact that udev removes dev node when device is removed. :)
This is not related to this "bug" which IMHO can be closed as "Not a bug" (even because if HAL learns how to recover from such bad situations better - it's a mainstream issue, not distro-specific).
Comment by Bradley (beejayzed) - Thursday, 21 December 2006, 01:03 GMT
Well, just a note. The problem doesn't seem to be present in the ubuntu implementation of hal, although it is a different version (0.5.7.1).
Basically, removing a device without unmounting should produce the same enduser results as unmounting it first (except there may be data corruption).

JGC, I did your test. The results are attached.
Basically when it was removed the directory showed up as empty, and no errors came up from umount when it was unmounted.
I noticed dmesg errors came up when trying to ls the mounted directory after the device had been removed. They were:
FAT: Directory bread(block 493) failed
scsi 3:0:0:0: rejecting I/O to dead device
FAT: Directory bread(block 494) failed
scsi 3:0:0:0: rejecting I/O to dead device
(and that block xxx increased to 524)
(application/octet-stream)    mount (0.4 KiB)
Comment by Jan de Groot (JGC) - Thursday, 21 December 2006, 08:42 GMT
AFAIK hal uses some state file that it used to write to writable media. I don't know if it's still used, as it used to cause a hanging hal when an NFS share would die.
Comment by Jan de Groot (JGC) - Thursday, 17 May 2007, 14:19 GMT
Is this still an issue with hal 0.5.9? Hal uses /media/.hal-mtab to monitor what it had mounted now.

Loading...