qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v4 01/20] block: Add refcnt in BlockDriverAIOCB


From: Benoît Canet
Subject: Re: [Qemu-devel] [PATCH v4 01/20] block: Add refcnt in BlockDriverAIOCB
Date: Thu, 4 Sep 2014 17:07:48 +0200
User-agent: Mutt/1.5.23 (2014-03-12)

The Wednesday 03 Sep 2014 à 19:23:36 (+0800), Fam Zheng wrote :
> This will be useful in synchronous cancel emulation with
> bdrv_aio_cancel_async.
> 
> Signed-off-by: Fam Zheng <address@hidden>
> ---
>  block.c             | 12 +++++++++++-
>  include/block/aio.h |  2 ++
>  2 files changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/block.c b/block.c
> index cb670fd..78d68cb 100644
> --- a/block.c
> +++ b/block.c
> @@ -4885,13 +4885,23 @@ void *qemu_aio_get(const AIOCBInfo *aiocb_info, 
> BlockDriverState *bs,
>      acb->bs = bs;
>      acb->cb = cb;
>      acb->opaque = opaque;
> +    acb->refcnt = 1;
>      return acb;
>  }
>  
> +void qemu_aio_ref(void *p)
> +{
> +    BlockDriverAIOCB *acb = p;
> +    acb->refcnt++;
> +}


> +
>  void qemu_aio_release(void *p)

I would expect _release to change to _unref for symetry.

>  {
>      BlockDriverAIOCB *acb = p;
> -    g_slice_free1(acb->aiocb_info->aiocb_size, acb);
> +    assert(acb->refcnt > 0);
> +    if (--acb->refcnt == 0) {
> +        g_slice_free1(acb->aiocb_info->aiocb_size, acb);
> +    }
>  }
>  
>  /**************************************************************/
> diff --git a/include/block/aio.h b/include/block/aio.h
> index 4603c0f..2626fc7 100644
> --- a/include/block/aio.h
> +++ b/include/block/aio.h
> @@ -35,11 +35,13 @@ struct BlockDriverAIOCB {
>      BlockDriverState *bs;
>      BlockDriverCompletionFunc *cb;
>      void *opaque;
> +    int refcnt;
>  };
>  
>  void *qemu_aio_get(const AIOCBInfo *aiocb_info, BlockDriverState *bs,
>                     BlockDriverCompletionFunc *cb, void *opaque);
>  void qemu_aio_release(void *p);
> +void qemu_aio_ref(void *p);
>  
>  typedef struct AioHandler AioHandler;
>  typedef void QEMUBHFunc(void *opaque);
> -- 
> 2.1.0.27.g96db324
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]