All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] [PATCH] block: Add blk_max_rw_sectors limit
@ 2015-06-15 19:02 Brian King
  2015-06-16 22:46 ` Martin K. Petersen
  0 siblings, 1 reply; 10+ messages in thread
From: Brian King @ 2015-06-15 19:02 UTC (permalink / raw)
  To: James.Bottomley; +Cc: linux-scsi, martin.petersen, hch, axboe, brking


The commit bcdb247c6b6a1f3e72b9b787b73f47dd509d17ec "sd: Limit transfer length"
added support for setting max_hw_sectors based on the block limits VPD page.
As defined in the transfer limit table in the block limits VPD page section
of SBC4, this value is only supposed to apply to a small subset of SCSI
opcodes. However, we are using that value for all SCSI commands. I ran into
this with a new disk drive we are qualifying which is reporting a value here
that is smaller than the size of its firmware image, which means
sg_write_buffer fails when trying to update the drive code. This patch adds a
new max_rw_sectors limit on the block device to reflect this max read/write
transfer size for media commands that the device supports. It restricts
max_sectors_kb from being set to a value larger than this and removes any
policing of per target limits for BLOCK_PC requests.

Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
---

 block/blk-settings.c   |   46 +++++++++++++++++++++++++++++++++++++++++++++-
 block/blk-sysfs.c      |    4 +++-
 drivers/scsi/sd.c      |    2 +-
 include/linux/blkdev.h |    8 ++++++++
 4 files changed, 57 insertions(+), 3 deletions(-)

diff -puN block/blk-settings.c~blk_max_rw_sectors2 block/blk-settings.c
--- linux/block/blk-settings.c~blk_max_rw_sectors2	2015-06-15 07:58:04.654048551 -0500
+++ linux-bjking1/block/blk-settings.c	2015-06-15 13:55:39.367136836 -0500
@@ -112,7 +112,7 @@ void blk_set_default_limits(struct queue
 	lim->max_integrity_segments = 0;
 	lim->seg_boundary_mask = BLK_SEG_BOUNDARY_MASK;
 	lim->max_segment_size = BLK_MAX_SEGMENT_SIZE;
-	lim->max_sectors = lim->max_hw_sectors = BLK_SAFE_MAX_SECTORS;
+	lim->max_sectors = lim->max_rw_sectors = lim->max_hw_sectors = BLK_SAFE_MAX_SECTORS;
 	lim->chunk_sectors = 0;
 	lim->max_write_same_sectors = 0;
 	lim->max_discard_sectors = 0;
@@ -145,6 +145,7 @@ void blk_set_stacking_limits(struct queu
 	lim->discard_zeroes_data = 1;
 	lim->max_segments = USHRT_MAX;
 	lim->max_hw_sectors = UINT_MAX;
+	lim->max_rw_sectors = UINT_MAX;
 	lim->max_segment_size = UINT_MAX;
 	lim->max_sectors = UINT_MAX;
 	lim->max_write_same_sectors = UINT_MAX;
@@ -262,6 +263,48 @@ void blk_limits_max_hw_sectors(struct qu
 EXPORT_SYMBOL(blk_limits_max_hw_sectors);
 
 /**
+ * blk_limits_max_rw_sectors - set hard and soft limit of max sectors for request
+ * @limits: the queue limits
+ * @max_rw_sectors:  max read/write sectors in the usual 512b unit
+ *
+ * Description:
+ *    Enables a low level driver to set a hard upper limit,
+ *    max_rw_sectors, on the size of requests.  max_rw_sectors is set by
+ *    the device driver based upon the capabilities of the storage device.
+ *    This limit does not apply to REQ_TYPE_BLOCK_PC requests.
+ *
+ *    max_sectors is a soft limit imposed by the block layer for
+ *    filesystem type requests.  This value can be overridden on a
+ *    per-device basis in /sys/block/<device>/queue/max_sectors_kb.
+ *    The soft limit can not exceed max_hw_sectors or max_rw_sectors
+ **/
+void blk_limits_max_rw_sectors(struct queue_limits *limits, unsigned int max_rw_sectors)
+{
+	if ((max_rw_sectors << 9) < PAGE_CACHE_SIZE) {
+		max_rw_sectors = 1 << (PAGE_CACHE_SHIFT - 9);
+		printk(KERN_INFO "%s: set to minimum %d\n",
+		       __func__, max_rw_sectors);
+	}
+
+	limits->max_sectors = limits->max_rw_sectors = max_rw_sectors;
+}
+EXPORT_SYMBOL(blk_limits_max_rw_sectors);
+
+/**
+ * blk_queue_max_rw_sectors - set max sectors for a request for this queue
+ * @q:  the request queue for the device
+ * @max_rw_sectors:  max read/write sectors in the usual 512b unit
+ *
+ * Description:
+ *    See description for blk_limits_max_rw_sectors().
+ **/
+void blk_queue_max_rw_sectors(struct request_queue *q, unsigned int max_rw_sectors)
+{
+	blk_limits_max_rw_sectors(&q->limits, max_rw_sectors);
+}
+EXPORT_SYMBOL(blk_queue_max_rw_sectors);
+
+/**
  * blk_queue_max_hw_sectors - set max sectors for a request for this queue
  * @q:  the request queue for the device
  * @max_hw_sectors:  max hardware sectors in the usual 512b unit
@@ -544,6 +587,7 @@ int blk_stack_limits(struct queue_limits
 
 	t->max_sectors = min_not_zero(t->max_sectors, b->max_sectors);
 	t->max_hw_sectors = min_not_zero(t->max_hw_sectors, b->max_hw_sectors);
+	t->max_rw_sectors = min_not_zero(t->max_rw_sectors, b->max_rw_sectors);
 	t->max_write_same_sectors = min(t->max_write_same_sectors,
 					b->max_write_same_sectors);
 	t->bounce_pfn = min_not_zero(t->bounce_pfn, b->bounce_pfn);
diff -puN block/blk-sysfs.c~blk_max_rw_sectors2 block/blk-sysfs.c
--- linux/block/blk-sysfs.c~blk_max_rw_sectors2	2015-06-15 07:58:04.658048519 -0500
+++ linux-bjking1/block/blk-sysfs.c	2015-06-15 07:58:04.680048347 -0500
@@ -167,13 +167,15 @@ queue_max_sectors_store(struct request_q
 {
 	unsigned long max_sectors_kb,
 		max_hw_sectors_kb = queue_max_hw_sectors(q) >> 1,
+			max_rw_sectors_kb = queue_max_rw_sectors(q) >> 1,
 			page_kb = 1 << (PAGE_CACHE_SHIFT - 10);
 	ssize_t ret = queue_var_store(&max_sectors_kb, page, count);
 
 	if (ret < 0)
 		return ret;
 
-	if (max_sectors_kb > max_hw_sectors_kb || max_sectors_kb < page_kb)
+	if (max_sectors_kb > max_hw_sectors_kb || max_sectors_kb < page_kb ||
+	    max_sectors_kb > max_rw_sectors_kb)
 		return -EINVAL;
 
 	spin_lock_irq(q->queue_lock);
diff -puN drivers/scsi/sd.c~blk_max_rw_sectors2 drivers/scsi/sd.c
--- linux/drivers/scsi/sd.c~blk_max_rw_sectors2	2015-06-15 07:58:04.665048465 -0500
+++ linux-bjking1/drivers/scsi/sd.c	2015-06-15 07:58:04.684048315 -0500
@@ -2781,7 +2781,7 @@ static int sd_revalidate_disk(struct gen
 
 	max_xfer = min_not_zero(queue_max_hw_sectors(sdkp->disk->queue),
 				max_xfer);
-	blk_queue_max_hw_sectors(sdkp->disk->queue, max_xfer);
+	blk_queue_max_rw_sectors(sdkp->disk->queue, max_xfer);
 	set_capacity(disk, sdkp->capacity);
 	sd_config_write_same(sdkp);
 	kfree(buffer);
diff -puN include/linux/blkdev.h~blk_max_rw_sectors2 include/linux/blkdev.h
--- linux/include/linux/blkdev.h~blk_max_rw_sectors2	2015-06-15 07:58:04.669048433 -0500
+++ linux-bjking1/include/linux/blkdev.h	2015-06-15 07:58:04.688048283 -0500
@@ -286,6 +286,7 @@ struct queue_limits {
 	unsigned long		seg_boundary_mask;
 
 	unsigned int		max_hw_sectors;
+	unsigned int		max_rw_sectors;
 	unsigned int		chunk_sectors;
 	unsigned int		max_sectors;
 	unsigned int		max_segment_size;
@@ -1004,7 +1005,9 @@ extern void blk_cleanup_queue(struct req
 extern void blk_queue_make_request(struct request_queue *, make_request_fn *);
 extern void blk_queue_bounce_limit(struct request_queue *, u64);
 extern void blk_limits_max_hw_sectors(struct queue_limits *, unsigned int);
+extern void blk_limits_max_rw_sectors(struct queue_limits *, unsigned int);
 extern void blk_queue_max_hw_sectors(struct request_queue *, unsigned int);
+extern void blk_queue_max_rw_sectors(struct request_queue *, unsigned int);
 extern void blk_queue_chunk_sectors(struct request_queue *, unsigned int);
 extern void blk_queue_max_segments(struct request_queue *, unsigned short);
 extern void blk_queue_max_segment_size(struct request_queue *, unsigned int);
@@ -1213,6 +1216,11 @@ static inline unsigned int queue_max_hw_
 	return q->limits.max_hw_sectors;
 }
 
+static inline unsigned int queue_max_rw_sectors(struct request_queue *q)
+{
+	return q->limits.max_rw_sectors;
+}
+
 static inline unsigned short queue_max_segments(struct request_queue *q)
 {
 	return q->limits.max_segments;
_


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

* Re: [PATCH 1/1] [PATCH] block: Add blk_max_rw_sectors limit
  2015-06-15 19:02 [PATCH 1/1] [PATCH] block: Add blk_max_rw_sectors limit Brian King
@ 2015-06-16 22:46 ` Martin K. Petersen
  2015-06-17 10:33   ` Christoph Hellwig
  2015-06-17 13:26   ` Brian King
  0 siblings, 2 replies; 10+ messages in thread
