diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2007-09-15 19:22:19 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2007-09-15 19:22:19 +0000 |
commit | 1048dee18994bd356dfb09463e60f9821548f834 (patch) | |
tree | 03c94ee72b9ce47147e46463c1f1eb079fdfa6b0 /sys/dev/usb/umass.c | |
parent | 288752b760425fddc6fe00d317697ef966764b4c (diff) |
Allow to pull out an usb stick with ffs filesystem while mounted
and a file is written onto the stick. Without these fixes the
machine panics or hangs.
The usb fix calls the callback when the stick is pulled out to free
the associated buffers. Otherwise we have busy buffers for ever
and the automatic unmount will panic.
The change in the scsi layer prevents passing down further dirty
buffers to usb after the stick has been deactivated.
In vfs the automatic unmount has moved from the function vgonel()
to vop_generic_revoke(). Both are called when the sd device's vnode
is removed. In vgonel() the VXLOCK is already held which can cause
a deadlock. So call dounmount() earlier.
ok krw@, I like this marco@, tested by ian@
Diffstat (limited to 'sys/dev/usb/umass.c')
-rw-r--r-- | sys/dev/usb/umass.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/sys/dev/usb/umass.c b/sys/dev/usb/umass.c index 294c7bdd1b8..0752071aeae 100644 --- a/sys/dev/usb/umass.c +++ b/sys/dev/usb/umass.c @@ -1,4 +1,4 @@ -/* $OpenBSD: umass.c,v 1.52 2007/06/14 10:11:16 mbalmer Exp $ */ +/* $OpenBSD: umass.c,v 1.53 2007/09/15 19:22:18 bluhm Exp $ */ /* $NetBSD: umass.c,v 1.116 2004/06/30 05:53:46 mycroft Exp $ */ /* @@ -669,6 +669,15 @@ umass_detach(struct device *self, int flags) /* Wait for processes to go away. */ usb_detach_wait(&sc->sc_dev); } + + /* Free the buffers via callback. */ + if (sc->transfer_state != TSTATE_IDLE && sc->transfer_priv) { + sc->transfer_state = TSTATE_IDLE; + sc->transfer_cb(sc, sc->transfer_priv, + sc->transfer_datalen, + STATUS_WIRE_FAILED); + sc->transfer_priv = NULL; + } splx(s); scbus = sc->bus; |