All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block: prevent multiwrite_merge from creating too large iovecs
@ 2010-01-19 21:15 Christoph Hellwig
  2010-01-20 11:37 ` Kevin Wolf
  2010-01-20 14:56 ` Anthony Liguori
  0 siblings, 2 replies; 8+ messages in thread
From: Christoph Hellwig @ 2010-01-19 21:15 UTC (permalink / raw)
  To: qemu-devel

If we go over the maximum number of iovecs support by syscall we get
back EINVAL from the kernel which translate to I/O errors for the guest.

Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: qemu/block.c
===================================================================
--- qemu.orig/block.c	2010-01-19 22:10:19.797003226 +0100
+++ qemu/block.c	2010-01-19 22:11:08.226005767 +0100
@@ -1711,6 +1711,10 @@ static int multiwrite_merge(BlockDriverS
             merge = bs->drv->bdrv_merge_requests(bs, &reqs[outidx], &reqs[i]);
         }
 
+        if (reqs[outidx].qiov->niov + reqs[i].qiov->niov + 1 > IOV_MAX) {
+            merge = 0;
+        }
+
         if (merge) {
             size_t size;
             QEMUIOVector *qiov = qemu_mallocz(sizeof(*qiov));

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

* Re: [Qemu-devel] [PATCH] block: prevent multiwrite_merge from creating too large iovecs
  2010-01-19 21:15 [Qemu-devel] [PATCH] block: prevent multiwrite_merge from creating too large iovecs Christoph Hellwig
@ 2010-01-20 11:37 ` Kevin Wolf
  2010-01-20 16:24   ` Christoph Hellwig
  2010-01-26  9:21   ` Christoph Hellwig
  2010-01-20 14:56 ` Anthony Liguori
  1 sibling, 2 replies; 8+ messages in thread
From: Kevin Wolf @ 2010-01-20 11:37 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: qemu-devel

Am 19.01.2010 22:15, schrieb Christoph Hellwig:
> If we go over the maximum number of iovecs support by syscall we get
> back EINVAL from the kernel which translate to I/O errors for the guest.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Is this really enough? We don't check for IOV_MAX in any other place, so
can't we get a too big request directly from virtio-blk?

What about handling it transparently in qemu_pwritev/preadv and
laio_submit? Logically, it's a limitation of the backend anyway and not
a generic restriction.

To underline that it's a backend/platform dependent thing: Your patch
breaks the mingw build for me.

Kevin

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

* Re: [Qemu-devel] [PATCH] block: prevent multiwrite_merge from creating too large iovecs
  2010-01-19 21:15 [Qemu-devel] [PATCH] block: prevent multiwrite_merge from creating too large iovecs Christoph Hellwig
  2010-01-20 11:37 ` Kevin Wolf
@ 2010-01-20 14:56 ` Anthony Liguori
  1 sibling, 0 replies; 8+ messages in thread
From: Anthony Liguori @ 2010-01-20 14:56 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: qemu-devel

On 01/19/2010 03:15 PM, Christoph Hellwig wrote:
> If we go over the maximum number of iovecs support by syscall we get
> back EINVAL from the kernel which translate to I/O errors for the guest.
>
> Signed-off-by: Christoph Hellwig<hch@lst.de>
>    

Applied.  Thanks.

Regards,

Anthony Liguori
> Index: qemu/block.c
> ===================================================================
> --- qemu.orig/block.c	2010-01-19 22:10:19.797003226 +0100
> +++ qemu/block.c	2010-01-19 22:11:08.226005767 +0100
> @@ -1711,6 +1711,10 @@ static int multiwrite_merge(BlockDriverS
>               merge = bs->drv->bdrv_merge_requests(bs,&reqs[outidx],&reqs[i]);
>           }
>
> +        if (reqs[outidx].qiov->niov + reqs[i].qiov->niov + 1>  IOV_MAX) {
> +            merge = 0;
> +        }
> +
>           if (merge) {
>               size_t size;
>               QEMUIOVector *qiov = qemu_mallocz(sizeof(*qiov));
>
>
>
>    

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

* Re: [Qemu-devel] [PATCH] block: prevent multiwrite_merge from creating too large iovecs
  2010-01-20 11:37 ` Kevin Wolf
@ 2010-01-20 16:24   ` Christoph Hellwig
  2010-01-20 16:29     ` Kevin Wolf
  2010-01-26  9:21   ` Christoph Hellwig
  1 sibling, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2010-01-20 16:24 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: Christoph Hellwig, qemu-devel

On Wed, Jan 20, 2010 at 12:37:51PM +0100, Kevin Wolf wrote:
> Am 19.01.2010 22:15, schrieb Christoph Hellwig:
> > If we go over the maximum number of iovecs support by syscall we get
> > back EINVAL from the kernel which translate to I/O errors for the guest.
> > 
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> Is this really enough? We don't check for IOV_MAX in any other place, so
> can't we get a too big request directly from virtio-blk?

Currently the virtqueue is limited to 1024 iovecs, but I plan to put in
some better infrastructure to deal with the queue limit.  For now this
patch fixes an issue that we see with real life setups.

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

* Re: [Qemu-devel] [PATCH] block: prevent multiwrite_merge from creating too large iovecs
  2010-01-20 16:24   ` Christoph Hellwig
@ 2010-01-20 16:29     ` Kevin Wolf
  0 siblings, 0 replies; 8+ messages in thread
From: Kevin Wolf @ 2010-01-20 16:29 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: qemu-devel

Am 20.01.2010 17:24, schrieb Christoph Hellwig:
> On Wed, Jan 20, 2010 at 12:37:51PM +0100, Kevin Wolf wrote:
>> Am 19.01.2010 22:15, schrieb Christoph Hellwig:
>>> If we go over the maximum number of iovecs support by syscall we get
>>> back EINVAL from the kernel which translate to I/O errors for the guest.
>>>
>>> Signed-off-by: Christoph Hellwig <hch@lst.de>
>>
>> Is this really enough? We don't check for IOV_MAX in any other place, so
>> can't we get a too big request directly from virtio-blk?
> 
> Currently the virtqueue is limited to 1024 iovecs, but I plan to put in
> some better infrastructure to deal with the queue limit.  For now this
> patch fixes an issue that we see with real life setups.

Ok, if you're planning to replace it by something real, I'm not opposed
to using this as a quick fix for the meantime. However, it needs an
#ifdef for the mingw build breakage at least.

Kevin

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

* Re: [Qemu-devel] [PATCH] block: prevent multiwrite_merge from creating too large iovecs
  2010-01-20 11:37 ` Kevin Wolf
  2010-01-20 16:24   ` Christoph Hellwig
@ 2010-01-26  9:21   ` Christoph Hellwig
  2010-01-26 13:08     ` Anthony Liguori
  1 sibling, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2010-01-26  9:21 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: Christoph Hellwig, qemu-devel

On Wed, Jan 20, 2010 at 12:37:51PM +0100, Kevin Wolf wrote:
> To underline that it's a backend/platform dependent thing: Your patch
> breaks the mingw build for me.

Actually that's because mingw is the usual piece of crap and doesn't
actually have any of the vector support you can expect from a normal
Unix system.

I can either throw in an #ifdef IOV_MAX around the check or fake one up
for mingw.  Does any of the maintainers have a preference for either
variant?

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

* Re: [Qemu-devel] [PATCH] block: prevent multiwrite_merge from creating too large iovecs
  2010-01-26  9:21   ` Christoph Hellwig
@ 2010-01-26 13:08     ` Anthony Liguori
  2010-01-26 13:42       ` Christoph Hellwig
  0 siblings, 1 reply; 8+ messages in thread
From: Anthony Liguori @ 2010-01-26 13:08 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Kevin Wolf, qemu-devel

On 01/26/2010 03:21 AM, Christoph Hellwig wrote:
> On Wed, Jan 20, 2010 at 12:37:51PM +0100, Kevin Wolf wrote:
>    
>> To underline that it's a backend/platform dependent thing: Your patch
>> breaks the mingw build for me.
>>      
> Actually that's because mingw is the usual piece of crap and doesn't
> actually have any of the vector support you can expect from a normal
> Unix system.
>
> I can either throw in an #ifdef IOV_MAX around the check or fake one up
> for mingw.  Does any of the maintainers have a preference for either
> variant?
>    

grep for CONFIG_IOVEC in qemu-common.h and add a #define IOV_MAX.

mingw doesn't have iovec so we introduce a compat version.

Regards,

Anthony Liguori

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

* Re: [Qemu-devel] [PATCH] block: prevent multiwrite_merge from creating too large iovecs
  2010-01-26 13:08     ` Anthony Liguori
@ 2010-01-26 13:42       ` Christoph Hellwig
  0 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2010-01-26 13:42 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: Kevin Wolf, Christoph Hellwig, qemu-devel

On Tue, Jan 26, 2010 at 07:08:20AM -0600, Anthony Liguori wrote:
> >I can either throw in an #ifdef IOV_MAX around the check or fake one up
> >for mingw.  Does any of the maintainers have a preference for either
> >variant?
> >   
> 
> grep for CONFIG_IOVEC in qemu-common.h and add a #define IOV_MAX.
> 
> mingw doesn't have iovec so we introduce a compat version.

Yes, that's what I meant with the second alternative above.

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

end of thread, other threads:[~2010-01-26 13:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-19 21:15 [Qemu-devel] [PATCH] block: prevent multiwrite_merge from creating too large iovecs Christoph Hellwig
2010-01-20 11:37 ` Kevin Wolf
2010-01-20 16:24   ` Christoph Hellwig
2010-01-20 16:29     ` Kevin Wolf
2010-01-26  9:21   ` Christoph Hellwig
2010-01-26 13:08     ` Anthony Liguori
2010-01-26 13:42       ` Christoph Hellwig
2010-01-20 14:56 ` Anthony Liguori

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.