From: Martin K. Petersen @ 2015-06-16 22:46 UTC (permalink / raw)
  To: Brian King; +Cc: James.Bottomley, linux-scsi, martin.petersen, hch, axboe


Brian,

I only have minor nits wrt. your patch since you did what I asked.
However, now that I'm less jet lagged and blurry eyed I wonder if
the tweak below wouldn't suffice?


sd: Fix maximum I/O size for BLOCK_PC requests
    
Commit bcdb247c6b6a ("sd: Limit transfer length") clamped the maximum
size of an I/O request to the MAXIMUM TRANSFER LENGTH field in the BLOCK
LIMITS VPD. This had the unfortunate effect of also limiting the maximum
size of non-filesystem requests sent to the device through sg/bsg.

Avoid using blk_queue_max_hw_sectors() and set the max_sectors queue
limit directly.

Also update the comment in blk_limits_max_hw_sectors() to clarify that
max_hw_sectors defines the limit for the I/O controller only.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Reported-by: Brian King <brking@linux.vnet.ibm.com>
Cc: stable@vger.kernel.org # 3.17+

diff --git a/block/blk-settings.c b/block/blk-settings.c
index 12600bfffca9..e0057d035200 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -241,8 +241,8 @@ EXPORT_SYMBOL(blk_queue_bounce_limit);
  * Description:
  *    Enables a low level driver to set a hard upper limit,
  *    max_hw_sectors, on the size of requests.  max_hw_sectors is set by
