On Tue, Feb 04, Olaf Hering wrote: > On Tue, Feb 04, Kevin Wolf wrote: > > > Now you call bdrv_acct_done() in the callback without having a matching > > bdrv_acct_start(). You need to make it conditional in the callback.
> Stefano, > Is ioreq_runio_qemu_aio symetric in this regard anyway? In case of > BLKIF_OP_WRITE|BLKIF_OP_FLUSH_DISKCACHE and no ioreq->req.nr_segments > then qemu_aio_complete is called anyway. Will qemu_aio_complete get down > to the bdrv_acct_done call at all in this case? What I have in mind is something like the (not compile tested) change below. Olaf diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c index e74efc7..99d36b8 100644 --- a/hw/block/xen_disk.c +++ b/hw/block/xen_disk.c @@ -486,7 +486,16 @@ 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_DISCARD: + break; + case BLKIF_OP_WRITE: + case BLKIF_OP_FLUSH_DISKCACHE: + if (!ioreq->req.nr_segments) { + break; + } + bdrv_acct_done(ioreq->blkdev->bs, &ioreq->acct); + } qemu_bh_schedule(ioreq->blkdev->bh); }