]> xenbits.xensource.com Git - qemu-xen.git/commit
block: introduce max_hw_iov for use in scsi-generic
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 23 Sep 2021 13:04:36 +0000 (09:04 -0400)
committerMichael Roth <michael.roth@amd.com>
Tue, 14 Dec 2021 19:53:15 +0000 (13:53 -0600)
commita43e057bd6095108fbe99b6a21d4857186aa3df3
tree9ddacbd80f066345662bd070e99dbb7c92db1500
parent3aa2c2cd679dcf86e67f8c466c2e3c0bc5e1155f
block: introduce max_hw_iov for use in scsi-generic

Linux limits the size of iovecs to 1024 (UIO_MAXIOV in the kernel
sources, IOV_MAX in POSIX).  Because of this, on some host adapters
requests with many iovecs are rejected with -EINVAL by the
io_submit() or readv()/writev() system calls.

In fact, the same limit applies to SG_IO as well.  To fix both the
EINVAL and the possible performance issues from using fewer iovecs
than allowed by Linux (some HBAs have max_segments as low as 128),
introduce a separate entry in BlockLimits to hold the max_segments
value from sysfs.  This new limit is used only for SG_IO and clamped
to bs->bl.max_iov anyway, just like max_hw_transfer is clamped to
bs->bl.max_transfer.

Reported-by: Halil Pasic <pasic@linux.ibm.com>
Cc: Hanna Reitz <hreitz@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: qemu-block@nongnu.org
Cc: qemu-stable@nongnu.org
Fixes: 18473467d5 ("file-posix: try BLKSECTGET on block devices too, do not round to power of 2", 2021-06-25)
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210923130436.1187591-1-pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit cc071629539dc1f303175a7e2d4ab854c0a8b20f)
Signed-off-by: Michael Roth <michael.roth@amd.com>
block/block-backend.c
block/file-posix.c
block/io.c
hw/scsi/scsi-generic.c
include/block/block_int.h
include/sysemu/block-backend.h