diff mbox

[12/13] block: introduce bdrv_aio_io_plug() and its pair

Message ID 1415518978-2837-13-git-send-email-ming.lei@canonical.com
State New
Headers show

Commit Message

Ming Lei Nov. 9, 2014, 7:42 a.m. UTC
These two APIs are introduced for using AioContext wide
IO submission as batch.

Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
 block.c               |   16 ++++++++++++++++
 include/block/block.h |    3 +++
 2 files changed, 19 insertions(+)
diff mbox

Patch

diff --git a/block.c b/block.c
index dacd881..0200af0 100644
--- a/block.c
+++ b/block.c
@@ -5901,6 +5901,22 @@  void bdrv_io_unplug(BlockDriverState *bs)
     }
 }
 
+bool bdrv_aio_io_plug(AioContext *aio_ctx)
+{
+    if (aio_ctx->master_aio_bs) {
+        bdrv_io_plug(aio_ctx->master_aio_bs);
+        return true;
+    }
+    return false;
+}
+
+void bdrv_aio_io_unplug(AioContext *aio_ctx)
+{
+    if (aio_ctx->master_aio_bs) {
+        bdrv_io_unplug(aio_ctx->master_aio_bs);
+    }
+}
+
 void bdrv_flush_io_queue(BlockDriverState *bs)
 {
     BlockDriver *drv = bs->drv;
diff --git a/include/block/block.h b/include/block/block.h
index 13e4537..aae6b66 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -541,6 +541,9 @@  void bdrv_io_plug(BlockDriverState *bs);
 void bdrv_io_unplug(BlockDriverState *bs);
 void bdrv_flush_io_queue(BlockDriverState *bs);
 
+bool bdrv_aio_io_plug(AioContext *aio_ctx);
+void bdrv_aio_io_unplug(AioContext *aio_ctx);
+
 BlockAcctStats *bdrv_get_stats(BlockDriverState *bs);
 
 #endif