Skip to contentSkip to conversation

block/file-posix: Limit max_iov to IOV_MAX

PATCH In review lishan 2 participants 2 messages Sep 18, 2021 – Sep 20, 2021 Block layer

lore
Share & tools
lore

lishan

author
#0 lore raw

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
index d81e15efa4..27ab8d8784 100644
@@ -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
#1 lore raw

Am 18.09.2021 um 09:33 hat lishan geschrieben:

Quoted 3 lines

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.

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
index d81e15efa4..27ab8d8784 100644
@@ -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