diff mbox series

scsi: sd: Quiesce warning if device does not report optimal I/O size

Message ID 20190327161152.23401-1-martin.petersen@oracle.com (mailing list archive)
State Mainlined
Commit 1d5de5bd311be7cd54f02f7cd164f0349a75c876
Headers show
Series scsi: sd: Quiesce warning if device does not report optimal I/O size | expand

Commit Message

Martin K. Petersen March 27, 2019, 4:11 p.m. UTC
Commit a83da8a4509d ("scsi: sd: Optimal I/O size should be a multiple
of physical block size") split one conditional into several separate
statements in an effort to provide more accurate warning messages when
a device reports a nonsensical value. However, this reorganization
accidentally dropped the precondition of the reported value being
larger than zero. This lead to a warning getting emitted on devices
that do not report an optimal I/O size at all.

Remain silent if a device does not report an optimal I/O size.

Fixes: a83da8a4509d ("scsi: sd: Optimal I/O size should be a multiple of physical block size")
Reported-by: Hussam Al-Tayeb <ht990332@gmx.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
---
 drivers/scsi/sd.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Bart Van Assche March 27, 2019, 4:46 p.m. UTC | #1
On Wed, 2019-03-27 at 12:11 -0400, Martin K. Petersen wrote:
> Commit a83da8a4509d ("scsi: sd: Optimal I/O size should be a multiple
> of physical block size") split one conditional into several separate
> statements in an effort to provide more accurate warning messages when
> a device reports a nonsensical value. However, this reorganization
> accidentally dropped the precondition of the reported value being
> larger than zero. This lead to a warning getting emitted on devices
> that do not report an optimal I/O size at all.
> 
> Remain silent if a device does not report an optimal I/O size.
> 
> Fixes: a83da8a4509d ("scsi: sd: Optimal I/O size should be a multiple of physical block size")
> Reported-by: Hussam Al-Tayeb <ht990332@gmx.com>
> Cc: Randy Dunlap <rdunlap@infradead.org>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Hussam Al-Tayeb March 27, 2019, 6:05 p.m. UTC | #2
On Wed, 2019-03-27 at 09:46 -0700, Bart Van Assche wrote:
> On Wed, 2019-03-27 at 12:11 -0400, Martin K. Petersen wrote:
> > Commit a83da8a4509d ("scsi: sd: Optimal I/O size should be a
> > multiple
> > of physical block size") split one conditional into several
> > separate
> > statements in an effort to provide more accurate warning messages
> > when
> > a device reports a nonsensical value. However, this reorganization
> > accidentally dropped the precondition of the reported value being
> > larger than zero. This lead to a warning getting emitted on devices
> > that do not report an optimal I/O size at all.
> >
> > Remain silent if a device does not report an optimal I/O size.
> >
> > Fixes: a83da8a4509d ("scsi: sd: Optimal I/O size should be a
> > multiple of physical block size")
> > Reported-by: Hussam Al-Tayeb <ht990332@gmx.com>
> > Cc: Randy Dunlap <rdunlap@infradead.org>
> > Cc: <stable@vger.kernel.org>
> > Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
>
> Reviewed-by: Bart Van Assche <bvanassche@acm.org>
>
>

I tested two SATA disks and three usb flash drives on two machines. The
warnings are gone.
Thank you very much for the patch.
diff mbox series

Patch

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 9d8e15d03d2b..87d542de2db7 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3074,6 +3074,9 @@  static bool sd_validate_opt_xfer_size(struct scsi_disk *sdkp,
 	unsigned int opt_xfer_bytes =
 		logical_to_bytes(sdp, sdkp->opt_xfer_blocks);
 
+	if (sdkp->opt_xfer_blocks == 0)
+		return false;
+
 	if (sdkp->opt_xfer_blocks > dev_max) {
 		sd_first_printk(KERN_WARNING, sdkp,
 				"Optimal transfer size %u logical blocks " \