- *    the device driver based upon the combined capabilities of I/O
- *    controller and storage device.
+ *    the device driver based upon the capabilities of the I/O
+ *    controller.
  *
  *    max_sectors is a soft limit imposed by the block layer for
  *    filesystem type requests.  This value can be overridden on a
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 79beebf53302..cfc0de75d763 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2779,9 +2779,9 @@ static int sd_revalidate_disk(struct gendisk *disk)
 	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);
+	sdkp->disk->queue->limits.max_sectors =
+		min_not_zero(queue_max_hw_sectors(sdkp->disk->queue), max_xfer);
+
 	set_capacity(disk, sdkp->capacity);
 	sd_config_write_same(sdkp);
 	kfree(buffer);

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

* Re: [PATCH 1/1] [PATCH] block: Add blk_max_rw_sectors limit
  2015-06-16 22:46 ` Martin K. Petersen
@ 2015-06-17 10:33   ` Christoph Hellwig
  2015-06-17 13:26   ` Brian King
  1 sibling, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2015-06-17 10:33 UTC (permalink / raw)
  To: Martin K. Petersen; +Cc: Brian King, James.Bottomley, linux-scsi, hch, axboe

On Tue, Jun 16, 2015 at 06:46:14PM -0400, Martin K. Petersen wrote:
> 
> Brian,
> 
> I only have minor nits wrt. your patch since you did what I asked.
> However, now that I'm less jet lagged and blurry eyed I wonder if
> the tweak below wouldn't suffice?

This would be my preferred version as well.

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

* Re: [PATCH 1/1] [PATCH] block: Add blk_max_rw_sectors limit
  2015-06-16 22:46 ` Martin K. Petersen
  2015-06-17 10:33   ` Christoph Hellwig
@ 2015-06-17 13:26   ` Brian King
  2015-06-23 16:13     ` [PATCH] sd: Fix maximum I/O size for BLOCK_PC requests Martin K. Petersen
  2015-07-16  1:13       ` Martin K. Petersen
  1 sibling, 2 replies; 10+ messages in thread
