aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--blockjob.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/blockjob.c b/blockjob.c
index 69126af97f..2159df776b 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -755,12 +755,16 @@ static void block_job_defer_to_main_loop_bh(void *opaque)
/* Fetch BDS AioContext again, in case it has changed */
aio_context = blk_get_aio_context(data->job->blk);
- aio_context_acquire(aio_context);
+ if (aio_context != data->aio_context) {
+ aio_context_acquire(aio_context);
+ }
data->job->deferred_to_main_loop = false;
data->fn(data->job, data->opaque);
- aio_context_release(aio_context);
+ if (aio_context != data->aio_context) {
+ aio_context_release(aio_context);
+ }
aio_context_release(data->aio_context);