stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: sd: Quiesce warning if device does not report optimal I/O size
       [not found] <25d0ddcb-b603-6e0d-d512-b188813837bf@infradead.org>
@ 2019-03-27 16:11 ` Martin K. Petersen
  2019-03-27 16:46   ` Bart Van Assche
  0 siblings, 1 reply; 3+ messages in thread
From: Martin K. Petersen @ 2019-03-27 16:11 UTC (permalink / raw)
  To: linux-scsi; +Cc: Martin K. Petersen, Hussam Al-Tayeb, Randy Dunlap, stable

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(+)

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 " \
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] scsi: sd: Quiesce warning if device does not report optimal I/O size
  2019-03-27 16:11 ` [PATCH] scsi: sd: Quiesce warning if device does not report optimal I/O size Martin K. Petersen
@ 2019-03-27 16:46   ` Bart Van Assche
  2019-03-27 18:05     ` Hussam Al-Tayeb
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Van Assche @ 2019-03-27 16:46 UTC (permalink / raw)
  To: Martin K. Petersen, linux-scsi; +Cc: Hussam Al-Tayeb, Randy Dunlap, stable

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>



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] scsi: sd: Quiesce warning if device does not report optimal I/O size
  2019-03-27 16:46   ` Bart Van Assche
@ 2019-03-27 18:05     ` Hussam Al-Tayeb
  0 siblings, 0 replies; 3+ messages in thread
From: Hussam Al-Tayeb @ 2019-03-27 18:05 UTC (permalink / raw)
  To: Bart Van Assche, Martin K. Petersen, linux-scsi; +Cc: Randy Dunlap, stable

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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-03-27 19:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <25d0ddcb-b603-6e0d-d512-b188813837bf@infradead.org>
2019-03-27 16:11 ` [PATCH] scsi: sd: Quiesce warning if device does not report optimal I/O size Martin K. Petersen
2019-03-27 16:46   ` Bart Van Assche
2019-03-27 18:05     ` Hussam Al-Tayeb

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).