From: Brian King @ 2015-06-17 13:26 UTC (permalink / raw)
  To: Martin K. Petersen; +Cc: James.Bottomley, linux-scsi, hch, axboe

On 06/16/2015 05:46 PM, Martin K. Petersen wrote:
> 
> Brian,
> 
> I only have minor nits wrt. your patch since you did what I asked.
> However, now that I'm less jet lagged and blurry eyed I wonder if
> the tweak below wouldn't suffice?

Works for me. Thanks!

Tested-by: Brian King <brking@linux.vnet.ibm.com>

-Brian


-- 
Brian King
Power Linux I/O
IBM Linux Technology Center



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

* [PATCH] sd: Fix maximum I/O size for BLOCK_PC requests
  2015-06-17 13:26   ` Brian King
@ 2015-06-23 16:13     ` Martin K. Petersen
  2015-06-24 12:10       ` Christoph Hellwig
  2015-07-16  1:13       ` Martin K. Petersen
  1 sibling, 1 reply; 10+ messages in thread
From: Martin K. Petersen @ 2015-06-23 16:13 UTC (permalink / raw)
  To: linux-scsi; +Cc: brking, hch, Martin K. Petersen, stable

Commit bcdb247c6b6a ("sd: Limit transfer length") clamped the maximum
size of an I/O request to the MAXIMUM TRANSFER LENGTH field in the BLOCK
LIMITS VPD. This had the unfortunate effect of also limiting the maximum
size of non-filesystem requests sent to the device through sg/bsg.

Avoid using blk_queue_max_hw_sectors() and set the max_sectors queue
limit directly.

Also update the comment in blk_limits_max_hw_sectors() to clarify that
max_hw_sectors defines the limit for the I/O controller only.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Reported-by: Brian King <brking@linux.vnet.ibm.com>
Tested-by: Brian King <brking@linux.vnet.ibm.com>
Cc: stable@vger.kernel.org # 3.17+
---
 block/blk-settings.c | 4 ++--
 drivers/scsi/sd.c    | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/block/blk-settings.c b/block/blk-settings.c
index 12600bfffca9..e0057d035200 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -241,8 +241,8 @@ EXPORT_SYMBOL(blk_queue_bounce_limit);
  * Description:
  *    Enables a low level driver to set a hard upper limit,
  *    max_hw_sectors, on the size of requests.  max_hw_sectors is set by
