Received: from eggs.gnu.org ([2001:4830:134:3::10]:52627) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WBRJG-0001Qs-MI for qemu-devel@nongnu.org; Thu, 06 Feb 2014 10:56:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WBRJF-0000t1-II for qemu-devel@nongnu.org; Thu, 06 Feb 2014 10:56:14 -0500 Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::5]:61631) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WBRJF-0000sl-7z for qemu-devel@nongnu.org; Thu, 06 Feb 2014 10:56:13 -0500 From: Olaf Hering Date: Thu, 6 Feb 2014 16:55:53 +0100 Message-Id: <1391702153-19893-1-git-send-email-olaf@aepfle.de> Subject: [Qemu-devel] [PATCH] xen_disk: fix io accounting List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, Olaf Hering , stefanha@redhat.com, stefano.stabellini@eu.citrix.com 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 --- 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); }