Re: [linux-usb-devel] BUG when removing USB flash drive

2004-05-15 Thread Alan Stern
I took a look at scsi_host_cancel(), scsi_device_cancel(), and a few other routines. Three things stood out: When a host is removed, currently executing requests are aborted within the midlevel but the low-level driver is not informed of this. Presumably it shouldn't ca

Re: [linux-usb-devel] BUG when removing USB flash drive

2004-05-14 Thread Alberto Bertogli
On Fri, May 14, 2004 at 05:13:38PM -0400, Alan Stern wrote: > I'll work on a patch. Testing it won't be easy, though; it's hard to > prove that a race _isn't_ happening! I'm going to have to repeat this tests a few more times (in fact, I'll boot -mm2 in a couple of minutes to see if I can reprod

Re: [linux-usb-devel] BUG when removing USB flash drive

2004-05-14 Thread Alan Stern
On 14 May 2004, James Bottomley wrote: > The idea behind scsi_remove_host() was that it was going to be called > from the module_exit() routine. This means that the reference count on > the LLD has already dropped to zero and it's safe for removal. > > If you call scsi_remove_host() outside of t

Re: [linux-usb-devel] BUG when removing USB flash drive

2004-05-14 Thread James Bottomley
On Fri, 2004-05-14 at 14:33, Alan Stern wrote: > usb-storage checks the state of its kernel thread after calling > scsi_remove_host(), while preparing to kill the thread. This can only > be done while the thread is idle, not processing any queued commands or > error handler requests. The BUG in A

Re: [linux-usb-devel] BUG when removing USB flash drive

2004-05-14 Thread Alan Stern
On Fri, 14 May 2004, Mike Anderson wrote: > I was incorrect in my previous statement. Well we may hold a reference > count on the struct device passed into the scsi_add_host until all > references on the host instance are gone and there maybe a positive ref > count on the hostt module until all de

Re: [linux-usb-devel] BUG when removing USB flash drive

2004-05-14 Thread Mike Anderson
Alan Stern [EMAIL PROTECTED] wrote: > On Thu, 13 May 2004, Mike Anderson wrote: > > > The LLDD queuecommand should not be called after the return of > > scsi_remove_host (unless we have a bug). The LLDD should not free its > > resources until the release function is called on the struct device > >

Re: [linux-usb-devel] BUG when removing USB flash drive

2004-05-14 Thread Alan Stern
On Thu, 13 May 2004, Mike Anderson wrote: > The LLDD queuecommand should not be called after the return of > scsi_remove_host (unless we have a bug). The LLDD should not free its > resources until the release function is called on the struct device > passed in during the scsi_add_host call. Ah.

Re: [linux-usb-devel] BUG when removing USB flash drive

2004-05-13 Thread Mike Anderson
Alan Stern [EMAIL PROTECTED] wrote: > This BUG happened because the SCSI layer was still using the drive after > usb-storage had called scsi_remove_host(). In this case the scsi_remove_host is being called in a unexpected disconnect case. Any IOs in flight will be canceled in the mid-layer (i.e.,

Re: [linux-usb-devel] BUG when removing USB flash drive

2004-05-13 Thread Alan Stern
On Thu, 13 May 2004, Alberto Bertogli wrote: > Hi! > > I've just hit a bug after removing a Kingston USB flash drive. > > I have removed it several (probably more than 40) times today without > problems until now. I'm removing it while doing streaming write()s on > the device (using /dev/sda) be