diff mbox

[v3,1/2] block: replace bdrv_states iteration with bdrv_next()

Message ID 1430149991-29850-2-git-send-email-stefanha@redhat.com
State New
Headers show

Commit Message

Stefan Hajnoczi April 27, 2015, 3:53 p.m. UTC
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.

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

Comments

Alberto Garcia April 27, 2015, 4:09 p.m. UTC | #1
On Mon 27 Apr 2015 05:53:10 PM CEST, Stefan Hajnoczi <stefanha@redhat.com> wrote:

> 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.
>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>

Reviewed-by: Alberto Garcia <berto@igalia.com>

Note: not a consequence of your patch, but we'll have to update this
code again if this patch from me eventually gets merged:

http://patchwork.ozlabs.org/patch/464226/

Berto
diff mbox

Patch

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;