Received: from eggs.gnu.org ([2001:4830:134:3::10]:38071) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WBmis-0007uL-1K for qemu-devel@nongnu.org; Fri, 07 Feb 2014 09:48:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WBmiq-0003Ja-NV for qemu-devel@nongnu.org; Fri, 07 Feb 2014 09:48:05 -0500 Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::10]:23169) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WBmiq-0003JE-ED for qemu-devel@nongnu.org; Fri, 07 Feb 2014 09:48:04 -0500 From: Olaf Hering Date: Fri, 7 Feb 2014 15:47:54 +0100 Message-Id: <1391784474-418-1-git-send-email-olaf@aepfle.de> Subject: [Qemu-devel] [PATCH v2] 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 --- 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); }