qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Alberto Garcia <berto@igalia.com>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH v4 1/4] block: replace bdrv_states iteration with bdrv_next()
Date: Tue, 28 Apr 2015 14:27:49 +0100	[thread overview]
Message-ID: <1430227672-7670-2-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1430227672-7670-1-git-send-email-stefanha@redhat.com>

The bdrv_states list is a static variable in block.c.

bdrv_drain_all() and bdrv_flush_all() use this variable to iterate over
all drives.

The next patch will move bdrv_drain_all() and bdrv_flush_all() out of
block.c so it's necessary to switch to the public bdrv_next() interface.

Reviewed-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 block.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/block.c b/block.c
index ec23594..1f0a4e2 100644
--- a/block.c
+++ b/block.c
@@ -2051,9 +2051,9 @@ void bdrv_drain_all(void)
 {
     /* Always run first iteration so any pending completion BHs run */
     bool busy = true;
-    BlockDriverState *bs;
+    BlockDriverState *bs = NULL;
 
-    QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
+    while ((bs = bdrv_next(bs))) {
         AioContext *aio_context = bdrv_get_aio_context(bs);
 
         aio_context_acquire(aio_context);
@@ -2065,8 +2065,9 @@ void bdrv_drain_all(void)
 
     while (busy) {
         busy = false;
+        bs = NULL;
 
-        QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
+        while ((bs = bdrv_next(bs))) {
             AioContext *aio_context = bdrv_get_aio_context(bs);
 
             aio_context_acquire(aio_context);
@@ -2075,7 +2076,8 @@ void bdrv_drain_all(void)
         }
     }
 
-    QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
+    bs = NULL;
+    while ((bs = bdrv_next(bs))) {
         AioContext *aio_context = bdrv_get_aio_context(bs);
 
         aio_context_acquire(aio_context);
@@ -4015,10 +4017,10 @@ int bdrv_get_flags(BlockDriverState *bs)
 
 int bdrv_flush_all(void)
 {
-    BlockDriverState *bs;
+    BlockDriverState *bs = NULL;
     int result = 0;
 
-    QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
+    while ((bs = bdrv_next(bs))) {
         AioContext *aio_context = bdrv_get_aio_context(bs);
         int ret;
 
-- 
2.1.0

  reply	other threads:[~2015-04-28 13:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-28 13:27 [Qemu-devel] [PATCH v4 0/4] block: move I/O request processing to block/io.c Stefan Hajnoczi
2015-04-28 13:27 ` Stefan Hajnoczi [this message]
2015-04-28 13:27 ` [Qemu-devel] [PATCH v4 2/4] block: add bdrv_set_dirty()/bdrv_reset_dirty() to block_int.h Stefan Hajnoczi
2015-04-28 13:27 ` [Qemu-devel] [PATCH v4 3/4] block: extract bdrv_setup_io_funcs() Stefan Hajnoczi
2015-04-28 13:27 ` [Qemu-devel] [PATCH v4 4/4] block: move I/O request processing to block/io.c Stefan Hajnoczi
2015-04-28 13:49 ` [Qemu-devel] [PATCH v4 0/4] " Kevin Wolf

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=1430227672-7670-2-git-send-email-stefanha@redhat.com \
    --to=stefanha@redhat.com \
    --cc=berto@igalia.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@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).