scsi: sd: Consider max_xfer_blocks if opt_xfer_blocks is unusable
authorFam Zheng <famz@redhat.com>
Tue, 28 Mar 2017 04:41:26 +0000 (12:41 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Apr 2017 07:30:05 +0000 (09:30 +0200)
commit448961955592c46f1490fb6ca8d3e52ce17e6222
treeab323e276e470ef4db1491220b8523a3cc7bb1a9
parent925adae6664c0b9f5193876e9aeb2640a7e977d5
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>
drivers/scsi/sd.c