qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] xen_disk: fix io accounting
@ 2014-02-07 14:47 Olaf Hering
  2014-02-07 14:57 ` Stefano Stabellini
  2014-02-07 16:17 ` Kevin Wolf
  0 siblings, 2 replies; 4+ messages in thread
From: Olaf Hering @ 2014-02-07 14:47 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>
---
v2:
  add comment /* fall through */

 hw/block/xen_disk.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
index 098f6c6..fb4ca4a 100644
--- a/hw/block/xen_disk.c
+++ b/hw/block/xen_disk.c
@@ -483,7 +483,19 @@ 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;
+        }
+	/* fall through */
+    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] 4+ messages in thread

* Re: [Qemu-devel] [PATCH v2] xen_disk: fix io accounting
  2014-02-07 14:47 [Qemu-devel] [PATCH v2] xen_disk: fix io accounting Olaf Hering
@ 2014-02-07 14:57 ` Stefano Stabellini
  2014-02-07 15:03   ` Olaf Hering
  2014-02-07 16:17 ` Kevin Wolf
  1 sibling, 1 reply; 4+ messages in thread
From: Stefano Stabellini @ 2014-02-07 14:57 UTC (permalink / raw)
  To: Olaf Hering; +Cc: kwolf, qemu-devel, stefanha, stefano.stabellini

On Fri, 7 Feb 2014, Olaf Hering wrote:
> 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>

added to my queue, I'll fix the tab manually

> v2:
>   add comment /* fall through */
> 
>  hw/block/xen_disk.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
> index 098f6c6..fb4ca4a 100644
> --- a/hw/block/xen_disk.c
> +++ b/hw/block/xen_disk.c
> @@ -483,7 +483,19 @@ 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;
> +        }
> +	/* fall through */
> +    case BLKIF_OP_READ:
> +        bdrv_acct_done(ioreq->blkdev->bs, &ioreq->acct);
> +        break;
> +    default:
> +        break;
> +    }
>      qemu_bh_schedule(ioreq->blkdev->bh);
>  }
>  
> 

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

* Re: [Qemu-devel] [PATCH v2] xen_disk: fix io accounting
  2014-02-07 14:57 ` Stefano Stabellini
@ 2014-02-07 15:03   ` Olaf Hering
  0 siblings, 0 replies; 4+ messages in thread
From: Olaf Hering @ 2014-02-07 15:03 UTC (permalink / raw)
  To: Stefano Stabellini; +Cc: kwolf, qemu-devel, stefanha

On Fri, Feb 07, Stefano Stabellini wrote:

> added to my queue, I'll fix the tab manually

Thanks, sorry for the TAB.

Olaf

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

* Re: [Qemu-devel] [PATCH v2] xen_disk: fix io accounting
  2014-02-07 14:47 [Qemu-devel] [PATCH v2] xen_disk: fix io accounting Olaf Hering
  2014-02-07 14:57 ` Stefano Stabellini
@ 2014-02-07 16:17 ` Kevin Wolf
  1 sibling, 0 replies; 4+ messages in thread
From: Kevin Wolf @ 2014-02-07 16:17 UTC (permalink / raw)
  To: Olaf Hering; +Cc: qemu-devel, stefanha, stefano.stabellini

Am 07.02.2014 um 15:47 hat Olaf Hering geschrieben:
> 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>
> ---
> v2:
>   add comment /* fall through */
> 
>  hw/block/xen_disk.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
> index 098f6c6..fb4ca4a 100644
> --- a/hw/block/xen_disk.c
> +++ b/hw/block/xen_disk.c
> @@ -483,7 +483,19 @@ 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;
> +        }
> +	/* fall through */
> +    case BLKIF_OP_READ:
> +        bdrv_acct_done(ioreq->blkdev->bs, &ioreq->acct);
> +        break;
> +    default:
> +        break;
> +    }
>      qemu_bh_schedule(ioreq->blkdev->bh);
>  }

I think the default case could actually be abort() because it should
never happen. But either way, you can add:

Acked-by: Kevin Wolf <kwolf@redhat.com>

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

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-07 14:47 [Qemu-devel] [PATCH v2] xen_disk: fix io accounting Olaf Hering
2014-02-07 14:57 ` Stefano Stabellini
2014-02-07 15:03   ` Olaf Hering
2014-02-07 16:17 ` Kevin Wolf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).