Commit 58da5b1e authored by Olaf Hering's avatar Olaf Hering Committed by Stefano Stabellini
Browse files

xen_disk: fix io accounting



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: default avatarOlaf Hering <olaf@aepfle.de>
Signed-off-by: default avatarStefano Stabellini <stefano.stabellini@eu.citrix.com>
parent 15e8159e
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -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);
    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);
}