sd: Fix maximum I/O size for BLOCK_PC requests

Commit bcdb247c6b ("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+
Signed-off-by: James Bottomley <JBottomley@Odin.com>
This commit is contained in:
Martin K. Petersen 2015-06-23 12:13:59 -04:00 committed by James Bottomley
parent 8f2777f53e
commit 4f258a4634
2 changed files with 5 additions and 5 deletions

View file

@ -241,8 +241,8 @@ EXPORT_SYMBOL(blk_queue_bounce_limit);
* Description: * Description:
* Enables a low level driver to set a hard upper limit, * 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 * 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 * the device driver based upon the capabilities of the I/O
* controller and storage device. * controller.
* *
* max_sectors is a soft limit imposed by the block layer for * max_sectors is a soft limit imposed by the block layer for
* filesystem type requests. This value can be overridden on a * filesystem type requests. This value can be overridden on a

View file

@ -2770,9 +2770,9 @@ static int sd_revalidate_disk(struct gendisk *disk)
max_xfer = sdkp->max_xfer_blocks; max_xfer = sdkp->max_xfer_blocks;
max_xfer <<= ilog2(sdp->sector_size) - 9; max_xfer <<= ilog2(sdp->sector_size) - 9;
max_xfer = min_not_zero(queue_max_hw_sectors(sdkp->disk->queue), sdkp->disk->queue->limits.max_sectors =
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); set_capacity(disk, sdkp->capacity);
sd_config_write_same(sdkp); sd_config_write_same(sdkp);
kfree(buffer); kfree(buffer);