summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Bottomley <James.Bottomley@HansenPartnership.com>2015-12-28 07:19:58 -0800
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2015-12-28 07:19:58 -0800
commitf9ec0d559ef8d36266b52314e8c0158327572726 (patch)
tree5e5116e20d793367a3a245ff4dfc3cace17cb723
parented94724bedcbc40cbfc12d16990e834d64220d3f (diff)
parent9c1d9c207bb800498347a2716da298043ee280c5 (diff)
Merge remote-tracking branch 'mkp-scsi/4.4/scsi-fixes' into fixes
-rw-r--r--drivers/scsi/sd.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 3d22fc3e3c1a..4e08d1cd704d 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2885,10 +2885,13 @@ static int sd_revalidate_disk(struct gendisk *disk)
/*
* Use the device's preferred I/O size for reads and writes
- * unless the reported value is unreasonably large (or garbage).
+ * unless the reported value is unreasonably small, large, or
+ * garbage.
*/
- if (sdkp->opt_xfer_blocks && sdkp->opt_xfer_blocks <= dev_max &&
- sdkp->opt_xfer_blocks <= SD_DEF_XFER_BLOCKS)
+ if (sdkp->opt_xfer_blocks &&
+ sdkp->opt_xfer_blocks <= dev_max &&
+ sdkp->opt_xfer_blocks <= SD_DEF_XFER_BLOCKS &&
+ sdkp->opt_xfer_blocks * sdp->sector_size >= PAGE_CACHE_SIZE)
rw_max = q->limits.io_opt =
logical_to_sectors(sdp, sdkp->opt_xfer_blocks);
else