WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [qemu-xen-3.4-testing] Refactor aio callback allocation

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [qemu-xen-3.4-testing] Refactor aio callback allocation to use an aiocb pool (Avi Kivity)
From: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
Date: Tue, 20 Oct 2009 05:05:36 -0700
Delivery-date: Tue, 20 Oct 2009 05:05:37 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
commit 358362ffc971c9e817fbf1c5a6a51a75163cd418
Author: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Date:   Wed Oct 7 15:36:19 2009 +0100

    Refactor aio callback allocation to use an aiocb pool (Avi Kivity)
    
    Move the AIOCB allocation code to use a dedicate structure, AIOPool.  AIOCB
    specific information, such as the AIOCB size and cancellation routine, is
    moved into the pool.
    
    At present, there is exactly one pool per block format driver, maintaining
    the status quo.
    
    Signed-off-by: Avi Kivity <avi@xxxxxxxxxx>
    Signed-off-by: Anthony Liguori <aliguori@xxxxxxxxxx>
    
    git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6870 
c046a42c-6fe2-441c-8c8c-71466251a162
    
    [ Backported from 6bbff9a0b495918309074ac60375be5f9dc868b3
      by Stefano Stabellini. ]
    
    Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
    (cherry picked from commit efb4162ee6ad7ea15d1589eb09409854379f5139)
---
 block.c     |   42 +++++++++++++++++++++++++++---------------
 block_int.h |   14 +++++++++++++-
 2 files changed, 40 insertions(+), 16 deletions(-)

diff --git a/block.c b/block.c
index 36f5eb9..c26d4aa 100644
--- a/block.c
+++ b/block.c
@@ -145,6 +145,7 @@ static void bdrv_register(BlockDriver *bdrv)
     }
     if (!bdrv->bdrv_aio_flush)
         bdrv->bdrv_aio_flush = bdrv_aio_flush_em;
+    aio_pool_init(&bdrv->aio_pool, bdrv->aiocb_size, bdrv->bdrv_aio_cancel);
     bdrv->next = first_drv;
     first_drv = bdrv;
 }
@@ -1479,14 +1480,12 @@ BlockDriverAIOCB *bdrv_aio_write(BlockDriverState *bs, 
int64_t sector_num,
 
 void bdrv_aio_cancel(BlockDriverAIOCB *acb)
 {
-    BlockDriver *drv = acb->bs->drv;
-
     if (acb->cb == bdrv_aio_rw_vector_cb) {
         VectorTranslationState *s = acb->opaque;
         acb = s->aiocb;
     }
 
-    drv->bdrv_aio_cancel(acb);
+    acb->pool->cancel(acb);
 }
 
 BlockDriverAIOCB *bdrv_aio_flush(BlockDriverState *bs, 
@@ -1633,18 +1632,25 @@ void bdrv_init(void)
 #endif
 }
 
-void *qemu_aio_get(BlockDriverState *bs, BlockDriverCompletionFunc *cb,
-                   void *opaque)
+void aio_pool_init(AIOPool *pool, int aiocb_size,
+                   void (*cancel)(BlockDriverAIOCB *acb))
+{
+    pool->aiocb_size = aiocb_size;
+    pool->cancel = cancel;
+    pool->free_aiocb = NULL;
+}
+
+void *qemu_aio_get_pool(AIOPool *pool, BlockDriverState *bs,
+                        BlockDriverCompletionFunc *cb, void *opaque)
 {
-    BlockDriver *drv;
     BlockDriverAIOCB *acb;
 
-    drv = bs->drv;
-    if (drv->free_aiocb) {
-        acb = drv->free_aiocb;
-        drv->free_aiocb = acb->next;
+    if (pool->free_aiocb) {
+        acb = pool->free_aiocb;
+        pool->free_aiocb = acb->next;
     } else {
-        acb = qemu_mallocz(drv->aiocb_size);
+        acb = qemu_mallocz(pool->aiocb_size);
+        acb->pool = pool;
     }
     acb->bs = bs;
     acb->cb = cb;
@@ -1652,12 +1658,18 @@ void *qemu_aio_get(BlockDriverState *bs, 
BlockDriverCompletionFunc *cb,
     return acb;
 }
 
+void *qemu_aio_get(BlockDriverState *bs, BlockDriverCompletionFunc *cb,
+                   void *opaque)
+{
+    return qemu_aio_get_pool(&bs->drv->aio_pool, bs, cb, opaque);
+}
+
 void qemu_aio_release(void *p)
 {
-    BlockDriverAIOCB *acb = p;
-    BlockDriver *drv = acb->bs->drv;
-    acb->next = drv->free_aiocb;
-    drv->free_aiocb = acb;
+    BlockDriverAIOCB *acb = (BlockDriverAIOCB *)p;
+    AIOPool *pool = acb->pool;
+    acb->next = pool->free_aiocb;
+    pool->free_aiocb = acb;
 }
 
 /**************************************************************/
diff --git a/block_int.h b/block_int.h
index 1c8655b..6d2c2fc 100644
--- a/block_int.h
+++ b/block_int.h
@@ -32,6 +32,12 @@
 
 #define BLOCK_DRIVER_FLAG_EXTENDABLE  0x0001u
 
+typedef struct AIOPool {
+    void (*cancel)(BlockDriverAIOCB *acb);
+    int aiocb_size;
+    BlockDriverAIOCB *free_aiocb;
+} AIOPool;
+
 struct BlockDriver {
     const char *format_name;
     int instance_size;
@@ -95,7 +101,7 @@ struct BlockDriver {
     int (*bdrv_ioctl)(BlockDriverState *bs, unsigned long int req, void *buf);
 
     unsigned bdrv_flags;
-    BlockDriverAIOCB *free_aiocb;
+    AIOPool aio_pool;
     struct BlockDriver *next;
 };
 
@@ -146,6 +152,7 @@ struct BlockDriverState {
 };
 
 struct BlockDriverAIOCB {
+    AIOPool *pool;
     BlockDriverState *bs;
     BlockDriverCompletionFunc *cb;
     void *opaque;
@@ -154,8 +161,13 @@ struct BlockDriverAIOCB {
 
 void get_tmp_filename(char *filename, int size);
 
+void aio_pool_init(AIOPool *pool, int aiocb_size,
+                   void (*cancel)(BlockDriverAIOCB *acb));
+
 void *qemu_aio_get(BlockDriverState *bs, BlockDriverCompletionFunc *cb,
                    void *opaque);
+void *qemu_aio_get_pool(AIOPool *pool, BlockDriverState *bs,
+                        BlockDriverCompletionFunc *cb, void *opaque);
 void qemu_aio_release(void *p);
 
 extern BlockDriverState *bdrv_first;
--
generated by git-patchbot for /home/xen/git/qemu-xen-3.4-testing.git

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [qemu-xen-3.4-testing] Refactor aio callback allocation to use an aiocb pool (Avi Kivity), Ian Jackson <=