Skip to content

Commit 4489619

Browse files
Fam Zhenggregkh
authored andcommitted
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: ca369d5 ("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>
1 parent 925adae commit 4489619

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/scsi/sd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2888,7 +2888,8 @@ static int sd_revalidate_disk(struct gendisk *disk)
28882888
q->limits.io_opt = logical_to_bytes(sdp, sdkp->opt_xfer_blocks);
28892889
rw_max = logical_to_sectors(sdp, sdkp->opt_xfer_blocks);
28902890
} else
2891-
rw_max = BLK_DEF_MAX_SECTORS;
2891+
rw_max = min_not_zero(logical_to_sectors(sdp, dev_max),
2892+
(sector_t)BLK_DEF_MAX_SECTORS);
28922893

28932894
/* Combine with controller limits */
28942895
q->limits.max_sectors = min(rw_max, queue_max_hw_sectors(q));

0 commit comments

Comments
 (0)