linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Try #3: Use SCSI read/write(16) with > 32-bit LBA drives
@ 2012-11-14 15:39 Jason J. Herne
  0 siblings, 0 replies; 7+ messages in thread
From: Jason J. Herne @ 2012-11-14 15:39 UTC (permalink / raw)
  To: linux-scsi-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA, pbonzini-H+wXaHxf7aLQT0dZR+AlfA,
	JBottomley-bzQdu9zFT3WakBO8gow8eQ,
	stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz, Elliott-VXdhtT5mjnY,
	Jason J. Herne

From: "Jason J. Herne" <hernejj-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Force large capacity (> 0xFFFFFFFF blocks) drives to use READ/WRITE(16) instead
of READ/WRITE(10). Some(most/all?) USB enclosures do not like READ(10) commands
when a large capacity drive is installed.

Signed-off-by: Jason J. Herne <hernejj-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/scsi/sd.c          |    5 ++++-
 include/scsi/scsi_device.h |    1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 12f6fdf..f7913c0 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -887,7 +887,7 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
 		SCpnt->cmnd[29] = (unsigned char) (this_count >> 16) & 0xff;
 		SCpnt->cmnd[30] = (unsigned char) (this_count >> 8) & 0xff;
 		SCpnt->cmnd[31] = (unsigned char) this_count & 0xff;
-	} else if (block > 0xffffffff) {
+	} else if (sdp->use_16_for_rw) {
 		SCpnt->cmnd[0] += READ_16 - READ_6;
 		SCpnt->cmnd[1] = protect | ((rq->cmd_flags & REQ_FUA) ? 0x8 : 0);
 		SCpnt->cmnd[2] = sizeof(block) > 4 ? (unsigned char) (block >> 56) & 0xff : 0;
@@ -2054,6 +2054,9 @@ got_data:
 		}
 	}
 
