linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] SCSI & usb-storage: add try_rc_10_first flag
       [not found] <4FDEE8A1.5030200@redhat.com>
@ 2012-06-20 20:04 ` Alan Stern
  2012-06-20 20:13   ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Alan Stern @ 2012-06-20 20:04 UTC (permalink / raw)
  To: Greg KH, James E.J. Bottomley
  Cc: Matthew Dharm, Hans de Goede, Torsten Wohlfarth, Sturm Flut,
	Sergey, Philippe Valembois - Phil, USB list,
	SCSI development list

Several bug reports have been received recently for USB mass-storage
devices that don't handle READ CAPACITY(16) commands properly.  They
report bogus sizes, in some cases becoming unusable as a result.

The bugs were triggered by commit
09b6b51b0b6c1b9bb61815baf205e4d74c89ff04 (SCSI & usb-storage: add
flags for VPD pages and REPORT LUNS), which caused usb-storage to stop
overriding the SCSI level reported by devices.  By default, the sd
driver will try READ CAPACITY(16) first for any device whose level is
above SCSI_SPC_2.

It seems likely that any device large enough to require the use of
READ CAPACITY(16) (i.e., 2 TB or more) would be able to handle READ
CAPACITY(10) commands properly.  Indeed, I don't know of any devices
that don't handle READ CAPACITY(10) properly.

Therefore this patch (as1559) adds a new flag telling the sd driver
to try READ CAPACITY(10) before READ CAPACITY(16), and sets this flag
for every USB mass-storage device.  If a device really is larger than
2 TB, sd will fall back to READ CAPACITY(16) just as it used to.

This fixes Bugzilla #43391.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Hans de Goede <hdegoede@redhat.com>
CC: "James E.J. Bottomley" <JBottomley@parallels.com>
CC: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
CC: <stable@vger.kernel.org>

---

 drivers/scsi/sd.c              |    2 ++
 drivers/usb/storage/scsiglue.c |    6 ++++++
 include/scsi/scsi_device.h     |    1 +
 3 files changed, 9 insertions(+)

Index: usb-3.4/include/scsi/scsi_device.h
===================================================================
--- usb-3.4.orig/include/scsi/scsi_device.h
+++ usb-3.4/include/scsi/scsi_device.h
@@ -151,6 +151,7 @@ struct scsi_device {
 					   SD_LAST_BUGGY_SECTORS */
 	unsigned no_read_disc_info:1;	/* Avoid READ_DISC_INFO cmds */
 	unsigned no_read_capacity_16:1; /* Avoid READ_CAPACITY_16 cmds */
+	unsigned try_rc_10_first:1;	/* Try READ_CAPACACITY_10 first */
 	unsigned is_visible:1;	/* is the device visible in sysfs */
 
 	DECLARE_BITMAP(supported_events, SDEV_EVT_MAXBITS); /* supported events */
Index: usb-3.4/drivers/scsi/sd.c
===================================================================
--- usb-3.4.orig/drivers/scsi/sd.c
+++ usb-3.4/drivers/scsi/sd.c
@@ -1899,6 +1899,8 @@ static int sd_try_rc16_first(struct scsi
 {
 	if (sdp->host->max_cmd_len < 16)
 		return 0;
+	if (sdp->try_rc_10_first)
+		return 0;
 	if (sdp->scsi_level > SCSI_SPC_2)
 		return 1;
 	if (scsi_device_protection(sdp))
Index: usb-3.4/drivers/usb/storage/scsiglue.c
===================================================================
--- usb-3.4.orig/drivers/usb/storage/scsiglue.c
+++ usb-3.4/drivers/usb/storage/scsiglue.c
@@ -202,6 +202,12 @@ static int slave_configure(struct scsi_d
 		if (us->fflags & US_FL_NO_READ_CAPACITY_16)
 			sdev->no_read_capacity_16 = 1;
 
+		/*
+		 * Many devices do not respond properly to READ_CAPACITY_16.
+		 * Tell the SCSI layer to try READ_CAPACITY_10 first.
+		 */
+		sdev->try_rc_10_first = 1;
+
 		/* assume SPC3 or latter devices support sense size > 18 */
 		if (sdev->scsi_level > SCSI_SPC_2)
 			us->fflags |= US_FL_SANE_SENSE;



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

* Re: [PATCH 1/2] SCSI & usb-storage: add try_rc_10_first flag
  2012-06-20 20:04 ` [PATCH 1/2] SCSI & usb-storage: add try_rc_10_first flag Alan Stern
@ 2012-06-20 20:13   ` Greg KH
  2012-06-22 13:39     ` James Bottomley
  0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2012-06-20 20:13 UTC (permalink / raw)
  To: Alan Stern, James E.J. Bottomley
  Cc: Matthew Dharm, Hans de Goede, Torsten Wohlfarth, Sturm Flut,
	Sergey, Philippe Valembois - Phil, USB list,
	SCSI development list

