block/file-posix: Limit max_iov to IOV_MAX
PATCH 1/1 block/file-posix: Limit max_iov to IOV_MAX
AIO read/write. The size of iocb->aio_nbytes in the kernel cannot exceed UIO_MAXIOV = 1024. max_segments read from the block device layer may be greater than UIO_MAXIOV, this causes the ioq_submit interface to return a -22(-EINVAL) error result.
--- block/file-posix.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
block/file-posix.c +2 -1
@@ -1273,7 +1273,8 @@ static void raw_refresh_limits(BlockDriverState *bs, Error **errp) ret =hdev_get_max_segments (s->fd, &st);if (ret >0 ) { - bs->bl.max_iov = ret; +/* The maximum segment size allowed by the kernel is UIO_MAXIOV = 1024. */ + bs->bl.max_iov =MIN (ret,IOV_MAX ); } } }
Signature · 1 line
2.19.1.windows.1
Quoted 12 lines · lishan
AIO read/write. The size of
iocb->aio_nbytesin the kernel cannot exceedUIO_MAXIOV= 1024.max_segmentsread from the block device layer may be greater thanUIO_MAXIOV, this causes theioq_submitinterface to return a -22(-EINVAL) error result.--- block/file-posix.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)block/file-posix.c +0
-0
block/file-posix.c static void raw_refresh_limits(BlockDriverState *bs, Error **errp) · line 1280
Quoted 9 lines
block/file-posix.c +2
-1@@ -1273,7 +1273,8 @@ static void raw_refresh_limits(BlockDriverState *bs, Error **errp) ret =hdev_get_max_segments (s->fd, &st);if (ret >0 ) { - bs->bl.max_iov = ret; +/* The maximum segment size allowed by the kernel is UIO_MAXIOV = 1024. */ + bs->bl.max_iov =MIN (ret,IOV_MAX ); } } }
I didn't check your assertion we always need to cap at IOV_MAX. Assuming you're right, why not do it in hdev_get_max_segments()?
CC'ing qemu-block list
Quoted 12 lines · lishan
AIO read/write. The size of
iocb->aio_nbytesin the kernel cannot exceedUIO_MAXIOV= 1024.max_segmentsread from the block device layer may be greater thanUIO_MAXIOV, this causes theioq_submitinterface to return a -22(-EINVAL) error result.--- block/file-posix.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)block/file-posix.c +0
-0
block/file-posix.c static void raw_refresh_limits(BlockDriverState *bs, Error **errp) · line 1277
Quoted 6 lines
block/file-posix.c +2
-1@@ -1273,7 +1273,8 @@ static void raw_refresh_limits(BlockDriverState *bs, Error **errp) ret =hdev_get_max_segments (s->fd, &st);if (ret >0 ) { - bs->bl.max_iov = ret; +/* The maximum segment size allowed by the kernel is UIO_MAXIOV = 1024. */ + bs->bl.max_iov =MIN (ret,IOV_MAX );
This change matches a bug fix we've done downstream for QEMU, but it was suggested that the upstream patch would be taking a different approach for a more comprehensive fix.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|