+	/* Use read/write(16) for > 32-bit LBA disks */
+	sdp->use_16_for_rw = (sdkp->capacity > 0xffffffff);
+
 	/* Rescale capacity to 512-byte units */
 	if (sector_size == 4096)
 		sdkp->capacity <<= 3;
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 88fae8d..19ab8f1 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -135,6 +135,7 @@ struct scsi_device {
 				     * because we did a bus reset. */
 	unsigned use_10_for_rw:1; /* first try 10-byte read / write */
 	unsigned use_10_for_ms:1; /* first try 10-byte mode sense/select */
+	unsigned use_16_for_rw:1; /* Use read/write(16) over read/write(10) */
 	unsigned skip_ms_page_8:1;	/* do not use MODE SENSE page 0x08 */
 	unsigned skip_ms_page_3f:1;	/* do not use MODE SENSE page 0x3f */
 	unsigned skip_vpd_pages:1;	/* do not read VPD pages */
-- 
1.7.9.5

--
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 related	[flat|nested] 7+ messages in thread

* [PATCH] Try #3: Use SCSI read/write(16) with > 32-bit LBA drives
@ 2012-11-14 22:03 Jason J. Herne
       [not found] ` <1352930602-3505-1-git-send-email-hernejj-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Jason J. Herne @ 2012-11-14 22:03 UTC (permalink / raw)
  To: linux-scsi
  Cc: sebastian, linux-usb, pbonzini, JBottomley, stern, Elliott,
	Jason J. Herne

From: "Jason J. Herne" <hernejj@gmail.com>

Force large capacity (> 0xFFFFFFFF blocks) drives to use READ/WRITE(16) instead
of READ/WRITE(10). Some(most/all?) USB enclosures do not like READ(10) commands
when a large capacity drive is installed. This issue was reported and discussed
here: http://marc.info/?l=linux-usb&m=135247705222324&w=2

Signed-off-by: Jason J. Herne <hernejj@gmail.com>
---
 drivers/scsi/sd.c          |    4 +++-
 include/scsi/scsi_device.h |    1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 12f6fdf..f8eaf3a 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -887,7 +887,7 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
 		SCpnt->cmnd[29] = (unsigned char) (this_count >> 16) & 0xff;
 		SCpnt->cmnd[30] = (unsigned char) (this_count >> 8) & 0xff;
 		SCpnt->cmnd[31] = (unsigned char) this_count & 0xff;
-	} else if (block > 0xffffffff) {
+	} else if (sdp->use_16_for_rw) {
 		SCpnt->cmnd[0] += READ_16 - READ_6;
 		SCpnt->cmnd[1] = protect | ((rq->cmd_flags & REQ_FUA) ? 0x8 : 0);
 		SCpnt->cmnd[2] = sizeof(block) > 4 ? (unsigned char) (block >> 56) & 0xff : 0;
@@ -2054,6 +2054,8 @@ got_data:
 		}
 	}
 
+	sdp->use_16_for_rw = (sdkp->capacity > 0xffffffff);
+
 	/* Rescale capacity to 512-byte units */
 	if (sector_size == 4096)
 		sdkp->capacity <<= 3;
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 88fae8d..19ab8f1 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -135,6 +135,7 @@ struct scsi_device {
 				     * because we did a bus reset. */
 	unsigned use_10_for_rw:1; /* first try 10-byte read / write */
 	unsigned use_10_for_ms:1; /* first try 10-byte mode sense/select */
+	unsigned use_16_for_rw:1; /* Use read/write(16) over read/write(10) */
 	unsigned skip_ms_page_8:1;	/* do not use MODE SENSE page 0x08 */
 	unsigned skip_ms_page_3f:1;	/* do not use MODE SENSE page 0x3f */
 	unsigned skip_vpd_pages:1;	/* do not read VPD pages */
-- 
1.7.9.5


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

* Re: [PATCH] Try #3: Use SCSI read/write(16) with > 32-bit LBA drives
       [not found] ` <1352930602-3505-1-git-send-email-hernejj-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2012-11-14 22:22   ` Sergei Shtylyov
       [not found]     ` <50A419B6.4070605-Igf4POYTYCDQT0dZR+AlfA@public.gmane.org>
  2012-11-15  9:20   ` Christoph Hellwig
  1 sibling, 1 reply; 7+ messages in thread
From: Sergei Shtylyov @ 2012-11-14 22:22 UTC (permalink / raw)
  To: Jason J. Herne
  Cc: linux-scsi-u79uwXL29TY76Z2rM5mHXA,
	sebastian-E0PNVn5OA6ohrxcnuTQ+TQ,
	linux-usb-u79uwXL29TY76Z2rM5mHXA, pbonzini-H+wXaHxf7aLQT0dZR+AlfA,
	JBottomley-bzQdu9zFT3WakBO8gow8eQ,
	stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz, Elliott-VXdhtT5mjnY

Hello.

On 15-11-2012 2:03, Jason J. Herne wrote:

> From: "Jason J. Herne" <hernejj-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

   You have already posted Try #3. And preferrably, information about patch 
version should be included with [PATCH] prefix like this [PATCH v4].

> Force large capacity (> 0xFFFFFFFF blocks) drives to use READ/WRITE(16) instead
> of READ/WRITE(10). Some(most/all?) USB enclosures do not like READ(10) commands
> when a large capacity drive is installed. This issue was reported and discussed
> here: http://marc.info/?l=linux-usb&m=135247705222324&w=2

> Signed-off-by: Jason J. Herne <hernejj-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

WBR, Sergei


--
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] 7+ messages in thread

* Re: [PATCH] Try #3: Use SCSI read/write(16) with > 32-bit LBA drives
       [not found]     ` <50A419B6.4070605-Igf4POYTYCDQT0dZR+AlfA@public.gmane.org>
@ 2012-11-15  1:06       ` Jason J. Herne
  2012-11-15  5:50         ` Felipe Balbi
  0 siblings, 1 reply; 7+ messages in thread
From: Jason J. Herne @ 2012-11-15  1:06 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: linux-scsi-u79uwXL29TY76Z2rM5mHXA, Sebastian Andrzej Siewior,
	linux-usb-u79uwXL29TY76Z2rM5mHXA, Paolo Bonzini,
	JBottomley-bzQdu9zFT3WakBO8gow8eQ, Alan Stern,
	Elliott, Robert (Server Storage)

On Wed, Nov 14, 2012 at 5:22 PM, Sergei Shtylyov <sshtylyov-Igf4POYTYCDQT0dZR+AlfA@public.gmane.org> wrote:
> Hello.
>
>
> On 15-11-2012 2:03, Jason J. Herne wrote:
>
>> From: "Jason J. Herne" <hernejj-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>
>
>   You have already posted Try #3. And preferrably, information about patch
> version should be included with [PATCH] prefix like this [PATCH v4].
>
>

Noted for future submissions.  Any idea how I get git send-email to
generate the patch tag
like that?

Also, do I need to resubmit this patch because of this semi-faulty
subject line? I would
assume that to be unnecessary.

--
- Jason J. Herne (hernejj-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org)
--
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] 7+ messages in thread

* Re: [PATCH] Try #3: Use SCSI read/write(16) with > 32-bit LBA drives
  2012-11-15  1:06       ` Jason J. Herne
@ 2012-11-15  5:50         ` Felipe Balbi
  0 siblings, 0 replies; 7+ messages in thread
From: Felipe Balbi @ 2012-11-15  5:50 UTC (permalink / raw)
  To: Jason J. Herne
  Cc: Sergei Shtylyov, linux-scsi, Sebastian Andrzej Siewior, linux-usb,
	Paolo Bonzini, JBottomley, Alan Stern,
	Elliott, Robert (Server Storage)

