218e99
From 6a307262a0a30089eff547a9e6489ae8fd9d242d Mon Sep 17 00:00:00 2001
218e99
From: Paolo Bonzini <pbonzini@redhat.com>
218e99
Date: Fri, 18 Oct 2013 08:14:32 +0200
218e99
Subject: [PATCH 07/81] block: remove bdrv_is_allocated_above/bdrv_co_is_allocated_above distinction
218e99
218e99
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
218e99
Message-id: <1382084091-16636-8-git-send-email-pbonzini@redhat.com>
218e99
Patchwork-id: 54990
218e99
O-Subject: [RHEL 7.0 qemu-kvm PATCH 07/26] block: remove bdrv_is_allocated_above/bdrv_co_is_allocated_above distinction
218e99
Bugzilla: 989646
218e99
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
218e99
RH-Acked-by: Max Reitz <mreitz@redhat.com>
218e99
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
218e99
218e99
Now that bdrv_is_allocated detects coroutine context, the two can
218e99
use the same code.
218e99
218e99
Reviewed-by: Eric Blake <eblake@redhat.com>
218e99
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
218e99
(cherry picked from commit 4f5786376e41980e78af45a123c56ebdc5295099)
218e99
---
218e99
 block.c               | 46 ++++------------------------------------------
218e99
 block/commit.c        |  6 +++---
218e99
 block/mirror.c        |  4 ++--
218e99
 block/stream.c        |  4 ++--
218e99
 include/block/block.h |  4 ----
218e99
 5 files changed, 11 insertions(+), 53 deletions(-)
218e99
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 block.c               |   46 ++++------------------------------------------
218e99
 block/commit.c        |    6 +++---
218e99
 block/mirror.c        |    4 ++--
218e99
 block/stream.c        |    4 ++--
218e99
 include/block/block.h |    4 ----
218e99
 5 files changed, 11 insertions(+), 53 deletions(-)
218e99
218e99
diff --git a/block.c b/block.c
218e99
index 9ea8221..46d9420 100644
218e99
--- a/block.c
218e99
+++ b/block.c
218e99
@@ -3110,10 +3110,10 @@ int bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
218e99
  *  allocated/unallocated state.
218e99
  *
218e99
  */
218e99
-int coroutine_fn bdrv_co_is_allocated_above(BlockDriverState *top,
218e99
-                                            BlockDriverState *base,
218e99
-                                            int64_t sector_num,
218e99
-                                            int nb_sectors, int *pnum)
218e99
+int bdrv_is_allocated_above(BlockDriverState *top,
218e99
+                            BlockDriverState *base,
218e99
+                            int64_t sector_num,
218e99
+                            int nb_sectors, int *pnum)
218e99
 {
218e99
     BlockDriverState *intermediate;
218e99
     int ret, n = nb_sectors;
218e99
@@ -3149,44 +3149,6 @@ int coroutine_fn bdrv_co_is_allocated_above(BlockDriverState *top,
218e99
     return 0;
218e99
 }
218e99
 
218e99
-/* Coroutine wrapper for bdrv_is_allocated_above() */
218e99
-static void coroutine_fn bdrv_is_allocated_above_co_entry(void *opaque)
218e99
-{
218e99
-    BdrvCoIsAllocatedData *data = opaque;
218e99
-    BlockDriverState *top = data->bs;
218e99
-    BlockDriverState *base = data->base;
218e99
-
218e99
-    data->ret = bdrv_co_is_allocated_above(top, base, data->sector_num,
218e99
-                                           data->nb_sectors, data->pnum);
218e99
-    data->done = true;
218e99
-}
218e99
-
218e99
-/*
218e99
- * Synchronous wrapper around bdrv_co_is_allocated_above().
218e99
- *
218e99
- * See bdrv_co_is_allocated_above() for details.
218e99
- */
218e99
-int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base,
218e99
-                            int64_t sector_num, int nb_sectors, int *pnum)
218e99
-{
218e99
-    Coroutine *co;
218e99
-    BdrvCoIsAllocatedData data = {
218e99
-        .bs = top,
218e99
-        .base = base,
218e99
-        .sector_num = sector_num,
218e99
-        .nb_sectors = nb_sectors,
218e99
-        .pnum = pnum,
218e99
-        .done = false,
218e99
-    };
218e99
-
218e99
-    co = qemu_coroutine_create(bdrv_is_allocated_above_co_entry);
218e99
-    qemu_coroutine_enter(co, &data);
218e99
-    while (!data.done) {
218e99
-        qemu_aio_wait();
218e99
-    }
218e99
-    return data.ret;
218e99
-}
218e99
-
218e99
 BlockInfo *bdrv_query_info(BlockDriverState *bs)