- *    the device driver based upon the combined capabilities of I/O
- *    controller and storage device.
+ *    the device driver based upon the capabilities of the I/O
+ *    controller.
  *
  *    max_sectors is a soft limit imposed by the block layer for
  *    filesystem type requests.  This value can be overridden on a
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 3b2fcb4fada0..a20da8c25b4f 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2770,9 +2770,9 @@ static int sd_revalidate_disk(struct gendisk *disk)
 	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);
+	sdkp->disk->queue->limits.max_sectors =
+		min_not_zero(queue_max_hw_sectors(sdkp->disk->queue), max_xfer);
+
 	set_capacity(disk, sdkp->capacity);
 	sd_config_write_same(sdkp);
 	kfree(buffer);
-- 
2.4.3


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

* Re: [PATCH] sd: Fix maximum I/O size for BLOCK_PC requests
  2015-06-23 16:13     ` [PATCH] sd: Fix maximum I/O size for BLOCK_PC requests Martin K. Petersen
@ 2015-06-24 12:10       ` Christoph Hellwig
  0 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2015-06-24 12:10 UTC (permalink / raw)
  To: Martin K. Petersen; +Cc: linux-scsi, brking, hch, stable

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* [PATCH] sd: Fix maximum I/O size for BLOCK_PC requests
  2015-06-17 13:26   ` Brian King
@ 2015-07-16  1:13       ` Martin K. Petersen
  2015-07-16  1:13       ` Martin K. Petersen
  1 sibling, 0 replies; 10+ messages in thread
From: Martin K. Petersen @ 2015-07-16  1:13 UTC (permalink / raw)
  To: linux-scsi; +Cc: Martin K. Petersen, stable

Commit bcdb247c6b6a ("sd: Limit transfer length") clamped the maximum
size of an I/O request to the MAXIMUM TRANSFER LENGTH field in the BLOCK
LIMITS VPD. This had the unfortunate effect of also limiting the maximum
size of non-filesystem requests sent to the device through sg/bsg.

Avoid using blk_queue_max_hw_sectors() and set the max_sectors queue
limit directly.

Also update the comment in blk_limits_max_hw_sectors() to clarify that
max_hw_sectors defines the limit for the I/O controller only.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Reported-by: Brian King <brking@linux.vnet.ibm.com>
Tested-by: Brian King <brking@linux.vnet.ibm.com>
Cc: <stable@vger.kernel.org> # 3.17+
---
 block/blk-settings.c | 4 ++--
 drivers/scsi/sd.c    | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/block/blk-settings.c b/block/blk-settings.c
index 12600bfffca9..e0057d035200 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -241,8 +241,8 @@ EXPORT_SYMBOL(blk_queue_bounce_limit);
  * Description:
  *    Enables a low level driver to set a hard upper limit,
  *    max_hw_sectors, on the size of requests.  max_hw_sectors is set by
- *    the device driver based upon the combined capabilities of I/O
- *    controller and storage device.
+ *    the device driver based upon the capabilities of the I/O
+ *    controller.
  *
  *    max_sectors is a soft limit imposed by the block layer for
  *    filesystem type requests.  This value can be overridden on a
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 3b2fcb4fada0..a20da8c25b4f 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2770,9 +2770,9 @@ static int sd_revalidate_disk(struct gendisk *disk)
 	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);
+	sdkp->disk->queue->limits.max_sectors =
+		min_not_zero(queue_max_hw_sectors(sdkp->disk->queue), max_xfer);
+
 	set_capacity(disk, sdkp->capacity);
 	sd_config_write_same(sdkp);
 	kfree(buffer);
-- 
2.4.3


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

* [PATCH] sd: Fix maximum I/O size for BLOCK_PC requests
@ 2015-07-16  1:13       ` Martin K. Petersen
  0 siblings, 0 replies; 10+ messages in thread
From: Martin K. Petersen @ 2015-07-16  1:13 UTC (permalink / raw)
  To: linux-scsi; +Cc: Martin K. Petersen, stable

