detaching usb device without unmounting it

M. Warner Losh imp at bsdimp.com
Fri Jul 10 14:11:44 UTC 2009


In message: <permail-20090710090548f7e55a9d00003ae0-a_best01 at message-id.uni-muenster.de>
            Alexander Best <alexbestms at math.uni-muenster.de> writes:
: since the usb2 stack allows one to detach a mounted usb device without the
: kernel panic'ing

usb1 allowed that too.  the problem rarely was inside the usb stack
(although there were some problems).  The problem was at the higher
levels of cam, the buffer cache and the file system.  There were
changes scattered throughout the rest of the system to allow devices
to suddenly disappear.  All usb2 did was fix a few edge cases in usb.

: i'd like to know which steps are necessary to be taken after
: detaching a device? because i tried the following:
: 
: 1. attach device
: 2. mount device
: 3. detach device
: 
: when i tried to unmount the device i got the follwing error message:
: 
: g_vfs_done():label/usb[WRITE(offset=19456, length=4096)]error = 6

The proper action is limited to 'umount -f'.  You can't reattach it,
you can't really touch any files in the system (some cached files
might be ok), you certainly can't write to it.

: and the console got locked up (ctr+c didn't work). so i tried to reboot using
: ctrl+alt+del. however after the message: "All buffers synced" there was no
: reboot. so i had to do a hard reset. however after the reset freebsd fsck'ed
: my harddrives. so they didn't unmount properly.
: 
: should i have used `umount -f`? or just plug the device back in again? or
: isn't it possible to unmount a device that has already been detached?

You should have done an umount -f.  You can't plug it back in again
because we don't have support at the right levels (CAM(?), GEOM,
buffer cache, fs) to allow previously orphaned resources to be
reconnected to a new device.  The device was destroyed, and data was
destroyed with it...

Warner


More information about the freebsd-usb mailing list