From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46322) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGY7w-0003OM-Tm for qemu-devel@nongnu.org; Thu, 20 Feb 2014 13:13:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WGY7s-0008IR-G5 for qemu-devel@nongnu.org; Thu, 20 Feb 2014 13:13:40 -0500 Received: from smtp.citrix.com ([66.165.176.89]:55659) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGY7s-0008I2-0J for qemu-devel@nongnu.org; Thu, 20 Feb 2014 13:13:36 -0500 From: Stefano Stabellini Date: Thu, 20 Feb 2014 18:13:22 +0000 Message-ID: <1392920002-18522-2-git-send-email-stefano.stabellini@eu.citrix.com> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PULL 2/2] xen_disk: fix io accounting List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: peter.maydell@linaro.org, olaf@aepfle.de, xen-devel@lists.xensource.com, Stefano Stabellini , qemu-devel@nongnu.org, Anthony.Perard@citrix.com, pbonzini@redhat.com From: 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 Signed-off-by: Stefano Stabellini --- 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); } -- 1.7.10.4