All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block/file-posix: Limit max_iov to IOV_MAX
@ 2021-09-18  7:33 lishan
  2021-09-20  8:14 ` Kevin Wolf
  0 siblings, 1 reply; 5+ messages in thread
From: lishan @ 2021-09-18  7:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, hreitz, lishan24, qemu-block, eric.fangyi

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



^ permalink raw reply	[flat|nested] 5+ messages in thread
* [PATCH] block/file-posix: Limit max_iov to IOV_MAX
@ 2021-09-18  4:06 lishan
  2021-09-20  4:47 ` Markus Armbruster
  2021-09-20  9:03 ` Daniel P. Berrangé
  0 siblings, 2 replies; 5+ messages in thread
From: lishan @ 2021-09-18  4:06 UTC (permalink / raw)
  To: qemu-devel; +Cc: eric.fangyi

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..137e27e47b 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, IOV_MAX);
         }
     }
 }
-- 
2.19.1.windows.1



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

end of thread, other threads:[~2021-09-20  9:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-18  7:33 [PATCH] block/file-posix: Limit max_iov to IOV_MAX lishan
2021-09-20  8:14 ` Kevin Wolf
  -- strict thread matches above, loose matches on Subject: below --
2021-09-18  4:06 lishan
2021-09-20  4:47 ` Markus Armbruster
2021-09-20  9:03 ` Daniel P. Berrangé

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.