diff mbox

[RFC,v2,11/15] Make bdrv_discard coroutine only and add bdrv_sync_discard

Message ID 1376070245-22557-11-git-send-email-charlie@ctshepherd.com
State New
Headers show

Commit Message

Charlie Shepherd Aug. 9, 2013, 5:44 p.m. UTC
This patch renames the coroutine only bdrv_co_discard to bdrv_discard and the original
bdrv_discard to bdrv_sync_discard. bdrv_sync_discard is synchronous only.

Signed-off-by: Charlie Shepherd <charlie@ctshepherd.com>
---
 block.c               | 12 +++---------
 include/block/block.h |  3 ++-
 2 files changed, 5 insertions(+), 10 deletions(-)
diff mbox

Patch

diff --git a/block.c b/block.c
index c7b6f01..6995d3f 100644
--- a/block.c
+++ b/block.c
@@ -4190,7 +4190,7 @@  static void coroutine_fn bdrv_discard_co_entry(void *opaque)
     rwco->ret = bdrv_co_discard(rwco->bs, rwco->sector_num, rwco->nb_sectors);
 }
 
-int coroutine_fn bdrv_co_discard(BlockDriverState *bs, int64_t sector_num,
+int coroutine_fn bdrv_discard(BlockDriverState *bs, int64_t sector_num,
                                  int nb_sectors)
 {
     if (!bs->drv) {
@@ -4231,7 +4231,7 @@  int coroutine_fn bdrv_co_discard(BlockDriverState *bs, int64_t sector_num,
     }
 }
 
-int bdrv_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors)
+int bdrv_sync_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors)
 {
     Coroutine *co;
     RwCo rwco = {
@@ -4241,13 +4241,7 @@  int bdrv_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors)
         .ret = NOT_DONE,
     };
 
-    if (qemu_in_coroutine()) {
-        /* Fast-path if already in coroutine context */
-        bdrv_discard_co_entry(&rwco);
-        return rwco.ret;
-    } else {
-        return bdrv_sync_rwco(bdrv_discard_co_entry, &rwco);
-    }
+    return bdrv_sync_rwco(bdrv_discard_co_entry, &rwco);
 }
 
 /**************************************************************/
diff --git a/include/block/block.h b/include/block/block.h
index a209102..65d8864 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -279,7 +279,8 @@  int bdrv_flush_all(void);
 void bdrv_close_all(void);
 void bdrv_drain_all(void);
 
-int bdrv_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors);
+int coroutine_fn bdrv_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors);
+int bdrv_sync_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors);
 int bdrv_co_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors);
 int bdrv_has_zero_init_1(BlockDriverState *bs);
 int bdrv_has_zero_init(BlockDriverState *bs);