All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] scsi-disk: Don't enlarge min_io_size to max_io_size
@ 2018-03-22  7:38 Fam Zheng
  2018-03-22  9:11 ` Paolo Bonzini
  2018-03-22 12:19 ` Daniel Henrique Barboza
  0 siblings, 2 replies; 6+ messages in thread
From: Fam Zheng @ 2018-03-22  7:38 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Fam Zheng, eblake

Some backends report big max_io_sectors. Making min_io_size the same
value in this case will make it impossible for guest to align memory,
therefore the disk may not be usable at all.

Change the default behavior (when min_io_size and opt_io_size are not
specified in the command line), do not assume max_io_sectors is a good
value for opt_io_size and min_io_size, use 512 instead.

Reported-by: David Gibson <dgibson@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
---
 hw/scsi/scsi-disk.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index 5b7a48f5a5..76e3c9eaa4 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -714,10 +714,8 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf)
 
                 /* min_io_size and opt_io_size can't be greater than
                  * max_io_sectors */
-                min_io_size =
-                    MIN_NON_ZERO(min_io_size, max_io_sectors);
-                opt_io_size =
-                    MIN_NON_ZERO(opt_io_size, max_io_sectors);
+                min_io_size = MIN(min_io_size ? : 512, max_io_sectors);
+                opt_io_size = MIN(opt_io_size ? : 512, max_io_sectors);
             }
             /* required VPD size with unmap support */
             buflen = 0x40;
-- 
2.14.3

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

end of thread, other threads:[~2018-03-27 16:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-22  7:38 [Qemu-devel] [PATCH] scsi-disk: Don't enlarge min_io_size to max_io_size Fam Zheng
2018-03-22  9:11 ` Paolo Bonzini
2018-03-22 12:19 ` Daniel Henrique Barboza
2018-03-26  7:26   ` Fam Zheng
2018-03-27  3:44     ` David Gibson
2018-03-27 16:28       ` Fam Zheng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.