the malloc() implementation should do a decent job at this, simplifies
block device locking.

Index: kvm-userspace.io/qemu/block.c
===================================================================
--- kvm-userspace.io.orig/qemu/block.c
+++ kvm-userspace.io/qemu/block.c
@@ -1447,14 +1447,10 @@ void *qemu_aio_get(BlockDriverState *bs,
     BlockDriverAIOCB *acb;
 
     drv = bs->drv;
-    if (drv->free_aiocb) {
-        acb = drv->free_aiocb;
-        drv->free_aiocb = acb->next;
-    } else {
-        acb = qemu_mallocz(drv->aiocb_size);
-        if (!acb)
-            return NULL;
-    }
+    acb = qemu_mallocz(drv->aiocb_size);
+    if (!acb)
+        return NULL;
+
     acb->bs = bs;
     acb->cb = cb;
     acb->opaque = opaque;
@@ -1464,9 +1460,7 @@ void *qemu_aio_get(BlockDriverState *bs,
 void qemu_aio_release(void *p)
 {
     BlockDriverAIOCB *acb = p;
-    BlockDriver *drv = acb->bs->drv;
-    acb->next = drv->free_aiocb;
-    drv->free_aiocb = acb;
+    qemu_free(p);
 }
 
 /**************************************************************/
Index: kvm-userspace.io/qemu/block_int.h
===================================================================
--- kvm-userspace.io.orig/qemu/block_int.h
+++ kvm-userspace.io/qemu/block_int.h
@@ -85,7 +85,6 @@ struct BlockDriver {
     /* to control generic scsi devices */
     int (*bdrv_ioctl)(BlockDriverState *bs, unsigned long int req, void *buf);
 
-    BlockDriverAIOCB *free_aiocb;
     struct BlockDriver *next;
 };
 

-- 


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel

Reply via email to