All of lore.kernel.org
 help / color / mirror / Atom feed
* [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

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

lishan <lishan24@huawei.com> writes:

> 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);
>          }
>      }
>  }

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()?



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

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

CC'ing qemu-block list

On Sat, Sep 18, 2021 at 12:06:58PM +0800, lishan wrote:
> 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);

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
-- 
|: 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 :|



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

* Re: [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, 0 replies; 5+ messages in thread
From: Kevin Wolf @ 2021-09-20  8:14 UTC (permalink / raw)
  To: lishan; +Cc: hreitz, qemu-devel, qemu-block, eric.fangyi

Am 18.09.2021 um 09:33 hat lishan geschrieben:
> 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

>  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  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

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  4:06 [PATCH] block/file-posix: Limit max_iov to IOV_MAX lishan
2021-09-20  4:47 ` Markus Armbruster
2021-09-20  9:03 ` Daniel P. Berrangé
2021-09-18  7:33 lishan
2021-09-20  8:14 ` Kevin Wolf

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.