Commit f197fe2b authored by Fam Zheng's avatar Fam Zheng Committed by Stefan Hajnoczi
Browse files

block: Add refcnt in BlockDriverAIOCB



This will be useful in synchronous cancel emulation with
bdrv_aio_cancel_async.

Signed-off-by: default avatarFam Zheng <famz@redhat.com>
Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
parent 0d910cfe
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -4891,14 +4891,24 @@ 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;
    assert(acb->refcnt > 0);
    if (--acb->refcnt == 0) {
        g_slice_free1(acb->aiocb_info->aiocb_size, acb);
    }
}

/**************************************************************/
/* Coroutine block device emulation */
+2 −0
Original line number Diff line number Diff line
@@ -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);