qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC v2 11/15] Make bdrv_discard coroutine only and add bdr


From: Charlie Shepherd
Subject: [Qemu-devel] [RFC v2 11/15] Make bdrv_discard coroutine only and add bdrv_sync_discard
Date: Fri, 9 Aug 2013 19:44:01 +0200

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 <address@hidden>
---
 block.c               | 12 +++---------
 include/block/block.h |  3 ++-
 2 files changed, 5 insertions(+), 10 deletions(-)

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);
-- 
1.8.3.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]