scsi: sd: Optimal I/O size should be a multiple of physical block size
authorMartin K. Petersen <martin.petersen@oracle.com>
Tue, 12 Feb 2019 21:21:05 +0000 (16:21 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Mar 2019 19:09:59 +0000 (20:09 +0100)
commit852a4ab292bbc878eb137cbc2197b7282c71ba5e
tree462411c8bab94abd5df19c0a788296b8a4eb0183
parente6e738e2b5fff96de2af39f15838fd21671aacf3
scsi: sd: Optimal I/O size should be a multiple of physical block size

commit a83da8a4509d3ebfe03bb7fffce022e4d5d4764f upstream.

It was reported that some devices report an OPTIMAL TRANSFER LENGTH of
0xFFFF blocks. That looks bogus, especially for a device with a
4096-byte physical block size.

Ignore OPTIMAL TRANSFER LENGTH if it is not a multiple of the device's
reported physical block size.

To make the sanity checking conditionals more readable--and to
facilitate printing warnings--relocate the checking to a helper
function. No functional change aside from the printks.

Cc: <stable@vger.kernel.org>
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=199759
Reported-by: Christoph Anton Mitterer <calestyo@scientia.net>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/scsi/sd.c