Re: Buffer I/O error after s2ram with usb storage persistance

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Le Fri, 18 Apr 2014 14:29:46 -0400,
Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> a écrit :

> On Fri, 18 Apr 2014, Matthieu CASTET wrote:
>  
> > "echo mem > /sys/power/state; cat /dev/sdx > /dev/null" works.
> 
> I guess this works because the initial open of /dev/sdx swallows the 
> media-changed notification.
Ok

> 
> > > The device reported a "Not-ready to ready change" because the power was
> > > lost and then restored.  The SCSI layer interprets this as meaning that
> > > the media was changed, even though USB keys don't have changeable media
> > > -- evidently your key tells the computer that it does.
> > 
> > yes, I tested with differents usb key and all of them report removable   
> > (1
> > in /sys/devices/pci0000:00/*/usb*/*/*/host*/target*/*/block/sdx/removable).
> 
> > > Since the SCSI layer thinks the media was changed, it has no choice but 
> > > to fail the read request.
> > ok.
> > 
> > I suppose the scsi layer can't ignore "Not-ready to ready change" event
> > at resume time ?
> 
> But that event doesn't happen at resume time.  It happens later, when
> the "cat" program issues its next read request.
Yes, but we can ignore the first "Not-ready to ready change" event
after resume.

In fact after reset, we call usb_stor_reset_resume that do a
scsi_report_bus_reset.
This will set the flag expecting_cc_ua in scsi layer and the scsi layer
will ignore the first unit attention.

But the commit dfcf7775815504d13a1d273073810058caf84b9d change the
logic and we don't ignore unit attention if "sshdr.asc == 0x28 &&
sshdr.ascq == 0x00" ("Not-ready to ready").

> In any case, the SCSI people will probably argue that ignoring such 
> events would not be safe.  And if it's not safe to ignore those events 
> during normal operation then it's not safe to ignore them at resume 
> time.
> 
> If you want to discuss the matter any further, you should post to the 
> linux-scsi mailing list.  There's not much we can do about it at the 
> USB level -- although perhaps we could turn off the erroneous 
> "removable" indicator.
Thanks,

I will continue the discution on linux-scsi ML.

Matthieu CASTET


[1]
commit dfcf7775815504d13a1d273073810058caf84b9d
Author: TARUISI Hiroaki <taruishi.hiroak@xxxxxxxxxxxxxx>
Date:   Thu Aug 11 20:25:20 2011 +0900

    [SCSI] Fix out of spec CD-ROM problem with media change
    
    Some CD-ROMs fail to report a media change correctly.  The specific
    one for this patch simply fails to respond to commands, then gives a
    UNIT ATTENTION after being reset which returns ASC/ASCQ 28/00.  This
    is out of spec behaviour, but add a check in the eat CC/UA on reset
    path to catch this case so the CD-ROM will function somewhat properly.
    
    [jejb: fixed up white space and accepted without signoff]
    Signed-off-by: James Bottomley <JBottomley@xxxxxxxxxxxxx>

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index a4b9cdb..dc6131e 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -293,8 +293,16 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
                 * so that we can deal with it there.
                 */
                if (scmd->device->expecting_cc_ua) {
-                       scmd->device->expecting_cc_ua = 0;
-                       return NEEDS_RETRY;
+                       /*
+                        * Because some device does not queue unit
+                        * attentions correctly, we carefully check
+                        * additional sense code and qualifier so as
+                        * not to squash media change unit attention.
+                        */
+                       if (sshdr.asc != 0x28 || sshdr.ascq != 0x00) {
+                               scmd->device->expecting_cc_ua = 0;
+                               return NEEDS_RETRY;
+                       }
                }
                /*
                 * if the device is in the process of becoming ready, we
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux