qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 5/5] block: use QSLIST for the AIO free list


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH v2 5/5] block: use QSLIST for the AIO free list
Date: Fri, 17 Feb 2012 10:03:03 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110922 Lightning/1.0b2 Thunderbird/3.1.15

On 01/13/2012 10:34 AM, Paolo Bonzini wrote:
QSLIST is equivalent to an open-coded free list, use it.

Signed-off-by: Paolo Bonzini<address@hidden>

Surprisingly enough, this breaks hotplug (causes QEMU to segv).

I'll drop this patch and you can bring the next one in through Kevin's queue to make sure it gets adequate review.

Regards,

Anthony Liguori

---
  block.c     |    9 ++++-----
  block_int.h |    4 ++--
  2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/block.c b/block.c
index 3f072f6..acb54b1 100644
--- a/block.c
+++ b/block.c
@@ -3242,9 +3242,9 @@ void *qemu_aio_get(AIOPool *pool, BlockDriverState *bs,
  {
      BlockDriverAIOCB *acb;

-    if (pool->free_aiocb) {
-        acb = pool->free_aiocb;
-        pool->free_aiocb = acb->next;
+    if (!QSLIST_EMPTY(pool->free_aiocb)) {
+        acb = QSLIST_FIRST(pool->free_aiocb);
+        QSLIST_REMOVE_HEAD(pool->free_aiocb, next);
      } else {
          acb = g_malloc0(pool->aiocb_size);
          acb->pool = pool;
@@ -3259,8 +3259,7 @@ void qemu_aio_release(void *p)
  {
      BlockDriverAIOCB *acb = (BlockDriverAIOCB *)p;
      AIOPool *pool = acb->pool;
-    acb->next = pool->free_aiocb;
-    pool->free_aiocb = acb;
+    QSLIST_INSERT_HEAD(pool->free_aiocb, acb, next);
  }

  /**************************************************************/
diff --git a/block_int.h b/block_int.h
index 311bd2a..c592e54 100644
--- a/block_int.h
+++ b/block_int.h
@@ -56,7 +56,7 @@ typedef struct BdrvTrackedRequest BdrvTrackedRequest;
  typedef struct AIOPool {
      void (*cancel)(BlockDriverAIOCB *acb);
      int aiocb_size;
-    BlockDriverAIOCB *free_aiocb;
+    QSLIST_HEAD(, BlockDriverAIOCB) *free_aiocb;
  } AIOPool;

  typedef struct BlockIOLimit {
@@ -268,7 +268,7 @@ struct BlockDriverAIOCB {
      BlockDriverState *bs;
      BlockDriverCompletionFunc *cb;
      void *opaque;
-    BlockDriverAIOCB *next;
+    QSLIST_ENTRY(BlockDriverAIOCB) next;
  };

  void get_tmp_filename(char *filename, int size);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]