From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:54249) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RhmC6-0000y5-49 for qemu-devel@nongnu.org; Mon, 02 Jan 2012 13:01:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RhmC3-0001A0-S1 for qemu-devel@nongnu.org; Mon, 02 Jan 2012 13:01:09 -0500 Sender: Paolo Bonzini From: Paolo Bonzini Date: Mon, 2 Jan 2012 19:00:32 +0100 Message-Id: <1325527237-24146-4-git-send-email-pbonzini@redhat.com> In-Reply-To: <1325527237-24146-1-git-send-email-pbonzini@redhat.com> References: <1325527237-24146-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 3/8] qed: switch to QTAILQ List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org QED needs to insert at tail. Use a QTAILQ, even though the double links are strictly not necessary. Signed-off-by: Paolo Bonzini --- 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