All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: Re: Re: BUG in kernel: Wrong Handling of USB HDD’s in scsiglue(slave_configure) and scsi/sd(sd_read_cache_type)
@ 2011-10-04 14:10   ` Alan Stern
  0 siblings, 0 replies; 15+ messages in thread
From: Alan Stern @ 2011-10-04 14:10 UTC (permalink / raw)
  To: Amit Sahrawat
  Cc: James Bottomley, Douglas Gilbert, linux-usb, linux-scsi,
	linux-kernel, linux-fsdevel, Christoph Hellwig

On Tue, 4 Oct 2011, Amit Sahrawat wrote:

> Not able to get tools which can show the Caching Information when
> connected USB device to Windows 7(Except one option which allows for
> optimizing Performance by enabling/disabling Cache - But that option
> is available for all the Mass storage device) - Please let me know if
> there is option to view this.

I have no idea.

> So, I have collected USB analyzer logs for Device after connected to
> Windows 7.  Please find the attached logs.

It would be more informative if your logs did not show the initial
connection, but did show what happens when you write a small file to
the drive and then go through the "Safely Remove Hardware" procedure.

The real question is whether or not Windows sends a SYNCHRONIZE CACHE 
command to the drive.

Alan Stern


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Re: Re: BUG in kernel: Wrong Handling of USB HDD’s in scsiglue(slave_configure) and scsi/sd(sd_read_cache_type)
@ 2011-10-04 14:10   ` Alan Stern
  0 siblings, 0 replies; 15+ messages in thread
From: Alan Stern @ 2011-10-04 14:10 UTC (permalink / raw)
  To: Amit Sahrawat
  Cc: James Bottomley, Douglas Gilbert,
	linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-scsi-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA, Christoph Hellwig

On Tue, 4 Oct 2011, Amit Sahrawat wrote:

> Not able to get tools which can show the Caching Information when
> connected USB device to Windows 7(Except one option which allows for
> optimizing Performance by enabling/disabling Cache - But that option
> is available for all the Mass storage device) - Please let me know if
> there is option to view this.

I have no idea.

> So, I have collected USB analyzer logs for Device after connected to
> Windows 7.  Please find the attached logs.

It would be more informative if your logs did not show the initial
connection, but did show what happens when you write a small file to
the drive and then go through the "Safely Remove Hardware" procedure.

The real question is whether or not Windows sends a SYNCHRONIZE CACHE 
command to the drive.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Re: Re: BUG in kernel: Wrong Handling of USB HDD’s in scsiglue(slave_configure) and scsi/sd(sd_read_cache_type)
@ 2011-10-04 14:10   ` Alan Stern
  0 siblings, 0 replies; 15+ messages in thread
From: Alan Stern @ 2011-10-04 14:10 UTC (permalink / raw)
  To: Amit Sahrawat
  Cc: James Bottomley, Douglas Gilbert,
	linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-scsi-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA, Christoph Hellwig

On Tue, 4 Oct 2011, Amit Sahrawat wrote:

> Not able to get tools which can show the Caching Information when
> connected USB device to Windows 7(Except one option which allows for
> optimizing Performance by enabling/disabling Cache - But that option
> is available for all the Mass storage device) - Please let me know if
> there is option to view this.

I have no idea.

> So, I have collected USB analyzer logs for Device after connected to
> Windows 7.  Please find the attached logs.

It would be more informative if your logs did not show the initial
connection, but did show what happens when you write a small file to
the drive and then go through the "Safely Remove Hardware" procedure.

The real question is whether or not Windows sends a SYNCHRONIZE CACHE 
command to the drive.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Re: Re: BUG in kernel: Wrong Handling of USB HDD’s in scsiglue(slave_configure) and scsi/sd(sd_read_cache_type)
  2011-10-04 14:10   ` Alan Stern
  (?)
  (?)
@ 2011-10-04 15:34   ` Amit Sahrawat
       [not found]     ` <CADDb1s3sPxpfNi-OD=QvVT+JWO9kUeTAmb8ZGyN0YCuBKWd4rg@mail.gmail.com>
  -1 siblings, 1 reply; 15+ messages in thread
From: Amit Sahrawat @ 2011-10-04 15:34 UTC (permalink / raw)
  To: Alan Stern
  Cc: James Bottomley, Douglas Gilbert, linux-usb, linux-scsi,
	linux-kernel, linux-fsdevel, Christoph Hellwig

