public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] scsi: Fix max transfer length for 4k disks
@ 2015-01-29 21:54 Brian King
  2015-01-29 23:09 ` Paolo Bonzini
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Brian King @ 2015-01-29 21:54 UTC (permalink / raw)
  To: James.Bottomley; +Cc: hch, linux-scsi, wenxiong, brking, stable


The following patch fixes an issue observed with 4k sector disks
where the max_hw_sectors attribute was getting set too large in
sd_revalidate_disk. Since sdkp->max_xfer_blocks is in units
of SCSI logical blocks and queue_max_hw_sectors is in units of
512 byte blocks, on a 4k sector disk, every time we went through
sd_revalidate_disk, we were taking the current value of
queue_max_hw_sectors and increasing it by a factor of 8. Fix
this by only shifting sdkp->max_xfer_blocks.

Cc: stable<stable@vger.kernel.org>
Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
---

 drivers/scsi/sd.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff -puN drivers/scsi/sd.c~sd_revalidate_4k drivers/scsi/sd.c
--- linux/drivers/scsi/sd.c~sd_revalidate_4k	2015-01-29 14:44:23.316171187 -0600
+++ linux-bjking1/drivers/scsi/sd.c	2015-01-29 14:51:05.846126392 -0600
@@ -2800,9 +2800,11 @@ static int sd_revalidate_disk(struct gen
 	 */
 	sd_set_flush_flag(sdkp);
 
-	max_xfer = min_not_zero(queue_max_hw_sectors(sdkp->disk->queue),
-				sdkp->max_xfer_blocks);
+	max_xfer = sdkp->max_xfer_blocks;
 	max_xfer <<= ilog2(sdp->sector_size) - 9;
+
+	max_xfer = min_not_zero(queue_max_hw_sectors(sdkp->disk->queue),
+				max_xfer);
 	blk_queue_max_hw_sectors(sdkp->disk->queue, max_xfer);
 	set_capacity(disk, sdkp->capacity);
 	sd_config_write_same(sdkp);
_


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

* Re: [PATCH 1/1] scsi: Fix max transfer length for 4k disks
  2015-01-29 21:54 [PATCH 1/1] scsi: Fix max transfer length for 4k disks Brian King
@ 2015-01-29 23:09 ` Paolo Bonzini
  2015-01-30  0:43 ` Martin K. Petersen
  2015-02-03 19:25 ` Venkatesh Srinivas
  2 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2015-01-29 23:09 UTC (permalink / raw)
  To: Brian King, James.Bottomley; +Cc: hch, linux-scsi, wenxiong, stable



