All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Try #2: Use SCSI read/write(16) with >2TB drives
       [not found] <50A2F12F.9060209 () redhat ! com>
@ 2012-11-14  5:55 ` Jason J. Herne
  2012-11-14 19:02   ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 3+ messages in thread
From: Jason J. Herne @ 2012-11-14  5:55 UTC (permalink / raw)
  To: linux-scsi; +Cc: linux-usb, pbonzini, JBottomley, stern, Jason J. Herne

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

Force large capacity (> 2TB) 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@gmail.com>
---
 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..9611d6b 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 > 2TB 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


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

* Re: [PATCH] Try #2: Use SCSI read/write(16) with >2TB drives
  2012-11-14  5:55 ` [PATCH] Try #2: Use SCSI read/write(16) with >2TB drives Jason J. Herne
@ 2012-11-14 19:02   ` Sebastian Andrzej Siewior
  2012-11-14 22:06     ` Jason J. Herne
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Andrzej Siewior @ 2012-11-14 19:02 UTC (permalink / raw)
  To: Jason J. Herne; +Cc: linux-scsi, linux-usb, pbonzini, JBottomley, stern

On Wed, Nov 14, 2012 at 12:55:13AM -0500, Jason J. Herne wrote:
> --- 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 > 2TB disks */
> +	sdp->use_16_for_rw = (sdkp->capacity > 0xffffffff);

The comment is pointless if you assume the reading is able to read C. What
would help is a link either here or in patch's description to the mail thread
where it has been descovered that some >2TB devices don't recognize the small
command.

> +
>  	/* Rescale capacity to 512-byte units */
>  	if (sector_size == 4096)
>  		sdkp->capacity <<= 3;

Sebastian

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

* Re: [PATCH] Try #2: Use SCSI read/write(16) with >2TB drives
  2012-11-14 19:02   ` Sebastian Andrzej Siewior
@ 2012-11-14 22:06     ` Jason J. Herne
  0 siblings, 0 replies; 3+ messages in thread
From: Jason J. Herne @ 2012-11-14 22:06 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-scsi, linux-usb, Paolo Bonzini, JBottomley, Alan Stern

On Wed, Nov 14, 2012 at 2:02 PM, Sebastian Andrzej Siewior
<sebastian@breakpoint.cc> wrote:
> On Wed, Nov 14, 2012 at 12:55:13AM -0500, Jason J. Herne wrote:
>>               }
>>       }
>>
>> +     /* Use read/write(16) for > 2TB disks */
>> +     sdp->use_16_for_rw = (sdkp->capacity > 0xffffffff);
>
> The comment is pointless if you assume the reading is able to read C. What
> would help is a link either here or in patch's description to the mail thread
> where it has been descovered that some >2TB devices don't recognize the small
> command.

I've removed the comment entirely and added a link to the original
post within the patch
description. Resending in separate e-mail.

--
- Jason J. Herne (hernejj@gmail.com)

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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <50A2F12F.9060209 () redhat ! com>
2012-11-14  5:55 ` [PATCH] Try #2: Use SCSI read/write(16) with >2TB drives Jason J. Herne
2012-11-14 19:02   ` Sebastian Andrzej Siewior
2012-11-14 22:06     ` Jason J. Herne

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.