Commit bcdb247c6b6a ("sd: Limit transfer length") clamped the maximum
size of an I/O request to the MAXIMUM TRANSFER LENGTH field in the BLOCK
LIMITS VPD. This had the unfortunate effect of also limiting the maximum
size of non-filesystem requests sent to the device through sg/bsg.

Avoid using blk_queue_max_hw_sectors() and set the max_sectors queue
limit directly.

Also update the comment in blk_limits_max_hw_sectors() to clarify that
max_hw_sectors defines the limit for the I/O controller only.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Reported-by: Brian King <brking@linux.vnet.ibm.com>
Tested-by: Brian King <brking@linux.vnet.ibm.com>
Cc: <stable@vger.kernel.org> # 3.17+
---
 block/blk-settings.c | 4 ++--
 drivers/scsi/sd.c    | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/block/blk-settings.c b/block/blk-settings.c
index 12600bfffca9..e0057d035200 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -241,8 +241,8 @@ EXPORT_SYMBOL(blk_queue_bounce_limit);
  * Description:
  *    Enables a low level driver to set a hard upper limit,
  *    max_hw_sectors, on the size of requests.  max_hw_sectors is set by
- *    the device driver based upon the combined capabilities of I/O
- *    controller and storage device.
+ *    the device driver based upon the capabilities of the I/O
+ *    controller.
  *
  *    max_sectors is a soft limit imposed by the block layer for
  *    filesystem type requests.  This value can be overridden on a
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 3b2fcb4fada0..a20da8c25b4f 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2770,9 +2770,9 @@ static int sd_revalidate_disk(struct gendisk *disk)
 	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);
+	sdkp->disk->queue->limits.max_sectors =
+		min_not_zero(queue_max_hw_sectors(sdkp->disk->queue), max_xfer);
+
 	set_capacity(disk, sdkp->capacity);
 	sd_config_write_same(sdkp);
 	kfree(buffer);
-- 
2.4.3

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

* Re: [PATCH] sd: Fix maximum I/O size for BLOCK_PC requests
  2015-07-16  1:13       ` Martin K. Petersen
@ 2015-07-16 11:12         ` Hannes Reinecke
  -1 siblings, 0 replies; 10+ messages in thread
From: Hannes Reinecke @ 2015-07-16 11:12 UTC (permalink / raw)
  To: Martin K. Petersen, linux-scsi; +Cc: stable

On 07/16/2015 03:13 AM, Martin K. Petersen wrote:
> Commit bcdb247c6b6a ("sd: Limit transfer length") clamped the maximum
> size of an I/O request to the MAXIMUM TRANSFER LENGTH field in the BLOCK
> LIMITS VPD. This had the unfortunate effect of also limiting the maximum
> size of non-filesystem requests sent to the device through sg/bsg.
> 
> Avoid using blk_queue_max_hw_sectors() and set the max_sectors queue
> limit directly.
> 
> Also update the comment in blk_limits_max_hw_sectors() to clarify that
> max_hw_sectors defines the limit for the I/O controller only.
> 
> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
> Reported-by: Brian King <brking@linux.vnet.ibm.com>
> Tested-by: Brian King <brking@linux.vnet.ibm.com>
> Cc: <stable@vger.kernel.org> # 3.17+
> ---
>  block/blk-settings.c | 4 ++--
>  drivers/scsi/sd.c    | 6 +++---
>  2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/block/blk-settings.c b/block/blk-settings.c
> index 12600bfffca9..e0057d035200 100644
> --- a/block/blk-settings.c
> +++ b/block/blk-settings.c
> @@ -241,8 +241,8 @@ EXPORT_SYMBOL(blk_queue_bounce_limit);
>   * Description:
>   *    Enables a low level driver to set a hard upper limit,
>   *    max_hw_sectors, on the size of requests.  max_hw_sectors is set by
> - *    the device driver based upon the combined capabilities of I/O
> - *    controller and storage device.
> + *    the device driver based upon the capabilities of the I/O
> + *    controller.
>   *
>   *    max_sectors is a soft limit imposed by the block layer for
>   *    filesystem type requests.  This value can be overridden on a
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index 3b2fcb4fada0..a20da8c25b4f 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -2770,9 +2770,9 @@ static int sd_revalidate_disk(struct gendisk *disk)
>  	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);
> +	sdkp->disk->queue->limits.max_sectors =
> +		min_not_zero(queue_max_hw_sectors(sdkp->disk->queue), max_xfer);
> +
>  	set_capacity(disk, sdkp->capacity);
>  	sd_config_write_same(sdkp);
>  	kfree(buffer);
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		               zSeries & Storage
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg
GF: F. Imend�rffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG N�rnberg)

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

