diff options
author | Kevin Wolf <kwolf@redhat.com> | 2016-11-18 16:04:59 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2017-06-26 14:51:15 +0200 |
commit | c0e8f98927929b65ffbfb320b7a1c79e0e620006 (patch) | |
tree | 7e51c39e8f83e0e0aff5c07474e196f389b43ef2 /block/qed.c | |
parent | 48cc565e767d1cb4965150d258ebd15a1b3de488 (diff) |
qed: Use a coroutine for need_check_timer
This fixes the last place where we degraded from AIO to actual blocking
synchronous I/O requests. Putting it into a coroutine means that instead
of blocking, the coroutine simply yields while doing I/O.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'block/qed.c')
-rw-r--r-- | block/qed.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/block/qed.c b/block/qed.c index e53f6b5abf..eac8c2f19a 100644 --- a/block/qed.c +++ b/block/qed.c @@ -264,11 +264,23 @@ static void qed_unplug_allocating_write_reqs(BDRVQEDState *s) qemu_co_enter_next(&s->allocating_write_reqs); } -static void qed_clear_need_check(void *opaque, int ret) +static void qed_need_check_timer_entry(void *opaque) { BDRVQEDState *s = opaque; + int ret; - if (ret) { + /* The timer should only fire when allocating writes have drained */ + assert(!s->allocating_acb); + + trace_qed_need_check_timer_cb(s); + + qed_acquire(s); + qed_plug_allocating_write_reqs(s); + + /* Ensure writes are on disk before clearing flag */ + ret = bdrv_co_flush(s->bs->file->bs); + qed_release(s); + if (ret < 0) { qed_unplug_allocating_write_reqs(s); return; } @@ -279,25 +291,14 @@ static void qed_clear_need_check(void *opaque, int ret) qed_unplug_allocating_write_reqs(s); - ret = bdrv_flush(s->bs); + ret = bdrv_co_flush(s->bs); (void) ret; } static void qed_need_check_timer_cb(void *opaque) { - BDRVQEDState *s = opaque; - - /* The timer should only fire when allocating writes have drained */ - assert(!s->allocating_acb); - - trace_qed_need_check_timer_cb(s); - - qed_acquire(s); - qed_plug_allocating_write_reqs(s); - - /* Ensure writes are on disk before clearing flag */ - bdrv_aio_flush(s->bs->file->bs, qed_clear_need_check, s); - qed_release(s); + Coroutine *co = qemu_coroutine_create(qed_need_check_timer_entry, opaque); + qemu_coroutine_enter(co); } void qed_acquire(BDRVQEDState *s) |