qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org
Subject: [Qemu-devel] [PATCH 3/8] qed: switch to QTAILQ
Date: Mon,  2 Jan 2012 19:00:32 +0100	[thread overview]
Message-ID: <1325527237-24146-4-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1325527237-24146-1-git-send-email-pbonzini@redhat.com>

QED needs to insert at tail.  Use a QTAILQ, even though
the double links are strictly not necessary.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 block/qed.c |   20 ++++++++++----------
 block/qed.h |    4 ++--
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/block/qed.c b/block/qed.c
index 8da3ebe..d30323b 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -300,7 +300,7 @@ static void qed_unplug_allocating_write_reqs(BDRVQEDState *s)
 
     s->allocating_write_reqs_plugged = false;
 
-    acb = QSIMPLEQ_FIRST(&s->allocating_write_reqs);
+    acb = QTAILQ_FIRST(&s->allocating_write_reqs);
     if (acb) {
         qed_aio_next_io(acb, 0);
     }
@@ -339,7 +339,7 @@ static void qed_need_check_timer_cb(void *opaque)
     BDRVQEDState *s = opaque;
 
     /* The timer should only fire when allocating writes have drained */
-    assert(!QSIMPLEQ_FIRST(&s->allocating_write_reqs));
+    assert(!QTAILQ_FIRST(&s->allocating_write_reqs));
 
     trace_qed_need_check_timer_cb(s);
 
@@ -375,7 +375,7 @@ static int bdrv_qed_open(BlockDriverState *bs, int flags)
     int ret;
 
     s->bs = bs;
-    QSIMPLEQ_INIT(&s->allocating_write_reqs);
+    QTAILQ_INIT(&s->allocating_write_reqs);
 
     ret = bdrv_pread(bs->file, 0, &le_header, sizeof(le_header));
     if (ret < 0) {
@@ -886,9 +886,9 @@ static void qed_aio_complete(QEDAIOCB *acb, int ret)
      * next request in the queue.  This ensures that we don't cycle through
      * requests multiple times but rather finish one at a time completely.
      */
-    if (acb == QSIMPLEQ_FIRST(&s->allocating_write_reqs)) {
-        QSIMPLEQ_REMOVE_HEAD(&s->allocating_write_reqs, next);
-        acb = QSIMPLEQ_FIRST(&s->allocating_write_reqs);
+    if (acb == QTAILQ_FIRST(&s->allocating_write_reqs)) {
+        QTAILQ_REMOVE(&s->allocating_write_reqs, acb, next);
+        acb = QTAILQ_FIRST(&s->allocating_write_reqs);
         if (acb) {
             qed_aio_next_io(acb, 0);
         } else if (s->header.features & QED_F_NEED_CHECK) {
@@ -1094,15 +1094,15 @@ static void qed_aio_write_alloc(QEDAIOCB *acb, size_t len)
     BDRVQEDState *s = acb_to_s(acb);
 
     /* Cancel timer when the first allocating request comes in */
-    if (QSIMPLEQ_EMPTY(&s->allocating_write_reqs)) {
+    if (QTAILQ_EMPTY(&s->allocating_write_reqs)) {
         qed_cancel_need_check_timer(s);
     }
 
     /* Freeze this request if another allocating write is in progress */
-    if (acb != QSIMPLEQ_FIRST(&s->allocating_write_reqs)) {
-        QSIMPLEQ_INSERT_TAIL(&s->allocating_write_reqs, acb, next);
+    if (acb != QTAILQ_FIRST(&s->allocating_write_reqs)) {
+        QTAILQ_INSERT_TAIL(&s->allocating_write_reqs, acb, next);
     }
-    if (acb != QSIMPLEQ_FIRST(&s->allocating_write_reqs) ||
+    if (acb != QTAILQ_FIRST(&s->allocating_write_reqs) ||
         s->allocating_write_reqs_plugged) {
         return; /* wait for existing request to finish */
     }
diff --git a/block/qed.h b/block/qed.h
index 62cbd3b..f2be4e1 100644
--- a/block/qed.h
+++ b/block/qed.h
@@ -127,7 +127,7 @@ typedef struct QEDAIOCB {
     BlockDriverAIOCB common;
     QEMUBH *bh;
     int bh_ret;                     /* final return status for completion bh */
-    QSIMPLEQ_ENTRY(QEDAIOCB) next;  /* next request */
+    QTAILQ_ENTRY(QEDAIOCB) next;    /* next request */
     bool is_write;                  /* false - read, true - write */
     bool *finished;                 /* signal for cancel completion */
     uint64_t end_pos;               /* request end on block device, in bytes */
@@ -159,7 +159,7 @@ typedef struct {
     uint32_t l2_mask;
 
     /* Allocating write request queue */
-    QSIMPLEQ_HEAD(, QEDAIOCB) allocating_write_reqs;
+    QTAILQ_HEAD(, QEDAIOCB) allocating_write_reqs;
     bool allocating_write_reqs_plugged;
 
     /* Periodic flush and clear need check flag */
-- 
1.7.7.1

  parent reply	other threads:[~2012-01-02 18:01 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-02 18:00 [Qemu-devel] [PATCH 0/8] qemu-queue cleanups Paolo Bonzini
2012-01-02 18:00 ` [Qemu-devel] [PATCH 1/8] notifier: switch to QLIST Paolo Bonzini
2012-01-03 11:54   ` Stefan Hajnoczi
2012-01-03 11:59     ` Paolo Bonzini
2012-01-03 12:09       ` Stefan Hajnoczi
2012-01-02 18:00 ` [Qemu-devel] [PATCH 2/8] block-migration: switch to QTAILQ Paolo Bonzini
2012-01-02 18:00 ` Paolo Bonzini [this message]
2012-01-02 18:00 ` [Qemu-devel] [PATCH 4/8] ccid: " Paolo Bonzini
2012-01-02 18:00 ` [Qemu-devel] [PATCH 5/8] qemu-queue: really simplify QSIMPLEQ Paolo Bonzini
2012-01-03 12:04   ` [Qemu-devel] [Qemu-trivial] " Stefan Hajnoczi
2012-01-13 16:04   ` [Qemu-devel] " Peter Maydell
2012-01-02 18:00 ` [Qemu-devel] [PATCH 6/8] qemu-queue: drop QCIRCLEQ Paolo Bonzini
2012-01-02 18:00 ` [Qemu-devel] [PATCH 7/8] coroutine: switch to QSIMPLEQ Paolo Bonzini
2012-01-02 18:00 ` [Qemu-devel] [PATCH 8/8] block: use QSIMPLEQ for the AIO free list Paolo Bonzini
2012-01-03 12:07 ` [Qemu-devel] [Qemu-trivial] [PATCH 0/8] qemu-queue cleanups Stefan Hajnoczi
2012-01-13 15:47 ` [Qemu-devel] " Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1325527237-24146-4-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).