diff options
author | Brian King <brking@linux.vnet.ibm.com> | 2015-01-29 16:54:40 -0500 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2015-02-02 07:46:29 -0500 |
commit | 3a9794d32984b67a6d8992226918618f0e51e5d5 (patch) | |
tree | 63a25d8d1d8b851c97a0d24e334f1a317d07fb63 | |
parent | 28072ad50ca7328bd99f9dba94ac27c723da0053 (diff) |
sd: Fix max transfer length for 4k disks
The following patch fixes an issue observed with 4k sector disks
where the max_hw_sectors attribute was getting set too large in
sd_revalidate_disk. Since sdkp->max_xfer_blocks is in units
of SCSI logical blocks and queue_max_hw_sectors is in units of
512 byte blocks, on a 4k sector disk, every time we went through
sd_revalidate_disk, we were taking the current value of
queue_max_hw_sectors and increasing it by a factor of 8. Fix
this by only shifting sdkp->max_xfer_blocks.
Cc: stable@vger.kernel.org
Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
-rw-r--r-- | drivers/scsi/sd.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 399516925d80..05ea0d49a3a3 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -2800,9 +2800,11 @@ static int sd_revalidate_disk(struct gendisk *disk) | |||
2800 | */ | 2800 | */ |
2801 | sd_set_flush_flag(sdkp); | 2801 | sd_set_flush_flag(sdkp); |
2802 | 2802 | ||
2803 | max_xfer = min_not_zero(queue_max_hw_sectors(sdkp->disk->queue), | 2803 | max_xfer = sdkp->max_xfer_blocks; |
2804 | sdkp->max_xfer_blocks); | ||
2805 | max_xfer <<= ilog2(sdp->sector_size) - 9; | 2804 | max_xfer <<= ilog2(sdp->sector_size) - 9; |
2805 | |||
2806 | max_xfer = min_not_zero(queue_max_hw_sectors(sdkp->disk->queue), | ||
2807 | max_xfer); | ||
2806 | blk_queue_max_hw_sectors(sdkp->disk->queue, max_xfer); | 2808 | blk_queue_max_hw_sectors(sdkp->disk->queue, max_xfer); |
2807 | set_capacity(disk, sdkp->capacity); | 2809 | set_capacity(disk, sdkp->capacity); |
2808 | sd_config_write_same(sdkp); | 2810 | sd_config_write_same(sdkp); |