mirror of
https://github.com/qemu/qemu.git
synced 2025-08-09 19:15:32 +00:00
block: Add refcnt in BlockDriverAIOCB
This will be useful in synchronous cancel emulation with bdrv_aio_cancel_async. Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
0d910cfeaf
commit
f197fe2b2c
12
block.c
12
block.c
@ -4891,13 +4891,23 @@ void *qemu_aio_get(const AIOCBInfo *aiocb_info, BlockDriverState *bs,
|
|||||||
acb->bs = bs;
|
acb->bs = bs;
|
||||||
acb->cb = cb;
|
acb->cb = cb;
|
||||||
acb->opaque = opaque;
|
acb->opaque = opaque;
|
||||||
|
acb->refcnt = 1;
|
||||||
return acb;
|
return acb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void qemu_aio_ref(void *p)
|
||||||
|
{
|
||||||
|
BlockDriverAIOCB *acb = p;
|
||||||
|
acb->refcnt++;
|
||||||
|
}
|
||||||
|
|
||||||
void qemu_aio_release(void *p)
|
void qemu_aio_release(void *p)
|
||||||
{
|
{
|
||||||
BlockDriverAIOCB *acb = p;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
|
@ -35,11 +35,13 @@ struct BlockDriverAIOCB {
|
|||||||
BlockDriverState *bs;
|
BlockDriverState *bs;
|
||||||
BlockDriverCompletionFunc *cb;
|
BlockDriverCompletionFunc *cb;
|
||||||
void *opaque;
|
void *opaque;
|
||||||
|
int refcnt;
|
||||||
};
|
};
|
||||||
|
|
||||||
void *qemu_aio_get(const AIOCBInfo *aiocb_info, BlockDriverState *bs,
|
void *qemu_aio_get(const AIOCBInfo *aiocb_info, BlockDriverState *bs,
|
||||||
BlockDriverCompletionFunc *cb, void *opaque);
|
BlockDriverCompletionFunc *cb, void *opaque);
|
||||||
void qemu_aio_release(void *p);
|
void qemu_aio_release(void *p);
|
||||||
|
void qemu_aio_ref(void *p);
|
||||||
|
|
||||||
typedef struct AioHandler AioHandler;
|
typedef struct AioHandler AioHandler;
|
||||||
typedef void QEMUBHFunc(void *opaque);
|
typedef void QEMUBHFunc(void *opaque);
|
||||||
|
Loading…
Reference in New Issue
Block a user