Received: from eggs.gnu.org ([2001:4830:134:3::10]:57303) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WBo7p-00085f-Kg for qemu-devel@nongnu.org; Fri, 07 Feb 2014 11:18:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WBo7j-0004xQ-OJ for qemu-devel@nongnu.org; Fri, 07 Feb 2014 11:17:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50919) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WBo7j-0004xF-GP for qemu-devel@nongnu.org; Fri, 07 Feb 2014 11:17:51 -0500 Date: Fri, 7 Feb 2014 17:17:45 +0100 From: Kevin Wolf Message-ID: <20140207161745.GC9796@dhcp-200-207.str.redhat.com> References: <1391784474-418-1-git-send-email-olaf@aepfle.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1391784474-418-1-git-send-email-olaf@aepfle.de> Subject: Re: [Qemu-devel] [PATCH v2] xen_disk: fix io accounting List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Olaf Hering Cc: qemu-devel@nongnu.org, stefanha@redhat.com, stefano.stabellini@eu.citrix.com 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 > --- > 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