On Wed, Jun 20, 2012 at 04:04:19PM -0400, Alan Stern wrote:
> Several bug reports have been received recently for USB mass-storage
> devices that don't handle READ CAPACITY(16) commands properly.  They
> report bogus sizes, in some cases becoming unusable as a result.
> 
> The bugs were triggered by commit
> 09b6b51b0b6c1b9bb61815baf205e4d74c89ff04 (SCSI & usb-storage: add
> flags for VPD pages and REPORT LUNS), which caused usb-storage to stop
> overriding the SCSI level reported by devices.  By default, the sd
> driver will try READ CAPACITY(16) first for any device whose level is
> above SCSI_SPC_2.
> 
> It seems likely that any device large enough to require the use of
> READ CAPACITY(16) (i.e., 2 TB or more) would be able to handle READ
> CAPACITY(10) commands properly.  Indeed, I don't know of any devices
> that don't handle READ CAPACITY(10) properly.
> 
> Therefore this patch (as1559) adds a new flag telling the sd driver
> to try READ CAPACITY(10) before READ CAPACITY(16), and sets this flag
> for every USB mass-storage device.  If a device really is larger than
> 2 TB, sd will fall back to READ CAPACITY(16) just as it used to.
> 
> This fixes Bugzilla #43391.
> 
> Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
> Acked-by: Hans de Goede <hdegoede@redhat.com>
> CC: "James E.J. Bottomley" <JBottomley@parallels.com>
> CC: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
> CC: <stable@vger.kernel.org>

James, mind if I take this through my trees?

thanks,

greg k-h

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

* Re: [PATCH 1/2] SCSI & usb-storage: add try_rc_10_first flag
  2012-06-20 20:13   ` Greg KH
@ 2012-06-22 13:39     ` James Bottomley
  2012-06-22 16:23       ` James Bottomley
  0 siblings, 1 reply; 5+ messages in thread
From: James Bottomley @ 2012-06-22 13:39 UTC (permalink / raw)
  To: Greg KH
  Cc: Alan Stern, Matthew Dharm, Hans de Goede, Torsten Wohlfarth,
	Sturm Flut, Sergey, Philippe Valembois - Phil, USB list,
	SCSI development list

On Wed, 2012-06-20 at 13:13 -0700, Greg KH wrote:
> On Wed, Jun 20, 2012 at 04:04:19PM -0400, Alan Stern wrote:
> > Several bug reports have been received recently for USB mass-storage
> > devices that don't handle READ CAPACITY(16) commands properly.  They
> > report bogus sizes, in some cases becoming unusable as a result.
> > 
> > The bugs were triggered by commit
> > 09b6b51b0b6c1b9bb61815baf205e4d74c89ff04 (SCSI & usb-storage: add
> > flags for VPD pages and REPORT LUNS), which caused usb-storage to stop
> > overriding the SCSI level reported by devices.  By default, the sd
> > driver will try READ CAPACITY(16) first for any device whose level is
> > above SCSI_SPC_2.
> > 
> > It seems likely that any device large enough to require the use of
> > READ CAPACITY(16) (i.e., 2 TB or more) would be able to handle READ
> > CAPACITY(10) commands properly.  Indeed, I don't know of any devices
> > that don't handle READ CAPACITY(10) properly.
> > 
> > Therefore this patch (as1559) adds a new flag telling the sd driver
> > to try READ CAPACITY(10) before READ CAPACITY(16), and sets this flag
> > for every USB mass-storage device.  If a device really is larger than
> > 2 TB, sd will fall back to READ CAPACITY(16) just as it used to.
> > 
> > This fixes Bugzilla #43391.
> > 
> > Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
> > Acked-by: Hans de Goede <hdegoede@redhat.com>
> > CC: "James E.J. Bottomley" <JBottomley@parallels.com>
> > CC: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
> > CC: <stable@vger.kernel.org>
> 
> James, mind if I take this through my trees?

Actually, you can take 1/2 but I need to do 2/2 as a postmerge.  I
foresee a conflict with another patch I'm queuing that needs resolving.

Let me know when you've got 1/2 in and I'll build the postmerge tree.

Thanks,

James



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

* Re: [PATCH 1/2] SCSI & usb-storage: add try_rc_10_first flag
  2012-06-22 13:39     ` James Bottomley
