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(-)
diff --git a/block/file-posix.c b/block/file-posix.c
index d81e15efa4..27ab8d8784 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -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);
}
}
}
--
2.19.1.windows.1