Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1407739 > unrolled thread

[PATCH] Use the correct size to set block max sectors

Started byLong Li <longli@microsoft.com>
First post2016-05-27 00:30 +0200
Last post2016-05-27 06:30 +0200
Articles 4 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] Use the correct size to set block max sectors Long Li <longli@microsoft.com> - 2016-05-27 00:30 +0200
    Re: [PATCH] Use the correct size to set block max sectors Fam Zheng <famz@redhat.com> - 2016-05-27 02:50 +0200
    Re: [PATCH] Use the correct size to set block max sectors Joe Perches <joe@perches.com> - 2016-05-27 03:40 +0200
    RE: [PATCH] Use the correct size to set block max sectors Long Li <longli@microsoft.com> - 2016-05-27 06:30 +0200

#1407739 — [PATCH] Use the correct size to set block max sectors

FromLong Li <longli@microsoft.com>
Date2016-05-27 00:30 +0200
Subject[PATCH] Use the correct size to set block max sectors
Message-ID<rDbWV-3C0-13@gated-at.bofh.it>
The block sector size should be in unit of 512 bytes, not in bytes.

Signed-off-by: Long Li <longli@microsoft.com>

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

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 428c03e..4bce17e 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2862,9 +2862,11 @@ static int sd_revalidate_disk(struct gendisk *disk)
 	if (sdkp->opt_xfer_blocks &&
 	    sdkp->opt_xfer_blocks <= dev_max &&
 	    sdkp->opt_xfer_blocks <= SD_DEF_XFER_BLOCKS &&
-	    sdkp->opt_xfer_blocks * sdp->sector_size >= PAGE_SIZE)
-		rw_max = q->limits.io_opt =
+	    sdkp->opt_xfer_blocks * sdp->sector_size >= PAGE_SIZE) {
+		q->limits.io_opt =
 			sdkp->opt_xfer_blocks * sdp->sector_size;
+		rw_max = (q->limits.io_opt >> 9);
+	}
 	else
 		rw_max = BLK_DEF_MAX_SECTORS;
 
-- 
1.8.5.6

[toc] | [next] | [standalone]


#1407761

FromFam Zheng <famz@redhat.com>
Date2016-05-27 02:50 +0200
Message-ID<rDe8p-4QQ-5@gated-at.bofh.it>
In reply to#1407739
On Thu, 05/26 17:08, Long Li wrote:
> The block sector size should be in unit of 512 bytes, not in bytes.
> 
> Signed-off-by: Long Li <longli@microsoft.com>
> 
> ---
>  drivers/scsi/sd.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index 428c03e..4bce17e 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -2862,9 +2862,11 @@ static int sd_revalidate_disk(struct gendisk *disk)
>  	if (sdkp->opt_xfer_blocks &&
>  	    sdkp->opt_xfer_blocks <= dev_max &&
>  	    sdkp->opt_xfer_blocks <= SD_DEF_XFER_BLOCKS &&
> -	    sdkp->opt_xfer_blocks * sdp->sector_size >= PAGE_SIZE)
> -		rw_max = q->limits.io_opt =
> +	    sdkp->opt_xfer_blocks * sdp->sector_size >= PAGE_SIZE) {
> +		q->limits.io_opt =
>  			sdkp->opt_xfer_blocks * sdp->sector_size;
> +		rw_max = (q->limits.io_opt >> 9);

Other than the superfluous parenthesis, looks good to me.

Fam

> +	}
>  	else
>  		rw_max = BLK_DEF_MAX_SECTORS;
>  
> -- 
> 1.8.5.6
> 
> --
> 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

[toc] | [prev] | [next] | [standalone]


#1407767

FromJoe Perches <joe@perches.com>
Date2016-05-27 03:40 +0200
Message-ID<rDeUN-5lZ-3@gated-at.bofh.it>
In reply to#1407739
dOn Thu, 2016-05-26 at 17:08 -0700, Long Li wrote:
> The block sector size should be in unit of 512 bytes, not in bytes.

Thanks.  The patch subject should use something like:

[PATCH] sd: Use the correct size to set block max sectors

