diff options
author | Fam Zheng <famz@redhat.com> | 2017-03-28 12:41:26 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-04-21 09:32:39 +0200 |
commit | 8b30ed56fa89c14f9850438b48fe8a3fa0005e47 (patch) | |
tree | e550ddefa8e73d0bd2d58a593a04a19b89d7ba10 | |
parent | 01fb9440938af4083e4883a3190980fee8fa7e00 (diff) | |
download | linux-stable-8b30ed56fa89c14f9850438b48fe8a3fa0005e47.tar.gz linux-stable-8b30ed56fa89c14f9850438b48fe8a3fa0005e47.tar.bz2 linux-stable-8b30ed56fa89c14f9850438b48fe8a3fa0005e47.zip |
scsi: sd: Consider max_xfer_blocks if opt_xfer_blocks is unusable
commit 6780414519f91c2a84da9baa963a940ac916f803 upstream.
If device reports a small max_xfer_blocks and a zero opt_xfer_blocks, we
end up using BLK_DEF_MAX_SECTORS, which is wrong and r/w of that size
may get error.
[mkp: tweaked to avoid setting rw_max twice and added typecast]
Fixes: ca369d51b3e ("block/sd: Fix device-imposed transfer length limits")
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/scsi/sd.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 1ee57619c95e..cc089fb22ae9 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2963,7 +2963,8 @@ static int sd_revalidate_disk(struct gendisk *disk) q->limits.io_opt = logical_to_bytes(sdp, sdkp->opt_xfer_blocks); rw_max = logical_to_sectors(sdp, sdkp->opt_xfer_blocks); } else - rw_max = BLK_DEF_MAX_SECTORS; + rw_max = min_not_zero(logical_to_sectors(sdp, dev_max), + (sector_t)BLK_DEF_MAX_SECTORS); /* Combine with controller limits */ q->limits.max_sectors = min(rw_max, queue_max_hw_sectors(q)); |