summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFam Zheng <famz@redhat.com>2017-03-28 12:41:26 +0800
committerMartin K. Petersen <martin.petersen@oracle.com>2017-04-07 17:05:15 -0400
commit6780414519f91c2a84da9baa963a940ac916f803 (patch)
tree118f22f4a52c2389b90c19cccc0dce45068db62e
parenta3902ee98304324f681088203391b5c0353ce977 (diff)
downloadblackbird-op-linux-6780414519f91c2a84da9baa963a940ac916f803.tar.gz
blackbird-op-linux-6780414519f91c2a84da9baa963a940ac916f803.zip
scsi: sd: Consider max_xfer_blocks if opt_xfer_blocks is unusable
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] Cc: <stable@vger.kernel.org> # v4.4+ 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>
-rw-r--r--drivers/scsi/sd.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index fb9b4d29af0b..906cd6bfa2a9 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2956,7 +2956,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));
OpenPOWER on IntegriCloud