Commit 458919c470d3316ab86f5de005bc37ca9ae32a86
Committed by
Greg Kroah-Hartman
1 parent
0ee291a9b4
sd: Fix max transfer length for 4k disks
commit 3a9794d32984b67a6d8992226918618f0e51e5d5 upstream. 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. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Showing 1 changed file with 4 additions and 2 deletions Side-by-side Diff
drivers/scsi/sd.c
... | ... | @@ -2818,9 +2818,11 @@ |
2818 | 2818 | */ |
2819 | 2819 | sd_set_flush_flag(sdkp); |
2820 | 2820 | |
2821 | - max_xfer = min_not_zero(queue_max_hw_sectors(sdkp->disk->queue), | |
2822 | - sdkp->max_xfer_blocks); | |
2821 | + max_xfer = sdkp->max_xfer_blocks; | |
2823 | 2822 | max_xfer <<= ilog2(sdp->sector_size) - 9; |
2823 | + | |
2824 | + max_xfer = min_not_zero(queue_max_hw_sectors(sdkp->disk->queue), | |
2825 | + max_xfer); | |
2824 | 2826 | blk_queue_max_hw_sectors(sdkp->disk->queue, max_xfer); |
2825 | 2827 | set_capacity(disk, sdkp->capacity); |
2826 | 2828 | sd_config_write_same(sdkp); |