Skip to content

Commit 4f258a4

Browse files
martinkpetersenJames Bottomley
authored andcommitted
sd: Fix maximum I/O size for BLOCK_PC requests
Commit bcdb247 ("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 <[email protected]> Reported-by: Brian King <[email protected]> Tested-by: Brian King <[email protected]> Cc: [email protected] # 3.17+ Signed-off-by: James Bottomley <[email protected]>
1 parent 8f2777f commit 4f258a4

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

block/blk-settings.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ EXPORT_SYMBOL(blk_queue_bounce_limit);
241241
* Description:
242242
* Enables a low level driver to set a hard upper limit,
243243
* max_hw_sectors, on the size of requests. max_hw_sectors is set by
244-
* the device driver based upon the combined capabilities of I/O
245-
* controller and storage device.
244+
* the device driver based upon the capabilities of the I/O
245+
* controller.
246246
*
247247
* max_sectors is a soft limit imposed by the block layer for
248248
* filesystem type requests. This value can be overridden on a

drivers/scsi/sd.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2770,9 +2770,9 @@ static int sd_revalidate_disk(struct gendisk *disk)
27702770
max_xfer = sdkp->max_xfer_blocks;
27712771
max_xfer <<= ilog2(sdp->sector_size) - 9;
27722772

2773-
max_xfer = min_not_zero(queue_max_hw_sectors(sdkp->disk->queue),
2774-
max_xfer);
2775-
blk_queue_max_hw_sectors(sdkp->disk->queue, max_xfer);
2773+
sdkp->disk->queue->limits.max_sectors =
2774+
min_not_zero(queue_max_hw_sectors(sdkp->disk->queue), max_xfer);
2775+
27762776
set_capacity(disk, sdkp->capacity);
27772777
sd_config_write_same(sdkp);
27782778
kfree(buffer);

0 commit comments

Comments
 (0)