ChangeSet 1.2000.6.6, 2004/10/20 16:10:49-07:00, [EMAIL PROTECTED]

[PATCH] USB Storage: Fix queuecommand() for disconnected devices

Following the recommendation of James Bottomley (of SCSI fame), this patch
changes the queuecommand() routine so that when a command is received for a
disconnected device, instead of accepting the command and then ignoring it,
we fail the command immediately with DID_NO_CONNECT.

This fixes a timeout-abort-oops sequence that would occur when the
higher-level drivers (mostly the CD driver) try to queue a SYNCHRONIZE
CACHE command during scsi_remove_host().


Signed-off-by: Alan Stern <[EMAIL PROTECTED]>
Signed-off-by: Matthew Dharm <[EMAIL PROTECTED]>
Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>


===== drivers/usb/storage/scsiglue.c 1.84 vs edited =====


 drivers/usb/storage/scsiglue.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)


diff -Nru a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
--- a/drivers/usb/storage/scsiglue.c    2004-10-22 16:15:38 -07:00
+++ b/drivers/usb/storage/scsiglue.c    2004-10-22 16:15:38 -07:00
@@ -175,7 +175,7 @@
        US_DEBUGP("%s called\n", __FUNCTION__);
        srb->host_scribble = (unsigned char *)us;
 
-       /* enqueue the command */
+       /* check for state-transition errors */
        if (us->sm_state != US_STATE_IDLE || us->srb != NULL) {
                printk(KERN_ERR USB_STORAGE "Error in %s: " 
                        "state = %d, us->srb = %p\n",
@@ -183,10 +183,17 @@
                return SCSI_MLQUEUE_HOST_BUSY;
        }
 
+       /* fail the command if we are disconnecting */
+       if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) {
+               US_DEBUGP("Fail command during disconnect\n");
+               srb->result = DID_NO_CONNECT << 16;
+               done(srb);
+               return 0;
+       }
+
+       /* enqueue the command and wake up the control thread */
        srb->scsi_done = done;
        us->srb = srb;
-
-       /* wake up the process task */
        up(&(us->sema));
 
        return 0;



-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to