aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin K. Petersen <martin.petersen@oracle.com>2015-12-16 17:53:52 -0500
committerMartin K. Petersen <martin.petersen@oracle.com>2015-12-21 21:37:18 -0500
commit9c1d9c207bb800498347a2716da298043ee280c5 (patch)
treee05d8f3b152b028d81d5b2694dfd533023bf54db
parent1c69d3b6eb73e466ecbb8edaf1bc7fd585b288da (diff)
sd: Reject optimal transfer length smaller than page size
Eryu Guan reported that loading scsi_debug would fail. This turned out to be caused by scsi_debug reporting an optimal I/O size of 32KB which is smaller than the 64KB page size on the PowerPC system in question. Add a check to ensure that we only use the device-reported OPTIMAL TRANSFER LENGTH if it is bigger than or equal to the page cache size. Reported-by: Eryu Guan <guaneryu@gmail.com> Reported-by: Ming Lei <tom.leiming@gmail.com> Reviewed-by: Douglas Gilbert <dgilbert@interlog.com> Reviewed-by: Ewan Milne <emilne@redhat.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-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)
2885 2885
2886 /* 2886 /*
2887 * Use the device's preferred I/O size for reads and writes 2887 * Use the device's preferred I/O size for reads and writes
2888 * unless the reported value is unreasonably large (or garbage). 2888 * unless the reported value is unreasonably small, large, or
2889 * garbage.
2889 */ 2890 */
2890 if (sdkp->opt_xfer_blocks && sdkp->opt_xfer_blocks <= dev_max && 2891 if (sdkp->opt_xfer_blocks &&
2891 sdkp->opt_xfer_blocks <= SD_DEF_XFER_BLOCKS) 2892 sdkp->opt_xfer_blocks <= dev_max &&
2893 sdkp->opt_xfer_blocks <= SD_DEF_XFER_BLOCKS &&
2894 sdkp->opt_xfer_blocks * sdp->sector_size >= PAGE_CACHE_SIZE)
2892 rw_max = q->limits.io_opt = 2895 rw_max = q->limits.io_opt =
2893 logical_to_sectors(sdp, sdkp->opt_xfer_blocks); 2896 logical_to_sectors(sdp, sdkp->opt_xfer_blocks);
2894 else 2897 else