[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] xen_disk: add discard support
From: |
Stefano Stabellini |
Subject: |
Re: [Qemu-devel] [PATCH] xen_disk: add discard support |
Date: |
Wed, 5 Feb 2014 18:07:38 +0000 |
User-agent: |
Alpine 2.02 (DEB 1266 2009-07-14) |
On Tue, 4 Feb 2014, Olaf Hering wrote:
> 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?
Right, you spotted a bug there: if !ioreq->req.nr_segments,
qemu_aio_complete is called without bdrv_acct_start being called first.
> What I have in mind is something like the (not compile tested) change below.
>
> 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:
What about BLKIF_OP_READ?
> + if (!ioreq->req.nr_segments) {
> + break;
> + }
> + bdrv_acct_done(ioreq->blkdev->bs, &ioreq->acct);
> + }
> qemu_bh_schedule(ioreq->blkdev->bh);
> }
>
>