qemu-block
[Top][All Lists]
Advanced

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

[Qemu-block] [PATCH 01/40] 9pfs: allocate pdus with g_malloc/g_free


From: Paolo Bonzini
Subject: [Qemu-block] [PATCH 01/40] 9pfs: allocate pdus with g_malloc/g_free
Date: Tue, 24 Nov 2015 19:00:52 +0100

Prepare for moving the allocation to virtqueue_pop.

Signed-off-by: Paolo Bonzini <address@hidden>
---
 hw/9pfs/virtio-9p-device.c |  7 +------
 hw/9pfs/virtio-9p.c        | 10 +++-------
 hw/9pfs/virtio-9p.h        |  2 --
 3 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
index e3abcfa..72a93c2 100644
--- a/hw/9pfs/virtio-9p-device.c
+++ b/hw/9pfs/virtio-9p-device.c
@@ -57,7 +57,7 @@ static void virtio_9p_device_realize(DeviceState *dev, Error 
**errp)
 {
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
     V9fsState *s = VIRTIO_9P(dev);
-    int i, len;
+    int len;
     struct stat stat;
     FsDriverEntry *fse;
     V9fsPath path;
@@ -65,12 +65,7 @@ static void virtio_9p_device_realize(DeviceState *dev, Error 
**errp)
     virtio_init(vdev, "virtio-9p", VIRTIO_ID_9P,
                 sizeof(struct virtio_9p_config) + MAX_TAG_LEN);
 
-    /* initialize pdu allocator */
-    QLIST_INIT(&s->free_list);
     QLIST_INIT(&s->active_list);
-    for (i = 0; i < (MAX_REQ - 1); i++) {
-        QLIST_INSERT_HEAD(&s->free_list, &s->pdus[i], next);
-    }
 
     s->vq = virtio_add_queue(vdev, MAX_REQ, handle_9p_output);
 
diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c
index f972731..747306b 100644
--- a/hw/9pfs/virtio-9p.c
+++ b/hw/9pfs/virtio-9p.c
@@ -565,13 +565,9 @@ static int fid_to_qid(V9fsPDU *pdu, V9fsFidState *fidp, 
V9fsQID *qidp)
 
 static V9fsPDU *alloc_pdu(V9fsState *s)
 {
-    V9fsPDU *pdu = NULL;
+    V9fsPDU *pdu = g_new(V9fsPDU, 1);
 
-    if (!QLIST_EMPTY(&s->free_list)) {
-        pdu = QLIST_FIRST(&s->free_list);
-        QLIST_REMOVE(pdu, next);
-        QLIST_INSERT_HEAD(&s->active_list, pdu, next);
-    }
+    QLIST_INSERT_HEAD(&s->active_list, pdu, next);
     return pdu;
 }
 
@@ -584,8 +580,8 @@ static void free_pdu(V9fsState *s, V9fsPDU *pdu)
          */
         if (!pdu->cancelled) {
             QLIST_REMOVE(pdu, next);
-            QLIST_INSERT_HEAD(&s->free_list, pdu, next);
         }
+        g_free(pdu);
     }
 }
 
diff --git a/hw/9pfs/virtio-9p.h b/hw/9pfs/virtio-9p.h
index d7a4dc1..1fb4ff9 100644
--- a/hw/9pfs/virtio-9p.h
+++ b/hw/9pfs/virtio-9p.h
@@ -201,8 +201,6 @@ typedef struct V9fsState
 {
     VirtIODevice parent_obj;
     VirtQueue *vq;
-    V9fsPDU pdus[MAX_REQ];
-    QLIST_HEAD(, V9fsPDU) free_list;
     QLIST_HEAD(, V9fsPDU) active_list;
     V9fsFidState *fid_list;
     FileOperations *ops;
-- 
1.8.3.1





reply via email to

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