summaryrefslogtreecommitdiff
path: root/block/linux-aio.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2016-04-07 18:33:34 +0200
committerKevin Wolf <kwolf@redhat.com>2016-05-12 15:22:07 +0200
commit6b98bd649520d07df4d1b7a0a54ac73bf178519c (patch)
tree22924e241859dcc57d55fdb1d71c8f4220313633 /block/linux-aio.c
parentce0f141259f06fd77fde2519cc352618ad797ce2 (diff)
downloadqemu-6b98bd649520d07df4d1b7a0a54ac73bf178519c.tar.gz
qemu-6b98bd649520d07df4d1b7a0a54ac73bf178519c.tar.bz2
qemu-6b98bd649520d07df4d1b7a0a54ac73bf178519c.zip
block: plug whole tree at once, introduce bdrv_io_unplugged_begin/end
Extract the handling of io_plug "depth" from linux-aio.c and let the main bdrv_drain loop do nothing but wait on I/O. Like the two newly introduced functions, bdrv_io_plug and bdrv_io_unplug now operate on all children. The visit order is now symmetrical between plug and unplug, making it possible for formats to implement plug/unplug. Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Acked-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/linux-aio.c')
-rw-r--r--block/linux-aio.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/block/linux-aio.c b/block/linux-aio.c
index 805757e02e..102bf928af 100644
--- a/block/linux-aio.c
+++ b/block/linux-aio.c
@@ -220,19 +220,16 @@ void laio_io_plug(BlockDriverState *bs, void *aio_ctx)
{
struct qemu_laio_state *s = aio_ctx;
- s->io_q.plugged++;
+ assert(!s->io_q.plugged);
+ s->io_q.plugged = 1;
}
-void laio_io_unplug(BlockDriverState *bs, void *aio_ctx, bool unplug)
+void laio_io_unplug(BlockDriverState *bs, void *aio_ctx)
{
struct qemu_laio_state *s = aio_ctx;
- assert(s->io_q.plugged > 0 || !unplug);
-
- if (unplug && --s->io_q.plugged > 0) {
- return;
- }
-
+ assert(s->io_q.plugged);
+ s->io_q.plugged = 0;
if (!s->io_q.blocked && !QSIMPLEQ_EMPTY(&s->io_q.pending)) {
ioq_submit(s);
}