]> git.baikalelectronics.ru Git - kernel.git/commit
scsi: sd: Fix optimal I/O size for devices that change reported values
authorMartin K. Petersen <martin.petersen@oracle.com>
Tue, 24 Mar 2020 15:16:15 +0000 (11:16 -0400)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 25 Mar 2020 02:53:04 +0000 (22:53 -0400)
commitffb8ca7ba1f53113c04e9d561be3b7f51396ec4a
treeb8213bdd031109e276199b4fcb6f527492d12a47
parentde69692fc48124d9c112b02ed56f92b18e04aaf7
scsi: sd: Fix optimal I/O size for devices that change reported values

Some USB bridge devices will return a default set of characteristics during
initialization. And then, once an attached drive has spun up, substitute
the actual parameters reported by the drive. According to the SCSI spec,
the device should return a UNIT ATTENTION in case any reported parameters
change. But in this case the change is made silently after a small window
where default values are reported.

Commit 3b0a40f6315f ("scsi: sd: Optimal I/O size should be a multiple of
physical block size") validated the reported optimal I/O size against the
physical block size to overcome problems with devices reporting nonsensical
transfer sizes. However, this validation did not account for the fact that
aforementioned devices will return default values during a brief window
during spin-up. The subsequent change in reported characteristics would
invalidate the checking that had previously been performed.

Unset a previously configured optimal I/O size should the sanity checking
fail on subsequent revalidate attempts.

Link: https://lore.kernel.org/r/33fb522e-4f61-1b76-914f-c9e6a3553c9b@gmail.com
Cc: Bryan Gurney <bgurney@redhat.com>
Cc: <stable@vger.kernel.org>
Reported-by: Bernhard Sulzer <micraft.b@gmail.com>
Tested-by: Bernhard Sulzer <micraft.b@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/sd.c