* Re: [PATCH] sd: Fix maximum I/O size for BLOCK_PC requests
@ 2015-07-16 11:12         ` Hannes Reinecke
  0 siblings, 0 replies; 10+ messages in thread
From: Hannes Reinecke @ 2015-07-16 11:12 UTC (permalink / raw)
  To: Martin K. Petersen, linux-scsi; +Cc: stable

On 07/16/2015 03:13 AM, Martin K. Petersen wrote:
> Commit bcdb247c6b6a ("sd: Limit transfer length") clamped the maximum
> size of an I/O request to the MAXIMUM TRANSFER LENGTH field in the BLOCK
> LIMITS VPD. This had the unfortunate effect of also limiting the maximum
> size of non-filesystem requests sent to the device through sg/bsg.
> 
> Avoid using blk_queue_max_hw_sectors() and set the max_sectors queue
> limit directly.
> 
> Also update the comment in blk_limits_max_hw_sectors() to clarify that
> max_hw_sectors defines the limit for the I/O controller only.
> 
> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
> Reported-by: Brian King <brking@linux.vnet.ibm.com>
> Tested-by: Brian King <brking@linux.vnet.ibm.com>
> Cc: <stable@vger.kernel.org> # 3.17+
> ---
>  block/blk-settings.c | 4 ++--
>  drivers/scsi/sd.c    | 6 +++---
>  2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/block/blk-settings.c b/block/blk-settings.c
> index 12600bfffca9..e0057d035200 100644
> --- a/block/blk-settings.c
> +++ b/block/blk-settings.c
> @@ -241,8 +241,8 @@ EXPORT_SYMBOL(blk_queue_bounce_limit);
>   * Description:
>   *    Enables a low level driver to set a hard upper limit,
>   *    max_hw_sectors, on the size of requests.  max_hw_sectors is set by
> - *    the device driver based upon the combined capabilities of I/O
> - *    controller and storage device.
> + *    the device driver based upon the capabilities of the I/O
> + *    controller.
>   *
>   *    max_sectors is a soft limit imposed by the block layer for
>   *    filesystem type requests.  This value can be overridden on a
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index 3b2fcb4fada0..a20da8c25b4f 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -2770,9 +2770,9 @@ static int sd_revalidate_disk(struct gendisk *disk)
>  	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);
> +	sdkp->disk->queue->limits.max_sectors =
> +		min_not_zero(queue_max_hw_sectors(sdkp->disk->queue), max_xfer);
> +
>  	set_capacity(disk, sdkp->capacity);
>  	sd_config_write_same(sdkp);
>  	kfree(buffer);
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		               zSeries & Storage
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

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

end of thread, other threads:[~2015-07-16 11:12 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-15 19:02 [PATCH 1/1] [PATCH] block: Add blk_max_rw_sectors limit Brian King
2015-06-16 22:46 ` Martin K. Petersen
2015-06-17 10:33   ` Christoph Hellwig
2015-06-17 13:26   ` Brian King
2015-06-23 16:13     ` [PATCH] sd: Fix maximum I/O size for BLOCK_PC requests Martin K. Petersen
2015-06-24 12:10       ` Christoph Hellwig
2015-07-16  1:13     ` Martin K. Petersen
2015-07-16  1:13       ` Martin K. Petersen
2015-07-16 11:12       ` Hannes Reinecke
2015-07-16 11:12         ` Hannes Reinecke

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.