to show what subsystem is being modified.

> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
[]
> @@ -2862,9 +2862,11 @@ static int sd_revalidate_disk(struct gendisk *disk)
>  	if (sdkp->opt_xfer_blocks &&
>  	    sdkp->opt_xfer_blocks <= dev_max &&
>  	    sdkp->opt_xfer_blocks <= SD_DEF_XFER_BLOCKS &&
> -	    sdkp->opt_xfer_blocks * sdp->sector_size >= PAGE_SIZE)
> -		rw_max = q->limits.io_opt =
> +	    sdkp->opt_xfer_blocks * sdp->sector_size >= PAGE_SIZE) {
> +		q->limits.io_opt =
>  			sdkp->opt_xfer_blocks * sdp->sector_size;
> +		rw_max = (q->limits.io_opt >> 9);
> +	}
>  	else
>  		rw_max = BLK_DEF_MAX_SECTORS;

And style trivia:  it'd be more kernel style consistent as:

	if (...
	    sdkp->opt_xfer_blocks * sdp->sector_size >= PAGE_SIZE) {
		q->limits.io_opt = sdkp->opt_xfer_blocks * sdp->sector_size;
		rw_max = q->limits.io_opt >> 9;
	} else {
		rw_max = BLK_DEF_MAX_SECTORS;
	}

ie: no parentheses necessary around the shifted value and
    braces around both arms.

[toc] | [prev] | [next] | [standalone]


#1407807

FromLong Li <longli@microsoft.com>
Date2016-05-27 06:30 +0200
Message-ID<rDhzj-7b0-9@gated-at.bofh.it>
In reply to#1407739
> -----Original Message-----
> From: Bart Van Assche [mailto:bart.vanassche@sandisk.com]
> Sent: Thursday, May 26, 2016 7:19 PM
> To: Long Li <longli@microsoft.com>; James E.J. Bottomley
> <jejb@linux.vnet.ibm.com>; Martin K. Petersen
> <martin.petersen@oracle.com>
> Cc: KY Srinivasan <kys@microsoft.com>; linux-scsi@vger.kernel.org; linux-
> kernel@vger.kernel.org
> Subject: Re: [PATCH] Use the correct size to set block max sectors
> 
> On 05/26/16 17:08, Long Li wrote:
> > The block sector size should be in unit of 512 bytes, not in bytes.
> >
> > Signed-off-by: Long Li <longli@microsoft.com>
> >
> > ---
> >  drivers/scsi/sd.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index
> > 428c03e..4bce17e 100644
> > --- a/drivers/scsi/sd.c
> > +++ b/drivers/scsi/sd.c
> > @@ -2862,9 +2862,11 @@ static int sd_revalidate_disk(struct gendisk *disk)
> >  	if (sdkp->opt_xfer_blocks &&
> >  	    sdkp->opt_xfer_blocks <= dev_max &&
> >  	    sdkp->opt_xfer_blocks <= SD_DEF_XFER_BLOCKS &&
> > -	    sdkp->opt_xfer_blocks * sdp->sector_size >= PAGE_SIZE)
> > -		rw_max = q->limits.io_opt =
> > +	    sdkp->opt_xfer_blocks * sdp->sector_size >= PAGE_SIZE) {
> > +		q->limits.io_opt =
> >  			sdkp->opt_xfer_blocks * sdp->sector_size;
> > +		rw_max = (q->limits.io_opt >> 9);
> > +	}
> >  	else
> >  		rw_max = BLK_DEF_MAX_SECTORS;
> 
> Isn't this a duplicate of a patch Martin Petersen posted three weeks ago? See
> also
> https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fthread.g
> mane.org%2fgmane.linux.scsi%2f113746&data=01%7c01%7clongli%40micros
> oft.com%7c4396718e6f9749d178bf08d385d53bba%7c72f988bf86f141af91ab2
> d7cd011db47%7c1&sdata=UpiYwEdYMtqcwuNS1llVuXcQ6riFT3b5%2b44Sn56
> Bl14%3d.
> 
> Bart.
> 
> 

Yes, this has been fixed in that patch.

Please drop this one.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web