All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] xen_disk: fix io accounting
@ 2014-02-06 15:55 Olaf Hering
  2014-02-06 18:02 ` Andreas Färber
  0 siblings, 1 reply; 3+ messages in thread
From: Olaf Hering @ 2014-02-06 15:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Olaf Hering, stefanha, stefano.stabellini

bdrv_acct_done was called unconditional. But in case the ioreq has no
segments there is no matching bdrv_acct_start call. This could lead to
bogus accounting values.

Found by code inspection.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
 hw/block/xen_disk.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
index 098f6c6..7f0f14a 100644
--- a/hw/block/xen_disk.c
+++ b/hw/block/xen_disk.c
@@ -483,7 +483,18 @@ static void qemu_aio_complete(void *opaque, int ret)
     ioreq->status = ioreq->aio_errors ? BLKIF_RSP_ERROR : BLKIF_RSP_OKAY;
     ioreq_unmap(ioreq);
     ioreq_finish(ioreq);
-    bdrv_acct_done(ioreq->blkdev->bs, &ioreq->acct);
+    switch (ioreq->req.operation) {
+    case BLKIF_OP_WRITE:
+    case BLKIF_OP_FLUSH_DISKCACHE:
+        if (!ioreq->req.nr_segments) {
+            break;
+        }
+    case BLKIF_OP_READ:
+        bdrv_acct_done(ioreq->blkdev->bs, &ioreq->acct);
+        break;
+    default:
+        break;
+    }
     qemu_bh_schedule(ioreq->blkdev->bh);
 }
 

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

* Re: [Qemu-devel] [PATCH] xen_disk: fix io accounting
  2014-02-06 15:55 [Qemu-devel] [PATCH] xen_disk: fix io accounting Olaf Hering
@ 2014-02-06 18:02 ` Andreas Färber
  2014-02-07 12:47   ` Stefano Stabellini
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Färber @ 2014-02-06 18:02 UTC (permalink / raw)
  To: Olaf Hering, qemu-devel; +Cc: kwolf, stefanha, stefano.stabellini

Am 06.02.2014 16:55, schrieb Olaf Hering:
> bdrv_acct_done was called unconditional. But in case the ioreq has no
> segments there is no matching bdrv_acct_start call. This could lead to
> bogus accounting values.
> 
> Found by code inspection.
> 
> Signed-off-by: Olaf Hering <olaf@aepfle.de>
> ---
>  hw/block/xen_disk.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
> index 098f6c6..7f0f14a 100644
> --- a/hw/block/xen_disk.c
> +++ b/hw/block/xen_disk.c
> @@ -483,7 +483,18 @@ static void qemu_aio_complete(void *opaque, int ret)
>      ioreq->status = ioreq->aio_errors ? BLKIF_RSP_ERROR : BLKIF_RSP_OKAY;
>      ioreq_unmap(ioreq);
>      ioreq_finish(ioreq);
> -    bdrv_acct_done(ioreq->blkdev->bs, &ioreq->acct);
> +    switch (ioreq->req.operation) {
> +    case BLKIF_OP_WRITE:
> +    case BLKIF_OP_FLUSH_DISKCACHE:
> +        if (!ioreq->req.nr_segments) {
> +            break;
> +        }

This will need a /* fall through */ comment for static analysis tools.

Andreas

> +    case BLKIF_OP_READ:
> +        bdrv_acct_done(ioreq->blkdev->bs, &ioreq->acct);
> +        break;
> +    default:
> +        break;
> +    }
>      qemu_bh_schedule(ioreq->blkdev->bh);
>  }
>  
> 


-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

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

* Re: [Qemu-devel] [PATCH] xen_disk: fix io accounting
  2014-02-06 18:02 ` Andreas Färber
@ 2014-02-07 12:47   ` Stefano Stabellini
  0 siblings, 0 replies; 3+ messages in thread
From: Stefano Stabellini @ 2014-02-07 12:47 UTC (permalink / raw)
  To: Andreas Färber
  Cc: kwolf, Olaf Hering, qemu-devel, stefanha, stefano.stabellini

[-- Attachment #1: Type: text/plain, Size: 1690 bytes --]

On Thu, 6 Feb 2014, Andreas Färber wrote:
> Am 06.02.2014 16:55, schrieb Olaf Hering:
> > bdrv_acct_done was called unconditional. But in case the ioreq has no
> > segments there is no matching bdrv_acct_start call. This could lead to
> > bogus accounting values.
> > 
> > Found by code inspection.
> > 
> > Signed-off-by: Olaf Hering <olaf@aepfle.de>
> > ---
> >  hw/block/xen_disk.c | 13 ++++++++++++-
> >  1 file changed, 12 insertions(+), 1 deletion(-)
> > 
> > diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
> > index 098f6c6..7f0f14a 100644
> > --- a/hw/block/xen_disk.c
> > +++ b/hw/block/xen_disk.c
> > @@ -483,7 +483,18 @@ static void qemu_aio_complete(void *opaque, int ret)
> >      ioreq->status = ioreq->aio_errors ? BLKIF_RSP_ERROR : BLKIF_RSP_OKAY;
> >      ioreq_unmap(ioreq);
> >      ioreq_finish(ioreq);
> > -    bdrv_acct_done(ioreq->blkdev->bs, &ioreq->acct);
> > +    switch (ioreq->req.operation) {
> > +    case BLKIF_OP_WRITE:
> > +    case BLKIF_OP_FLUSH_DISKCACHE:
> > +        if (!ioreq->req.nr_segments) {
> > +            break;
> > +        }
> 
> This will need a /* fall through */ comment for static analysis tools.
> 

Aside from this, I think that the patch is OK.
Can you please resend it with the comment?

 
> > +    case BLKIF_OP_READ:
> > +        bdrv_acct_done(ioreq->blkdev->bs, &ioreq->acct);
> > +        break;
> > +    default:
> > +        break;
> > +    }
> >      qemu_bh_schedule(ioreq->blkdev->bh);
> >  }
> >  
> > 
> 
> 
> -- 
> SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
> GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
> 

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

end of thread, other threads:[~2014-02-07 12:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-06 15:55 [Qemu-devel] [PATCH] xen_disk: fix io accounting Olaf Hering
2014-02-06 18:02 ` Andreas Färber
2014-02-07 12:47   ` Stefano Stabellini

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.