aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorFam Zheng <famz@redhat.com>2014-09-11 13:41:08 +0800
committerStefan Hajnoczi <stefanha@redhat.com>2014-09-22 11:38:57 +0100
commitf197fe2b2c77259b6570620f288d905bfa38e2da (patch)
treee9dcfaa75bbd9bc93ae309bbd2129207dc1e36b6 /block.c
parent0d910cfeaf2076b116b4517166d5deb0fea76394 (diff)
downloadqemu-f197fe2b2c77259b6570620f288d905bfa38e2da.zip
qemu-f197fe2b2c77259b6570620f288d905bfa38e2da.tar.gz
qemu-f197fe2b2c77259b6570620f288d905bfa38e2da.tar.bz2
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>
Diffstat (limited to 'block.c')
-rw-r--r--block.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/block.c b/block.c
index bcd952a..7f73ff0 100644
--- a/block.c
+++ b/block.c
@@ -4891,13 +4891,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)
{
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);
+ }
}
/**************************************************************/