Skip to contentSkip to conversation

Use the correct size to set block max sectors

PATCH In review Long Li 5 participants 7 messages May 26, 2016 – Jun 3, 2016 SCSI

lore
Share & tools
lore

Long Li

author
#0 lore raw

PATCH 1/1 Use the correct size to set block max sectors

The block sector size should be in unit of 512 bytes, not in bytes.

---
 drivers/scsi/sd.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/scsi/sd.c +4 -2
index 428c03e..4bce17e 100644
@@ -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;
 
Signature · 1 line
1.8.5.6
#1 lore raw
Quoted 13 lines · Long Li

The block sector size should be in unit of 512 bytes, not in bytes.

---
 drivers/scsi/sd.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/scsi/sd.c +0 -0
index 428c03e..4bce17e 100644

drivers/scsi/sd.c static int sd_revalidate_disk(struct gendisk *disk) · line 2868

Quoted 9 lines
drivers/scsi/sd.c +3 -2
@@ -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

Quoted 11 lines
drivers/scsi/sd.c +1 -0
+	}
 	else
 		rw_max = BLK_DEF_MAX_SECTORS;
 
Signature · 6 lines
1.8.5.6

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
In reply to Long Li
Quoted 1 line · Long Li

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.

drivers/scsi/sd.c

Quoted 1 line
drivers/scsi/sd.c +0 -0

[]

Quoted 11 lines
drivers/scsi/sd.c +0 -0
@@ -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 &&

drivers/scsi/sd.c +2 -2
-	    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;

drivers/scsi/sd.c +2 -0
+		rw_max = (q->limits.io_opt >> 9);
+	}
Quoted 2 lines

  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.

#3 lore raw
In reply to Long Li
Quoted 15 lines · Long Li

The block sector size should be in unit of 512 bytes, not in bytes.

---
 drivers/scsi/sd.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/scsi/sd.c +0 -0
index 428c03e..4bce17e 100644
@@ -2862,9 +2862,11 @@ static int sd_revalidate_disk(struct gendisk *disk)
 	if (sdkp->opt_xfer_blocks &&
 	    sdkp->opt_xfer_blocks <= dev_max &&

drivers/scsi/sd.c static int sd_revalidate_disk(struct gendisk *disk) · line 2871

Quoted 10 lines
drivers/scsi/sd.c +4 -2
 	    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 http://thread.gmane.org/gmane.linux.scsi/113746.

Bart.

author
#4 lore raw
Quoted 45 lines

-----Original Message-----
From: Bart Van Assche [mailto:[email protected]]
Sent: Thursday, May 26, 2016 7:19 PM
To: Long Li <[email protected]>; James E.J. Bottomley <[email protected]>; Martin K. Petersen <[email protected]>
Cc: KY Srinivasan <[email protected]>; [email protected]; linux- [email protected]
Subject: Re: [PATCH] Use the correct size to set block max sectors

Quoted 15 lines · Long Li

The block sector size should be in unit of 512 bytes, not in bytes.

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

428c03e..4bce17e 100644

drivers/scsi/sd.c +0 -0
@@ -2862,9 +2862,11 @@ static int sd_revalidate_disk(struct gendisk *disk)
 	if (sdkp->opt_xfer_blocks &&
 	    sdkp->opt_xfer_blocks <= dev_max &&

drivers/scsi/sd.c static int sd_revalidate_disk(struct gendisk *disk) · line 2871

Quoted 10 lines
drivers/scsi/sd.c +4 -2
 	    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.

Quoted 3 lines

Bart.

Yes, this has been fixed in that patch.

Please drop this one.

#5 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Long" == Long Li <[email protected]> writes:

Long,

Long> Yes, this has been fixed in that patch.

I'd like to get my patch into scsi-fixes but it needs another set of eyes. Would you mind either testing or reviewing it?

Thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
author
#6 lore raw

Hi Martin,

Yes I would like to test it. Please let me know when they get in there.

Thanks

Long

Quoted 23 lines

-----Original Message-----
From: Martin K. Petersen [mailto:[email protected]]
Sent: Tuesday, May 31, 2016 7:44 PM
To: Long Li <[email protected]>
Cc: Bart Van Assche <[email protected]>; James E.J. Bottomley <[email protected]>; Martin K. Petersen <[email protected]>; KY Srinivasan <[email protected]>; linux- [email protected]; [email protected]
Subject: Re: [PATCH] Use the correct size to set block max sectors

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Long" == Long Li <[email protected]> writes:

Long,

Long> Yes, this has been fixed in that patch.

I'd like to get my patch into scsi-fixes but it needs another set of eyes. Would you mind either testing or reviewing it?

Thanks!

--
Martin K. Petersen Oracle Linux Engineering