@@ -51,6 +51,7 @@ typedef struct RBDAIOCB {
int aiocnt;
int error;
struct BDRVRBDState *s;
+ int cancelled;
} RBDAIOCB;
typedef struct RADOSCB {
@@ -325,8 +326,18 @@ static void rbd_complete_aio(RADOSCB *rcb)
int64_t r;
int i;
- r = rcb->ret;
acb->aiocnt--;
+
+ if (acb->cancelled) {
+ if (!acb->aiocnt) {
+ qemu_vfree(acb->bounce);
+ qemu_aio_release(acb);
+ }
+ goto done;
+ }
+
+ r = rcb->ret;
+
if (acb->write) {
if (r < 0) {
acb->ret = r;
@@ -356,6 +367,7 @@ static void rbd_complete_aio(RADOSCB *rcb)
if (!acb->aiocnt && acb->bh) {
qemu_bh_schedule(acb->bh);
}
+done:
qemu_free(rcb);
i = 0;
}
@@ -585,7 +597,7 @@ static void rbd_aio_cancel(BlockDriverAIOCB *blockacb)
RBDAIOCB *acb = (RBDAIOCB *) blockacb;
qemu_bh_delete(acb->bh);
acb->bh = NULL;
- qemu_aio_release(acb);
+ acb->cancelled = 1;
}