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, bs->bl.max_iov); } } }
Signature · 1 line
2.19.1.windows.1
Am 18.09.2021 um 09:33 hat lishan geschrieben:
Quoted 3 lines
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.
You need a Signed-off-by line so that a patch can be accepted.
But Paolo intended to send a better solution anyway (splitting max_iov into two separate limits). Not sure what the status is there.
Kevin
Quoted 21 lines
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, bs->bl.max_iov); } } }Signature · 1 line
2.19.1.windows.1