@ 2012-06-22 16:23       ` James Bottomley
  2012-06-23  5:06         ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: James Bottomley @ 2012-06-22 16:23 UTC (permalink / raw)
  To: Greg KH
  Cc: Alan Stern, Matthew Dharm, Hans de Goede, Torsten Wohlfarth,
	Sturm Flut, Sergey, Philippe Valembois - Phil, USB list,
	SCSI development list

On Fri, 2012-06-22 at 14:39 +0100, James Bottomley wrote:
> On Wed, 2012-06-20 at 13:13 -0700, Greg KH wrote:
> > On Wed, Jun 20, 2012 at 04:04:19PM -0400, Alan Stern wrote:
> > > Several bug reports have been received recently for USB mass-storage
> > > devices that don't handle READ CAPACITY(16) commands properly.  They
> > > report bogus sizes, in some cases becoming unusable as a result.
> > > 
> > > The bugs were triggered by commit
> > > 09b6b51b0b6c1b9bb61815baf205e4d74c89ff04 (SCSI & usb-storage: add
> > > flags for VPD pages and REPORT LUNS), which caused usb-storage to stop
> > > overriding the SCSI level reported by devices.  By default, the sd
> > > driver will try READ CAPACITY(16) first for any device whose level is
> > > above SCSI_SPC_2.
> > > 
> > > It seems likely that any device large enough to require the use of
> > > READ CAPACITY(16) (i.e., 2 TB or more) would be able to handle READ
> > > CAPACITY(10) commands properly.  Indeed, I don't know of any devices
> > > that don't handle READ CAPACITY(10) properly.
> > > 
> > > Therefore this patch (as1559) adds a new flag telling the sd driver
> > > to try READ CAPACITY(10) before READ CAPACITY(16), and sets this flag
> > > for every USB mass-storage device.  If a device really is larger than
> > > 2 TB, sd will fall back to READ CAPACITY(16) just as it used to.
> > > 
> > > This fixes Bugzilla #43391.
> > > 
> > > Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
> > > Acked-by: Hans de Goede <hdegoede@redhat.com>
> > > CC: "James E.J. Bottomley" <JBottomley@parallels.com>
> > > CC: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
> > > CC: <stable@vger.kernel.org>
> > 
> > James, mind if I take this through my trees?
> 
> Actually, you can take 1/2 but I need to do 2/2 as a postmerge.  I
> foresee a conflict with another patch I'm queuing that needs resolving.
> 
> Let me know when you've got 1/2 in and I'll build the postmerge tree.

Actually, forget I said this ... the postmerge has to be the other way
around.  

James



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

* Re: [PATCH 1/2] SCSI & usb-storage: add try_rc_10_first flag
  2012-06-22 16:23       ` James Bottomley
@ 2012-06-23  5:06         ` Greg KH
  0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2012-06-23  5:06 UTC (permalink / raw)
  To: James Bottomley
  Cc: Alan Stern, Matthew Dharm, Hans de Goede, Torsten Wohlfarth,
	Sturm Flut, Sergey, Philippe Valembois - Phil, USB list,
	SCSI development list

On Fri, Jun 22, 2012 at 05:23:07PM +0100, James Bottomley wrote:
> On Fri, 2012-06-22 at 14:39 +0100, James Bottomley wrote:
> > On Wed, 2012-06-20 at 13:13 -0700, Greg KH wrote:
> > > On Wed, Jun 20, 2012 at 04:04:19PM -0400, Alan Stern wrote:
> > > > Several bug reports have been received recently for USB mass-storage
> > > > devices that don't handle READ CAPACITY(16) commands properly.  They
> > > > report bogus sizes, in some cases becoming unusable as a result.
> > > > 
> > > > The bugs were triggered by commit
> > > > 09b6b51b0b6c1b9bb61815baf205e4d74c89ff04 (SCSI & usb-storage: add
> > > > flags for VPD pages and REPORT LUNS), which caused usb-storage to stop
> > > > overriding the SCSI level reported by devices.  By default, the sd
> > > > driver will try READ CAPACITY(16) first for any device whose level is
> > > > above SCSI_SPC_2.
> > > > 
> > > > It seems likely that any device large enough to require the use of
> > > > READ CAPACITY(16) (i.e., 2 TB or more) would be able to handle READ
> > > > CAPACITY(10) commands properly.  Indeed, I don't know of any devices
> > > > that don't handle READ CAPACITY(10) properly.
> > > > 
> > > > Therefore this patch (as1559) adds a new flag telling the sd driver
> > > > to try READ CAPACITY(10) before READ CAPACITY(16), and sets this flag
> > > > for every USB mass-storage device.  If a device really is larger than
> > > > 2 TB, sd will fall back to READ CAPACITY(16) just as it used to.
> > > > 
> > > > This fixes Bugzilla #43391.
> > > > 
> > > > Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
> > > > Acked-by: Hans de Goede <hdegoede@redhat.com>
> > > > CC: "James E.J. Bottomley" <JBottomley@parallels.com>
> > > > CC: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
> > > > CC: <stable@vger.kernel.org>
> > > 
> > > James, mind if I take this through my trees?
> > 
> > Actually, you can take 1/2 but I need to do 2/2 as a postmerge.  I
> > foresee a conflict with another patch I'm queuing that needs resolving.
> > 
> > Let me know when you've got 1/2 in and I'll build the postmerge tree.
> 
> Actually, forget I said this ... the postmerge has to be the other way
> around.  

As these will probably make it to Linus before 3.5 is out, why would
that be needed?

Anyway, they are in my tree now, hopefully all should be fine.

thanks,

greg k-h

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

end of thread, other threads:[~2012-06-23  5:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <4FDEE8A1.5030200@redhat.com>
2012-06-20 20:04 ` [PATCH 1/2] SCSI & usb-storage: add try_rc_10_first flag Alan Stern
2012-06-20 20:13   ` Greg KH
2012-06-22 13:39     ` James Bottomley
2012-06-22 16:23       ` James Bottomley
2012-06-23  5:06         ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).