[-- Attachment #1: Type: text/plain, Size: 891 bytes --]

Hi,

On Wed, Nov 14, 2012 at 08:06:20PM -0500, Jason J. Herne wrote:
> On Wed, Nov 14, 2012 at 5:22 PM, Sergei Shtylyov <sshtylyov@mvista.com> wrote:
> > Hello.
> >
> >
> > On 15-11-2012 2:03, Jason J. Herne wrote:
> >
> >> From: "Jason J. Herne" <hernejj@gmail.com>
> >
> >
> >   You have already posted Try #3. And preferrably, information about patch
> > version should be included with [PATCH] prefix like this [PATCH v4].
> >
> >
> 
> Noted for future submissions.  Any idea how I get git send-email to
> generate the patch tag
> like that?
> 
> Also, do I need to resubmit this patch because of this semi-faulty
> subject line? I would
> assume that to be unnecessary.

$ git send-email --subject-prefix="PATCH v4" HEAD ^origin/master

if you want to generate the patch file before sending, pass
--subject-prefix to git format-patch instead.

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH] Try #3: Use SCSI read/write(16) with > 32-bit LBA drives
       [not found] ` <1352930602-3505-1-git-send-email-hernejj-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2012-11-14 22:22   ` Sergei Shtylyov
@ 2012-11-15  9:20   ` Christoph Hellwig
       [not found]     ` <20121115092051.GA16140-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
  1 sibling, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2012-11-15  9:20 UTC (permalink / raw)
  To: Jason J. Herne
  Cc: linux-scsi-u79uwXL29TY76Z2rM5mHXA,
	sebastian-E0PNVn5OA6ohrxcnuTQ+TQ,
	linux-usb-u79uwXL29TY76Z2rM5mHXA, pbonzini-H+wXaHxf7aLQT0dZR+AlfA,
	JBottomley-bzQdu9zFT3WakBO8gow8eQ,
	stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz, Elliott-VXdhtT5mjnY

On Wed, Nov 14, 2012 at 05:03:22PM -0500, Jason J. Herne wrote:
> From: "Jason J. Herne" <hernejj-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> 
> Force large capacity (> 0xFFFFFFFF blocks) drives to use READ/WRITE(16) instead
> of READ/WRITE(10). Some(most/all?) USB enclosures do not like READ(10) commands
> when a large capacity drive is installed. This issue was reported and discussed
> here: http://marc.info/?l=linux-usb&m=135247705222324&w=2

Is there any reason not to simply use the 16 byte command
unconditionally for large devices?

--
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] 7+ messages in thread

* Re: [PATCH] Try #3: Use SCSI read/write(16) with > 32-bit LBA drives
       [not found]     ` <20121115092051.GA16140-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
@ 2012-11-15 14:26       ` Jason J. Herne
  0 siblings, 0 replies; 7+ messages in thread
From: Jason J. Herne @ 2012-11-15 14:26 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: linux-scsi-u79uwXL29TY76Z2rM5mHXA, Sebastian Andrzej Siewior,
	linux-usb-u79uwXL29TY76Z2rM5mHXA, Paolo Bonzini,
	JBottomley-bzQdu9zFT3WakBO8gow8eQ, Alan Stern,
	Elliott, Robert (Server Storage)

On Thu, Nov 15, 2012 at 4:20 AM, Christoph Hellwig <hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org> wrote:
> On Wed, Nov 14, 2012 at 05:03:22PM -0500, Jason J. Herne wrote:
>> From: "Jason J. Herne" <hernejj-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>>
>> Force large capacity (> 0xFFFFFFFF blocks) drives to use READ/WRITE(16) instead
>> of READ/WRITE(10). Some(most/all?) USB enclosures do not like READ(10) commands
>> when a large capacity drive is installed. This issue was reported and discussed
>> here: http://marc.info/?l=linux-usb&m=135247705222324&w=2
>
> Is there any reason not to simply use the 16 byte command
> unconditionally for large devices?
>

What you are suggesting is exactly what this patch is doing.  Code was
added to sd_read_capacity()
to turn on the new bit if the device has more than 2^32 blocks.

--
- Jason J. Herne (hernejj-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org)
--
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] 7+ messages in thread

end of thread, other threads:[~2012-11-15 14:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-14 15:39 [PATCH] Try #3: Use SCSI read/write(16) with > 32-bit LBA drives Jason J. Herne
  -- strict thread matches above, loose matches on Subject: below --
2012-11-14 22:03 Jason J. Herne
     [not found] ` <1352930602-3505-1-git-send-email-hernejj-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-11-14 22:22   ` Sergei Shtylyov
     [not found]     ` <50A419B6.4070605-Igf4POYTYCDQT0dZR+AlfA@public.gmane.org>
2012-11-15  1:06       ` Jason J. Herne
2012-11-15  5:50         ` Felipe Balbi
2012-11-15  9:20   ` Christoph Hellwig
     [not found]     ` <20121115092051.GA16140-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2012-11-15 14:26       ` Jason J. Herne

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).