On Tue, Oct 4, 2011 at 7:40 PM, Alan Stern <stern@rowland.harvard.edu> wrote:
> On Tue, 4 Oct 2011, Amit Sahrawat wrote:
>
>> Not able to get tools which can show the Caching Information when
>> connected USB device to Windows 7(Except one option which allows for
>> optimizing Performance by enabling/disabling Cache - But that option
>> is available for all the Mass storage device) - Please let me know if
>> there is option to view this.
>
> I have no idea.
>
>> So, I have collected USB analyzer logs for Device after connected to
>> Windows 7.  Please find the attached logs.
>
> It would be more informative if your logs did not show the initial
> connection, but did show what happens when you write a small file to
> the drive and then go through the "Safely Remove Hardware" procedure.
>
> The real question is whether or not Windows sends a SYNCHRONIZE CACHE
> command to the drive.
ok, I will try this out and provide the results tomorrow early morning.
>
> Alan Stern
>
>
Thanks & Regards,
Amit Sahrawat

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Re: Re: Re: BUG in kernel: Wrong Handling of USB HDD’s in scsiglue(slave_configure) and scsi/sd(sd_read_cache_ =?windows-1252?Q?type=29
       [not found]     ` <CADDb1s3sPxpfNi-OD=QvVT+JWO9kUeTAmb8ZGyN0YCuBKWd4rg@mail.gmail.com>
@ 2011-10-05 14:17         ` Alan Stern
  2011-10-05 16:59       ` Re: Re: BUG in kernel: Wrong Handling of USB HDD’s in scsiglue(slave_configure) and scsi/sd(sd_read_cache_type) Amit Sahrawat
  1 sibling, 0 replies; 15+ messages in thread
From: Alan Stern @ 2011-10-05 14:17 UTC (permalink / raw)
  To: Amit Sahrawat
  Cc: James Bottomley, Douglas Gilbert, linux-usb, linux-scsi,
	linux-kernel, linux-fsdevel, Christoph Hellwig

On Wed, 5 Oct 2011, Amit Sahrawat wrote:

> Hi,
> 
> In order to verify the SYNC_CACHE command being passed.
> First I checked on the USB HDD(Seagate - Free Agent) which is gettind
> properly identified on linux. I performed - copy of a file and then
> did 'Safely Remove Hardware" - this resulted in SYNC_CACHE command
> being passed - All logs are captured for this.
> 
> Then, for the same Hard Disk - I checked for the behaviour on Windows.
> There is no SYNC CACHE command being passed in this case.
> 
> Again, checked for a different hard disk(Seagate) - which has cache
> but not shown in Linux. In that case also, there is no SYNC CACHE
> command.
> 
> Please find the logs for the '3' cases attached.

This is a little disappointing.  If Windows doesn't use the SYNCHRONIZE 
CACHE command, it's quite likely that some USB drives will crash when 
they receive it.

This strongly suggests that we should not change the current code.

Alan Stern


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Re: Re: Re: BUG in kernel: Wrong Handling of USB HDD’s in scsiglue(slave_configure) and scsi/sd(sd_read_cache_ =?windows-1252?Q?type=29
@ 2011-10-05 14:17         ` Alan Stern
  0 siblings, 0 replies; 15+ messages in thread
From: Alan Stern @ 2011-10-05 14:17 UTC (permalink / raw)
  To: Amit Sahrawat
  Cc: James Bottomley, Douglas Gilbert, linux-usb, linux-scsi,
	linux-kernel, linux-fsdevel, Christoph Hellwig

On Wed, 5 Oct 2011, Amit Sahrawat wrote:

> Hi,
> 
> In order to verify the SYNC_CACHE command being passed.
> First I checked on the USB HDD(Seagate - Free Agent) which is gettind
> properly identified on linux. I performed - copy of a file and then
> did 'Safely Remove Hardware" - this resulted in SYNC_CACHE command
> being passed - All logs are captured for this.
> 
> Then, for the same Hard Disk - I checked for the behaviour on Windows.
> There is no SYNC CACHE command being passed in this case.
> 
> Again, checked for a different hard disk(Seagate) - which has cache
> but not shown in Linux. In that case also, there is no SYNC CACHE
> command.
> 
> Please find the logs for the '3' cases attached.

This is a little disappointing.  If Windows doesn't use the SYNCHRONIZE 
CACHE command, it's quite likely that some USB drives will crash when 
they receive it.

This strongly suggests that we should not change the current code.

Alan Stern

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Re: Re: Re: BUG in kernel: Wrong Handling of USB HDD’s in scsiglue(slave_configure) and scsi/sd(sd_read_cache_ =?windows-1252?Q?type=29
  2011-10-05 14:17         ` Alan Stern
  (?)
@ 2011-10-05 15:17         ` James Bottomley
  -1 siblings, 0 replies; 15+ messages in thread
From: James Bottomley @ 2011-10-05 15:17 UTC (permalink / raw)
  To: Alan Stern
  Cc: Amit Sahrawat, Douglas Gilbert, linux-usb, linux-scsi,
	linux-kernel, linux-fsdevel, Christoph Hellwig

On Wed, 2011-10-05 at 10:17 -0400, Alan Stern wrote:
> On Wed, 5 Oct 2011, Amit Sahrawat wrote:
> 
> > Hi,
> > 
> > In order to verify the SYNC_CACHE command being passed.
> > First I checked on the USB HDD(Seagate - Free Agent) which is gettind
> > properly identified on linux. I performed - copy of a file and then
> > did 'Safely Remove Hardware" - this resulted in SYNC_CACHE command
> > being passed - All logs are captured for this.
> > 
> > Then, for the same Hard Disk - I checked for the behaviour on Windows.
> > There is no SYNC CACHE command being passed in this case.
> > 
> > Again, checked for a different hard disk(Seagate) - which has cache
> > but not shown in Linux. In that case also, there is no SYNC CACHE
> > command.
> > 
> > Please find the logs for the '3' cases attached.
> 
> This is a little disappointing.  If Windows doesn't use the SYNCHRONIZE 
> CACHE command, it's quite likely that some USB drives will crash when 
> they receive it.
> 
> This strongly suggests that we should not change the current code.

I agree ... it means they go by the SCSI mode pages too, so we'll be no
worse than they are.  Plus we don't risk upsetting the rest of the USB
device universe.

James



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Re: Re: BUG in kernel: Wrong Handling of USB HDD’s in scsiglue(slave_configure) and scsi/sd(sd_read_cache_type)
       [not found]     ` <CADDb1s3sPxpfNi-OD=QvVT+JWO9kUeTAmb8ZGyN0YCuBKWd4rg@mail.gmail.com>
  2011-10-05 14:17         ` Alan Stern
@ 2011-10-05 16:59       ` Amit Sahrawat
  2011-10-05 17:24         ` James Bottomley
  1 sibling, 1 reply; 15+ messages in thread
From: Amit Sahrawat @ 2011-10-05 16:59 UTC (permalink / raw)
  To: Alan Stern
  Cc: James Bottomley, Douglas Gilbert, linux-usb, linux-scsi,
	linux-kernel, linux-fsdevel, Christoph Hellwig

Hi All,
Can anyone suggest what is the way ahead to detect the presence of
Write Cache in these kind of USB HDD and proceed accordingly by
assigning proper flushing method.
Please share some opinions on this.

Thanks & Regards,
Amit Sahrawat

On Wed, Oct 5, 2011 at 3:05 PM, Amit Sahrawat <amit.sahrawat83@gmail.com> wrote:
> Hi,
>
> In order to verify the SYNC_CACHE command being passed.
> First I checked on the USB HDD(Seagate - Free Agent) which is gettind
> properly identified on linux. I performed - copy of a file and then
> did 'Safely Remove Hardware" - this resulted in SYNC_CACHE command
> being passed - All logs are captured for this.
>
> Then, for the same Hard Disk - I checked for the behaviour on Windows.
> There is no SYNC CACHE command being passed in this case.
>
> Again, checked for a different hard disk(Seagate) - which has cache
> but not shown in Linux. In that case also, there is no SYNC CACHE
> command.
>
> Please find the logs for the '3' cases attached.
>
> Thanks & Regards,
> Amit Sahrawat
>
> On Tue, Oct 4, 2011 at 9:04 PM, Amit Sahrawat <amit.sahrawat83@gmail.com> wrote:
>> On Tue, Oct 4, 2011 at 7:40 PM, Alan Stern <stern@rowland.harvard.edu> wrote:
>>> On Tue, 4 Oct 2011, Amit Sahrawat wrote:
>>>
>>>> Not able to get tools which can show the Caching Information when
>>>> connected USB device to Windows 7(Except one option which allows for
>>>> optimizing Performance by enabling/disabling Cache - But that option
>>>> is available for all the Mass storage device) - Please let me know if
>>>> there is option to view this.
>>>
>>> I have no idea.
>>>
>>>> So, I have collected USB analyzer logs for Device after connected to
>>>> Windows 7.  Please find the attached logs.
>>>
>>> It would be more informative if your logs did not show the initial
>>> connection, but did show what happens when you write a small file to
>>> the drive and then go through the "Safely Remove Hardware" procedure.
>>>
>>> The real question is whether or not Windows sends a SYNCHRONIZE CACHE
>>> command to the drive.
>> ok, I will try this out and provide the results tomorrow early morning.
>>>
>>> Alan Stern
>>>
>>>
>> Thanks & Regards,
>> Amit Sahrawat
>>
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Re: Re: BUG in kernel: Wrong Handling of USB HDD’s in scsiglue(slave_configure) and scsi/sd(sd_read_cache_type)
  2011-10-05 16:59       ` Re: Re: BUG in kernel: Wrong Handling of USB HDD’s in scsiglue(slave_configure) and scsi/sd(sd_read_cache_type) Amit Sahrawat
@ 2011-10-05 17:24         ` James Bottomley
  2011-10-05 19:51           ` Amit Sahrawat
  0 siblings, 1 reply; 15+ messages in thread
From: James Bottomley @ 2011-10-05 17:24 UTC (permalink / raw)
  To: Amit Sahrawat
  Cc: Alan Stern, Douglas Gilbert, linux-usb, linux-scsi, linux-kernel,
	linux-fsdevel, Christoph Hellwig

On Wed, 2011-10-05 at 22:29 +0530, Amit Sahrawat wrote:
> Can anyone suggest what is the way ahead to detect the presence of
> Write Cache in these kind of USB HDD and proceed accordingly by
> assigning proper flushing method.
> Please share some opinions on this.

We're a bit out of ideas.  We've already established that we do exactly
what windows does in this situation, which is usually what we aim for.
Realistically, if the disks lie how do we know when not to believe them?

The best we could probably offer is an interface to turn on the WCE bit
in software (technically, you can do this today
in /scsi/class/scsi_disk/<disk>/cache_type, it's just that it will try
to commit the change as a MODE_SELECT which will presumably fail).

James



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Re: Re: BUG in kernel: Wrong Handling of USB HDD’s in scsiglue(slave_configure) and scsi/sd(sd_read_cache_type)
  2011-10-05 17:24         ` James Bottomley
@ 2011-10-05 19:51           ` Amit Sahrawat
  2011-10-05 20:08             ` James Bottomley
  0 siblings, 1 reply; 15+ messages in thread
From: Amit Sahrawat @ 2011-10-05 19:51 UTC (permalink / raw)
  To: James Bottomley
  Cc: Alan Stern, Douglas Gilbert, linux-usb, linux-scsi, linux-kernel,
	linux-fsdevel, Christoph Hellwig

On Wed, Oct 5, 2011 at 10:54 PM, James Bottomley
<James.Bottomley@hansenpartnership.com> wrote:
> On Wed, 2011-10-05 at 22:29 +0530, Amit Sahrawat wrote:
>> Can anyone suggest what is the way ahead to detect the presence of
>> Write Cache in these kind of USB HDD and proceed accordingly by
>> assigning proper flushing method.
>> Please share some opinions on this.
>
> We're a bit out of ideas.  We've already established that we do exactly
> what windows does in this situation, which is usually what we aim for.
> Realistically, if the disks lie how do we know when not to believe them?
I never knew this could turn out to be an issue with such history. But
atleast debugging helped in diagnosis.
>
> The best we could probably offer is an interface to turn on the WCE bit
> in software (technically, you can do this today
> in /scsi/class/scsi_disk/<disk>/cache_type, it's just that it will try
> to commit the change as a MODE_SELECT which will presumably fail).
Thanks James, is this related with SCSI command MODE_SELECT? and this
is to be passed when there is some failure?
or simply doing an "echo <value>" to
/scsi/class/scsi_disk/<disk>/cache_type? can you please elaborate a
little
>
> James
>
Thanks & Regards,
Amit Sahrawat

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Re: Re: BUG in kernel: Wrong Handling of USB HDD’s in scsiglue(slave_configure) and scsi/sd(sd_read_cache_type)
  2011-10-05 19:51           ` Amit Sahrawat
@ 2011-10-05 20:08             ` James Bottomley
  2011-10-07  5:09                 ` Amit Sahrawat
  0 siblings, 1 reply; 15+ messages in thread
From: James Bottomley @ 2011-10-05 20:08 UTC (permalink / raw)
  To: Amit Sahrawat
  Cc: Alan Stern, Douglas Gilbert, linux-usb, linux-scsi, linux-kernel,
	linux-fsdevel, Christoph Hellwig

On Thu, 2011-10-06 at 01:21 +0530, Amit Sahrawat wrote:
> > The best we could probably offer is an interface to turn on the WCE bit
> > in software (technically, you can do this today
> > in /scsi/class/scsi_disk/<disk>/cache_type, it's just that it will try
> > to commit the change as a MODE_SELECT which will presumably fail).
> Thanks James, is this related with SCSI command MODE_SELECT? and this
> is to be passed when there is some failure?
> or simply doing an "echo <value>" to
> /scsi/class/scsi_disk/<disk>/cache_type? can you please elaborate a
> little

You tell me since you have the device.  What that echo does is that it
does try to make the change permanent with a mode select ... that likely
won't work and the cache change only takes if the revalidated disk says
the write back has been enabled (which I really think it won't).  So I
think you need an additional software bit to flip for the case where the
device lies.

James



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Re: Re: BUG in kernel: Wrong Handling of USB HDD’s in scsiglue(slave_configure) and scsi/sd(sd_read_cache_type)
  2011-10-05 20:08             ` James Bottomley
@ 2011-10-07  5:09                 ` Amit Sahrawat
  0 siblings, 0 replies; 15+ messages in thread
From: Amit Sahrawat @ 2011-10-07  5:09 UTC (permalink / raw)
  To: James Bottomley
  Cc: Alan Stern, Douglas Gilbert, linux-usb, linux-scsi, linux-kernel,
	linux-fsdevel, Christoph Hellwig

Trying to set the cache type as "write back" through "echo "write
back" > /sys/class/scsi_disk/<disk>/cache_type" does not work.
Few logs :
#> usb 2-1.4: new high speed USB device using ehci-sdp and address 5
usb 2-1.4: New USB device found, idVendor=152d, idProduct=2339
usb 2-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=5
usb 2-1.4: Product: USB to ATA/ATAPI Bridge
usb 2-1.4: Manufacturer: JMicron
usb 2-1.4: SerialNumber: 3446184AA01C
scsi1 : usb-storage 2-1.4:1.0
scsi 1:0:0:0: Direct-Access     SAMSUNG  HM501IX               PQ: 0 ANSI: 2 CCS
sd 1:0:0:0: [sda] 976773168 512-byte logical blocks: (500 GB/465 GiB)
sd 1:0:0:0: [sda] Write Protect is off
sd 1:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't
support DPO or FUA
 sda:

#> echo "write back" > /sys/class/scsi_disk/1\:0\:0\:0/cache_type
sd 1:0:0:0: [sda] Sense Key : 0x5 [current]
sd 1:0:0:0: [sda] ASC=0x20 ASCQ=0x0


#> usb 2-1.4: new high speed USB device using ehci-sdp and address 4
usb 2-1.4: New USB device found, idVendor=0bc2, idProduct=2300
usb 2-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 2-1.4: Product: Portable
usb 2-1.4: Manufacturer: Seagate
usb 2-1.4: SerialNumber: 2GHW02GR
scsi0 : usb-storage 2-1.4:1.0

#>
#> scsi 0:0:0:0: Direct-Access     Seagate  Portable         0130 PQ: 0 ANSI: 4
sd 0:0:0:0: [sda] 488397168 512-byte logical blocks: (250 GB/232 GiB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] No Caching mode page present
sd 0:0:0:0: [sda] Assuming drive cache: write through
sd 0:0:0:0: [sda] No Caching mode page present
sd 0:0:0:0: [sda] Assuming drive cache: write through
 sda: sda1 sda2 sda3 sda4
sd 0:0:0:0: [sda] No Caching mode page present
sd 0:0:0:0: [sda] Assuming drive cache: write through
sd 0:0:0:0: [sda] Attached SCSI disk

#> echo "write back" > /sys/class/scsi_disk/0\:0\:0\:0/cache_type
sd 0:0:0:0: [sda] No Caching mode page present
sd 0:0:0:0: [sda] Assuming drive cache: write through
#>


#> usb 2-1.4: new high speed USB device using ehci-sdp and address 7
usb 2-1.4: New USB device found, idVendor=1058, idProduct=070a
usb 2-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 2-1.4: Product: My Passport 070A
usb 2-1.4: Manufacturer: Western Digital
usb 2-1.4: SerialNumber: 575832314132304534373635
scsi3 : usb-storage 2-1.4:1.0
scsi 3:0:0:0: Direct-Access     WD       My Passport 070A 1032 PQ: 0 ANSI: 4
scsi 3:0:0:1: CD-ROM            WD       Virtual CD 070A  1032 PQ: 0 ANSI: 4
scsi 3:0:0:2: Enclosure         WD       SES Device       1032 PQ: 0 ANSI: 4
sd 3:0:0:0: [sda] 623769600 512-byte logical blocks: (319 GB/297 GiB)
sd 3:0:0:0: [sda] Write Protect is off
sd 3:0:0:0: [sda] No Caching mode page present
sd 3:0:0:0: [sda] Assuming drive cache: write through
sd 3:0:0:0: [sda] No Caching mode page present
sd 3:0:0:0: [sda] Assuming drive cache: write through
 sda:
sd 3:0:0:0: [sda] No Caching mode page present
sd 3:0:0:0: [sda] Assuming drive cache: write through
sd 3:0:0:0: [sda] Attached SCSI disk

#> cat /sys/class/scsi_disk/3\:0\:0\:0/cache_type
write through
#> echo "write back" > /sys/class/scsi_disk/3\:0\:0\:0/cache_type
#>
#> echo "write back" > /sys/class/scsi_disk/3\:0\:0\:0/cache_type
#>
#>
#> cat /sys/class/scsi_disk/3\:0\:0\:0/cache_type
write through

Regards,
Amit Sahrawat

On Thu, Oct 6, 2011 at 1:38 AM, James Bottomley
<James.Bottomley@hansenpartnership.com> wrote:
> On Thu, 2011-10-06 at 01:21 +0530, Amit Sahrawat wrote:
>> > The best we could probably offer is an interface to turn on the WCE bit
>> > in software (technically, you can do this today
>> > in /scsi/class/scsi_disk/<disk>/cache_type, it's just that it will try
>> > to commit the change as a MODE_SELECT which will presumably fail).
>> Thanks James, is this related with SCSI command MODE_SELECT? and this
>> is to be passed when there is some failure?
>> or simply doing an "echo <value>" to
>> /scsi/class/scsi_disk/<disk>/cache_type? can you please elaborate a
>> little
>
> You tell me since you have the device.  What that echo does is that it
> does try to make the change permanent with a mode select ... that likely
> won't work and the cache change only takes if the revalidated disk says
> the write back has been enabled (which I really think it won't).  So I
> think you need an additional software bit to flip for the case where the
> device lies.
>
> James
>
>
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Re: Re: BUG in kernel: Wrong Handling of USB HDD’s in scsiglue(slave_configure) and scsi/sd(sd_read_cache_type)
@ 2011-10-07  5:09                 ` Amit Sahrawat
  0 siblings, 0 replies; 15+ messages in thread
From: Amit Sahrawat @ 2011-10-07  5:09 UTC (permalink / raw)
  To: James Bottomley
  Cc: Alan Stern, Douglas Gilbert, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-scsi-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA, Christoph Hellwig

Trying to set the cache type as "write back" through "echo "write
back" > /sys/class/scsi_disk/<disk>/cache_type" does not work.
Few logs :
#> usb 2-1.4: new high speed USB device using ehci-sdp and address 5
usb 2-1.4: New USB device found, idVendor=152d, idProduct=2339
usb 2-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=5
usb 2-1.4: Product: USB to ATA/ATAPI Bridge
usb 2-1.4: Manufacturer: JMicron
usb 2-1.4: SerialNumber: 3446184AA01C
scsi1 : usb-storage 2-1.4:1.0
scsi 1:0:0:0: Direct-Access     SAMSUNG  HM501IX               PQ: 0 ANSI: 2 CCS
sd 1:0:0:0: [sda] 976773168 512-byte logical blocks: (500 GB/465 GiB)
sd 1:0:0:0: [sda] Write Protect is off
sd 1:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't
support DPO or FUA
 sda:

#> echo "write back" > /sys/class/scsi_disk/1\:0\:0\:0/cache_type
sd 1:0:0:0: [sda] Sense Key : 0x5 [current]
sd 1:0:0:0: [sda] ASC=0x20 ASCQ=0x0


#> usb 2-1.4: new high speed USB device using ehci-sdp and address 4
usb 2-1.4: New USB device found, idVendor=0bc2, idProduct=2300
usb 2-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 2-1.4: Product: Portable
usb 2-1.4: Manufacturer: Seagate
usb 2-1.4: SerialNumber: 2GHW02GR
scsi0 : usb-storage 2-1.4:1.0

#>
#> scsi 0:0:0:0: Direct-Access     Seagate  Portable         0130 PQ: 0 ANSI: 4
sd 0:0:0:0: [sda] 488397168 512-byte logical blocks: (250 GB/232 GiB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] No Caching mode page present
sd 0:0:0:0: [sda] Assuming drive cache: write through
sd 0:0:0:0: [sda] No Caching mode page present
sd 0:0:0:0: [sda] Assuming drive cache: write through
 sda: sda1 sda2 sda3 sda4
sd 0:0:0:0: [sda] No Caching mode page present
sd 0:0:0:0: [sda] Assuming drive cache: write through
sd 0:0:0:0: [sda] Attached SCSI disk

#> echo "write back" > /sys/class/scsi_disk/0\:0\:0\:0/cache_type
sd 0:0:0:0: [sda] No Caching mode page present
sd 0:0:0:0: [sda] Assuming drive cache: write through
#>


#> usb 2-1.4: new high speed USB device using ehci-sdp and address 7
usb 2-1.4: New USB device found, idVendor=1058, idProduct=070a
usb 2-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 2-1.4: Product: My Passport 070A
usb 2-1.4: Manufacturer: Western Digital
usb 2-1.4: SerialNumber: 575832314132304534373635
scsi3 : usb-storage 2-1.4:1.0
scsi 3:0:0:0: Direct-Access     WD       My Passport 070A 1032 PQ: 0 ANSI: 4
scsi 3:0:0:1: CD-ROM            WD       Virtual CD 070A  1032 PQ: 0 ANSI: 4
scsi 3:0:0:2: Enclosure         WD       SES Device       1032 PQ: 0 ANSI: 4
sd 3:0:0:0: [sda] 623769600 512-byte logical blocks: (319 GB/297 GiB)
sd 3:0:0:0: [sda] Write Protect is off
sd 3:0:0:0: [sda] No Caching mode page present
sd 3:0:0:0: [sda] Assuming drive cache: write through
sd 3:0:0:0: [sda] No Caching mode page present
sd 3:0:0:0: [sda] Assuming drive cache: write through
 sda:
sd 3:0:0:0: [sda] No Caching mode page present
sd 3:0:0:0: [sda] Assuming drive cache: write through
sd 3:0:0:0: [sda] Attached SCSI disk

#> cat /sys/class/scsi_disk/3\:0\:0\:0/cache_type
write through
#> echo "write back" > /sys/class/scsi_disk/3\:0\:0\:0/cache_type
#>
#> echo "write back" > /sys/class/scsi_disk/3\:0\:0\:0/cache_type
#>
#>
#> cat /sys/class/scsi_disk/3\:0\:0\:0/cache_type
write through

Regards,
Amit Sahrawat

On Thu, Oct 6, 2011 at 1:38 AM, James Bottomley
<James.Bottomley-JuX6DAaQMKPCXq6kfMZ53/egYHeGw8Jk@public.gmane.org> wrote:
> On Thu, 2011-10-06 at 01:21 +0530, Amit Sahrawat wrote:
>> > The best we could probably offer is an interface to turn on the WCE bit
>> > in software (technically, you can do this today
>> > in /scsi/class/scsi_disk/<disk>/cache_type, it's just that it will try
>> > to commit the change as a MODE_SELECT which will presumably fail).
>> Thanks James, is this related with SCSI command MODE_SELECT? and this
>> is to be passed when there is some failure?
>> or simply doing an "echo <value>" to
>> /scsi/class/scsi_disk/<disk>/cache_type? can you please elaborate a
>> little
>
> You tell me since you have the device.  What that echo does is that it
> does try to make the change permanent with a mode select ... that likely
> won't work and the cache change only takes if the revalidated disk says
> the write back has been enabled (which I really think it won't).  So I
> think you need an additional software bit to flip for the case where the
> device lies.
>
> James
>
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Re: Re: Re: BUG in kernel: Wrong Handling of USB HDD’s in scsiglue(slave_configure) and scsi/sd(sd_read_cache_ =?windows-1252?Q?type=29
  2011-10-07  5:09                 ` Amit Sahrawat
@ 2011-10-07 14:09                   ` Alan Stern
  -1 siblings, 0 replies; 15+ messages in thread
From: Alan Stern @ 2011-10-07 14:09 UTC (permalink / raw)
  To: Amit Sahrawat
  Cc: James Bottomley, Douglas Gilbert, linux-usb, linux-scsi,
	linux-kernel, linux-fsdevel, Christoph Hellwig

On Fri, 7 Oct 2011, Amit Sahrawat wrote:

> Trying to set the cache type as "write back" through "echo "write
> back" > /sys/class/scsi_disk/<disk>/cache_type" does not work.
> Few logs :
> #> usb 2-1.4: new high speed USB device using ehci-sdp and address 5
> usb 2-1.4: New USB device found, idVendor=152d, idProduct=2339
> usb 2-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=5
> usb 2-1.4: Product: USB to ATA/ATAPI Bridge
> usb 2-1.4: Manufacturer: JMicron
> usb 2-1.4: SerialNumber: 3446184AA01C
> scsi1 : usb-storage 2-1.4:1.0
> scsi 1:0:0:0: Direct-Access     SAMSUNG  HM501IX               PQ: 0 ANSI: 2 CCS
> sd 1:0:0:0: [sda] 976773168 512-byte logical blocks: (500 GB/465 GiB)
> sd 1:0:0:0: [sda] Write Protect is off
> sd 1:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't
> support DPO or FUA
>  sda:
> 
> #> echo "write back" > /sys/class/scsi_disk/1\:0\:0\:0/cache_type
> sd 1:0:0:0: [sda] Sense Key : 0x5 [current]
> sd 1:0:0:0: [sda] ASC=0x20 ASCQ=0x0

This is what James was talking about.  When you write something to 
/sys/class/scsi_disk/.../cache_type, the value you specify is sent to 
the drive using a MODE SELECT command.  However, if a USB drive doesn't 
report the caching type properly, it's not very likely to support the 
appropriate MODE SELECT command either.

What you need to do is create a variant of the cache_type sysfs 
attribute, one that will set or clear the WCE flag directly, without 
trying to communicate with the drive.

Alan Stern


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Re: Re: Re: BUG in kernel: Wrong Handling of USB HDD’s in scsiglue(slave_configure) and scsi/sd(sd_read_cache_ =?windows-1252?Q?type=29
@ 2011-10-07 14:09                   ` Alan Stern
  0 siblings, 0 replies; 15+ messages in thread
From: Alan Stern @ 2011-10-07 14:09 UTC (permalink / raw)
  To: Amit Sahrawat
  Cc: James Bottomley, Douglas Gilbert, linux-usb, linux-scsi,
	linux-kernel, linux-fsdevel, Christoph Hellwig

On Fri, 7 Oct 2011, Amit Sahrawat wrote:

> Trying to set the cache type as "write back" through "echo "write
> back" > /sys/class/scsi_disk/<disk>/cache_type" does not work.
> Few logs :
> #> usb 2-1.4: new high speed USB device using ehci-sdp and address 5
> usb 2-1.4: New USB device found, idVendor=152d, idProduct=2339
> usb 2-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=5
> usb 2-1.4: Product: USB to ATA/ATAPI Bridge
> usb 2-1.4: Manufacturer: JMicron
> usb 2-1.4: SerialNumber: 3446184AA01C
> scsi1 : usb-storage 2-1.4:1.0
> scsi 1:0:0:0: Direct-Access     SAMSUNG  HM501IX               PQ: 0 ANSI: 2 CCS
> sd 1:0:0:0: [sda] 976773168 512-byte logical blocks: (500 GB/465 GiB)
> sd 1:0:0:0: [sda] Write Protect is off
> sd 1:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't
> support DPO or FUA
>  sda:
> 
> #> echo "write back" > /sys/class/scsi_disk/1\:0\:0\:0/cache_type
> sd 1:0:0:0: [sda] Sense Key : 0x5 [current]
> sd 1:0:0:0: [sda] ASC=0x20 ASCQ=0x0

This is what James was talking about.  When you write something to 
/sys/class/scsi_disk/.../cache_type, the value you specify is sent to 
the drive using a MODE SELECT command.  However, if a USB drive doesn't 
report the caching type properly, it's not very likely to support the 
appropriate MODE SELECT command either.

What you need to do is create a variant of the cache_type sysfs 
attribute, one that will set or clear the WCE flag directly, without 
trying to communicate with the drive.

Alan Stern

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2011-10-07 14:09 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CADDb1s0ZnHzM72sDnFmRrM=GFJtxj5JkYUSPo6GdyQ_=7L2m9A@mail.gmail.com>
2011-10-04 14:10 ` Re: Re: BUG in kernel: Wrong Handling of USB HDD’s in scsiglue(slave_configure) and scsi/sd(sd_read_cache_type) Alan Stern
2011-10-04 14:10   ` Alan Stern
2011-10-04 14:10   ` Alan Stern
2011-10-04 15:34   ` Amit Sahrawat
     [not found]     ` <CADDb1s3sPxpfNi-OD=QvVT+JWO9kUeTAmb8ZGyN0YCuBKWd4rg@mail.gmail.com>
2011-10-05 14:17       ` Re: Re: Re: BUG in kernel: Wrong Handling of USB HDD’s in scsiglue(slave_configure) and scsi/sd(sd_read_cache_ =?windows-1252?Q?type=29 Alan Stern
2011-10-05 14:17         ` Alan Stern
2011-10-05 15:17         ` James Bottomley
2011-10-05 16:59       ` Re: Re: BUG in kernel: Wrong Handling of USB HDD’s in scsiglue(slave_configure) and scsi/sd(sd_read_cache_type) Amit Sahrawat
2011-10-05 17:24         ` James Bottomley
2011-10-05 19:51           ` Amit Sahrawat
2011-10-05 20:08             ` James Bottomley
2011-10-07  5:09               ` Amit Sahrawat
2011-10-07  5:09                 ` Amit Sahrawat
2011-10-07 14:09                 ` Re: Re: Re: BUG in kernel: Wrong Handling of USB HDD’s in scsiglue(slave_configure) and scsi/sd(sd_read_cache_ =?windows-1252?Q?type=29 Alan Stern
2011-10-07 14:09                   ` Alan Stern

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.