On 29/01/2015 22:54, Brian King wrote:
> The following patch fixes an issue observed with 4k sector disks
> where the max_hw_sectors attribute was getting set too large in
> sd_revalidate_disk. Since sdkp->max_xfer_blocks is in units
> of SCSI logical blocks and queue_max_hw_sectors is in units of
> 512 byte blocks, on a 4k sector disk, every time we went through
> sd_revalidate_disk, we were taking the current value of
> queue_max_hw_sectors and increasing it by a factor of 8. Fix
> this by only shifting sdkp->max_xfer_blocks.
> 
> Cc: stable<stable@vger.kernel.org>
> Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
> ---
> 
>  drivers/scsi/sd.c |    6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff -puN drivers/scsi/sd.c~sd_revalidate_4k drivers/scsi/sd.c
> --- linux/drivers/scsi/sd.c~sd_revalidate_4k	2015-01-29 14:44:23.316171187 -0600
> +++ linux-bjking1/drivers/scsi/sd.c	2015-01-29 14:51:05.846126392 -0600
> @@ -2800,9 +2800,11 @@ static int sd_revalidate_disk(struct gen
>  	 */
>  	sd_set_flush_flag(sdkp);
>  
> -	max_xfer = min_not_zero(queue_max_hw_sectors(sdkp->disk->queue),
> -				sdkp->max_xfer_blocks);
> +	max_xfer = sdkp->max_xfer_blocks;
>  	max_xfer <<= ilog2(sdp->sector_size) - 9;
> +
> +	max_xfer = min_not_zero(queue_max_hw_sectors(sdkp->disk->queue),
> +				max_xfer);
>  	blk_queue_max_hw_sectors(sdkp->disk->queue, max_xfer);
>  	set_capacity(disk, sdkp->capacity);
>  	sd_config_write_same(sdkp);
> _
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

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

* Re: [PATCH 1/1] scsi: Fix max transfer length for 4k disks
  2015-01-29 21:54 [PATCH 1/1] scsi: Fix max transfer length for 4k disks Brian King
  2015-01-29 23:09 ` Paolo Bonzini
@ 2015-01-30  0:43 ` Martin K. Petersen
  2015-02-03 19:25 ` Venkatesh Srinivas
  2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2015-01-30  0:43 UTC (permalink / raw)
  To: Brian King; +Cc: James.Bottomley, hch, linux-scsi, wenxiong, stable

>>>>> "Brian" == Brian King <brking@linux.vnet.ibm.com> writes:

Brian> on a 4k sector disk, every time we went through
Brian> sd_revalidate_disk, we were taking the current value of
Brian> queue_max_hw_sectors and increasing it by a factor of 8. Fix this
Brian> by only shifting sdkp->max_xfer_blocks.

*blush*

Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH 1/1] scsi: Fix max transfer length for 4k disks
  2015-01-29 21:54 [PATCH 1/1] scsi: Fix max transfer length for 4k disks Brian King
  2015-01-29 23:09 ` Paolo Bonzini
  2015-01-30  0:43 ` Martin K. Petersen
@ 2015-02-03 19:25 ` Venkatesh Srinivas
  2 siblings, 0 replies; 4+ messages in thread
From: Venkatesh Srinivas @ 2015-02-03 19:25 UTC (permalink / raw)
  To: Brian King; +Cc: Jej B, Christoph Hellwig, linux-scsi, wenxiong, stable

On Thu, Jan 29, 2015 at 1:54 PM, Brian King <brking@linux.vnet.ibm.com> wrote:
>
> The following patch fixes an issue observed with 4k sector disks
> where the max_hw_sectors attribute was getting set too large in
> sd_revalidate_disk. Since sdkp->max_xfer_blocks is in units
> of SCSI logical blocks and queue_max_hw_sectors is in units of
> 512 byte blocks, on a 4k sector disk, every time we went through
> sd_revalidate_disk, we were taking the current value of
> queue_max_hw_sectors and increasing it by a factor of 8. Fix
> this by only shifting sdkp->max_xfer_blocks.
>
> Cc: stable<stable@vger.kernel.org>
> Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
> ---
>
>  drivers/scsi/sd.c |    6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff -puN drivers/scsi/sd.c~sd_revalidate_4k drivers/scsi/sd.c
> --- linux/drivers/scsi/sd.c~sd_revalidate_4k    2015-01-29 14:44:23.316171187 -0600
> +++ linux-bjking1/drivers/scsi/sd.c     2015-01-29 14:51:05.846126392 -0600
> @@ -2800,9 +2800,11 @@ static int sd_revalidate_disk(struct gen
>          */
>         sd_set_flush_flag(sdkp);
>
> -       max_xfer = min_not_zero(queue_max_hw_sectors(sdkp->disk->queue),
> -                               sdkp->max_xfer_blocks);
> +       max_xfer = sdkp->max_xfer_blocks;
>         max_xfer <<= ilog2(sdp->sector_size) - 9;
> +
> +       max_xfer = min_not_zero(queue_max_hw_sectors(sdkp->disk->queue),
> +                               max_xfer);
>         blk_queue_max_hw_sectors(sdkp->disk->queue, max_xfer);
>         set_capacity(disk, sdkp->capacity);
>         sd_config_write_same(sdkp);

Heh, nice find.

Tested-by: Venkatesh Srinivas <venkateshs@google.com>

-- vs;

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

end of thread, other threads:[~2015-02-03 19:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-29 21:54 [PATCH 1/1] scsi: Fix max transfer length for 4k disks Brian King
2015-01-29 23:09 ` Paolo Bonzini
2015-01-30  0:43 ` Martin K. Petersen
2015-02-03 19:25 ` Venkatesh Srinivas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox