diff mbox

xen_disk: add discard support

Message ID 20140204154737.GA19903@aepfle.de
State New
Headers show

Commit Message

Olaf Hering Feb. 4, 2014, 3:47 p.m. UTC
On Mon, Feb 03, Kevin Wolf wrote:

> Am 30.01.2014 um 16:02 hat Olaf Hering geschrieben:
> > +++ b/hw/block/xen_disk.c

> > +    case BLKIF_OP_DISCARD:
> > +    {
> > +        struct blkif_request_discard *discard_req = (void *)&ioreq->req;
> > +        bdrv_acct_start(blkdev->bs, &ioreq->acct,
> > +                        discard_req->nr_sectors * BLOCK_SIZE, BDRV_ACCT_WRITE);
> 
> Neither SCSI nor IDE account for discards. I think we should keep the
> behaviour consistent across devices.

Stefano,did you already put this change into your queue?
I will resubmit the patch with the change below.

Olaf

Comments

Kevin Wolf Feb. 4, 2014, 4:15 p.m. UTC | #1
Am 04.02.2014 um 16:47 hat Olaf Hering geschrieben:
> On Mon, Feb 03, Kevin Wolf wrote:
> 
> > Am 30.01.2014 um 16:02 hat Olaf Hering geschrieben:
> > > +++ b/hw/block/xen_disk.c
> 
> > > +    case BLKIF_OP_DISCARD:
> > > +    {
> > > +        struct blkif_request_discard *discard_req = (void *)&ioreq->req;
> > > +        bdrv_acct_start(blkdev->bs, &ioreq->acct,
> > > +                        discard_req->nr_sectors * BLOCK_SIZE, BDRV_ACCT_WRITE);
> > 
> > Neither SCSI nor IDE account for discards. I think we should keep the
> > behaviour consistent across devices.
> 
> Stefano,did you already put this change into your queue?
> I will resubmit the patch with the change below.
> 
> Olaf
> 
> 
> diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
> index e74efc7..69ecc98 100644
> --- a/hw/block/xen_disk.c
> +++ b/hw/block/xen_disk.c
> @@ -527,8 +527,6 @@ static int ioreq_runio_qemu_aio(struct ioreq *ioreq)
>      case BLKIF_OP_DISCARD:
>      {
>          struct blkif_request_discard *discard_req = (void *)&ioreq->req;
> -        bdrv_acct_start(blkdev->bs, &ioreq->acct,
> -                        discard_req->nr_sectors * BLOCK_SIZE, BDRV_ACCT_WRITE);
>          ioreq->aio_inflight++;
>          bdrv_aio_discard(blkdev->bs,
>                          discard_req->sector_number, discard_req->nr_sectors,

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.

Kevin
diff mbox

Patch

diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
index e74efc7..69ecc98 100644
--- a/hw/block/xen_disk.c
+++ b/hw/block/xen_disk.c
@@ -527,8 +527,6 @@  static int ioreq_runio_qemu_aio(struct ioreq *ioreq)
     case BLKIF_OP_DISCARD:
     {
         struct blkif_request_discard *discard_req = (void *)&ioreq->req;
-        bdrv_acct_start(blkdev->bs, &ioreq->acct,
-                        discard_req->nr_sectors * BLOCK_SIZE, BDRV_ACCT_WRITE);
         ioreq->aio_inflight++;
         bdrv_aio_discard(blkdev->bs,
                         discard_req->sector_number, discard_req->nr_sectors,