[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 03/19] aio-wait: Increase num_waiters even in hom
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH v3 03/19] aio-wait: Increase num_waiters even in home thread |
Date: |
Thu, 20 Sep 2018 18:19:42 +0200 |
Even if AIO_WAIT_WHILE() is called in the home context of the
AioContext, we still want to allow the condition to change depending on
other threads as long as they kick the AioWait. Specfically block jobs
can be running in an I/O thread and should then be able to kick a drain
in the main loop context.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Fam Zheng <address@hidden>
---
include/block/aio-wait.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/block/aio-wait.h b/include/block/aio-wait.h
index c85a62f798..600fad183e 100644
--- a/include/block/aio-wait.h
+++ b/include/block/aio-wait.h
@@ -76,6 +76,8 @@ typedef struct {
bool waited_ = false; \
AioWait *wait_ = (wait); \
AioContext *ctx_ = (ctx); \
+ /* Increment wait_->num_waiters before evaluating cond. */ \
+ atomic_inc(&wait_->num_waiters); \
if (ctx_ && in_aio_context_home_thread(ctx_)) { \
while ((cond)) { \
aio_poll(ctx_, true); \
@@ -84,8 +86,6 @@ typedef struct {
} else { \
assert(qemu_get_current_aio_context() == \
qemu_get_aio_context()); \
- /* Increment wait_->num_waiters before evaluating cond. */ \
- atomic_inc(&wait_->num_waiters); \
while ((cond)) { \
if (ctx_) { \
aio_context_release(ctx_); \
@@ -96,8 +96,8 @@ typedef struct {
} \
waited_ = true; \
} \
- atomic_dec(&wait_->num_waiters); \
} \
+ atomic_dec(&wait_->num_waiters); \
waited_; })
/**
--
2.13.6
- [Qemu-devel] [PATCH v3 00/19] Fix some jobs/drain/aio_poll related hangs, Kevin Wolf, 2018/09/20
- [Qemu-devel] [PATCH v3 02/19] blockjob: Wake up BDS when job becomes idle, Kevin Wolf, 2018/09/20
- [Qemu-devel] [PATCH v3 01/19] job: Fix missing locking due to mismerge, Kevin Wolf, 2018/09/20
- [Qemu-devel] [PATCH v3 03/19] aio-wait: Increase num_waiters even in home thread,
Kevin Wolf <=
- [Qemu-devel] [PATCH v3 05/19] test-blockjob: Acquire AioContext around job_cancel_sync(), Kevin Wolf, 2018/09/20
- [Qemu-devel] [PATCH v3 04/19] test-bdrv-drain: Drain with block jobs in an I/O thread, Kevin Wolf, 2018/09/20
- [Qemu-devel] [PATCH v3 06/19] job: Use AIO_WAIT_WHILE() in job_finish_sync(), Kevin Wolf, 2018/09/20
- [Qemu-devel] [PATCH v3 09/19] block-backend: Add .drained_poll callback, Kevin Wolf, 2018/09/20
- [Qemu-devel] [PATCH v3 11/19] block-backend: Decrease in_flight only after callback, Kevin Wolf, 2018/09/20
- [Qemu-devel] [PATCH v3 08/19] block: Add missing locking in bdrv_co_drain_bh_cb(), Kevin Wolf, 2018/09/20
- [Qemu-devel] [PATCH v3 12/19] blockjob: Lie better in child_job_drained_poll(), Kevin Wolf, 2018/09/20
- [Qemu-devel] [PATCH v3 13/19] block: Remove aio_poll() in bdrv_drain_poll variants, Kevin Wolf, 2018/09/20
- [Qemu-devel] [PATCH v3 10/19] block-backend: Fix potential double blk_delete(), Kevin Wolf, 2018/09/20