218e99
 {
218e99
     BlockInfo *info = g_malloc0(sizeof(*info));
218e99
diff --git a/block/commit.c b/block/commit.c
218e99
index 553447e..74c209a 100644
218e99
--- a/block/commit.c
218e99
+++ b/block/commit.c
218e99
@@ -108,9 +108,9 @@ wait:
218e99
             break;
218e99
         }
218e99
         /* Copy if allocated above the base */
218e99
-        ret = bdrv_co_is_allocated_above(top, base, sector_num,
218e99
-                                         COMMIT_BUFFER_SIZE / BDRV_SECTOR_SIZE,
218e99
-                                         &n);
218e99
+        ret = bdrv_is_allocated_above(top, base, sector_num,
218e99
+                                      COMMIT_BUFFER_SIZE / BDRV_SECTOR_SIZE,
218e99
+                                      &n);
218e99
         copy = (ret == 1);
218e99
         trace_commit_one_iteration(s, sector_num, n, ret);
218e99
         if (copy) {
218e99
diff --git a/block/mirror.c b/block/mirror.c
218e99
index 1ae724f..dad1e3e 100644
218e99
--- a/block/mirror.c
218e99
+++ b/block/mirror.c
218e99
@@ -338,8 +338,8 @@ static void coroutine_fn mirror_run(void *opaque)
218e99
         base = s->mode == MIRROR_SYNC_MODE_FULL ? NULL : bs->backing_hd;
218e99
         for (sector_num = 0; sector_num < end; ) {
218e99
             int64_t next = (sector_num | (sectors_per_chunk - 1)) + 1;
218e99
-            ret = bdrv_co_is_allocated_above(bs, base,
218e99
-                                             sector_num, next - sector_num, &n);
218e99
+            ret = bdrv_is_allocated_above(bs, base,
218e99
+                                          sector_num, next - sector_num, &n);
218e99
 
218e99
             if (ret < 0) {
218e99
                 goto immediate_exit;
218e99
diff --git a/block/stream.c b/block/stream.c
218e99
index f8efa8a..9674c31 100644
218e99
--- a/block/stream.c
218e99
+++ b/block/stream.c
218e99
@@ -123,8 +123,8 @@ wait:
218e99
         } else {
218e99
             /* Copy if allocated in the intermediate images.  Limit to the
218e99
              * known-unallocated area [sector_num, sector_num+n).  */
218e99
-            ret = bdrv_co_is_allocated_above(bs->backing_hd, base,
218e99
-                                             sector_num, n, &n);
218e99
+            ret = bdrv_is_allocated_above(bs->backing_hd, base,
218e99
+                                          sector_num, n, &n);
218e99
 
218e99
             /* Finish early if end of backing file has been reached */
218e99
             if (ret == 0 && n == 0) {
218e99
diff --git a/include/block/block.h b/include/block/block.h
218e99
index 1932e67..ec4d4aa 100644
218e99
--- a/include/block/block.h
218e99
+++ b/include/block/block.h
218e99
@@ -192,10 +192,6 @@ int coroutine_fn bdrv_co_writev(BlockDriverState *bs, int64_t sector_num,
218e99
  */
218e99
 int coroutine_fn bdrv_co_write_zeroes(BlockDriverState *bs, int64_t sector_num,
218e99
     int nb_sectors);
218e99
-int coroutine_fn bdrv_co_is_allocated_above(BlockDriverState *top,
218e99
-                                            BlockDriverState *base,
218e99
-                                            int64_t sector_num,
218e99
-                                            int nb_sectors, int *pnum);
218e99
 BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs,
218e99
     const char *backing_file);
218e99
 int bdrv_get_backing_file_depth(BlockDriverState *bs);
218e99
-- 
218e99
1.7.1
218e99