deleted file mode 100644
Binary files a/block/.block-backend.c.swp and /dev/null differ
@@ -91,7 +91,12 @@ static void virtio_blk_rw_complete(void *opaque, int ret)
VirtIOBlock *s = next->dev;
VirtIODevice *vdev = VIRTIO_DEVICE(s);
QEMU_LOG(LOG_INFO, "virtio_blk_rw_complete before context_acquire: %p\n", (blk_get_aio_context(s->conf.conf.blk)));
- aio_context_acquire(blk_get_aio_context(s->conf.conf.blk));
+ static struct timespec ts_sleep;
+ ts_sleep.tv_sec = 0;
+ ts_sleep.tv_nsec = 50 * 1000 * 1000ull;
+ while (aio_context_tryacquire(blk_get_aio_context(s->conf.conf.blk))) {
+ nanosleep(&ts_sleep, NULL);
+ }
while (next) {
VirtIOBlockReq *req = next;
next = req->mr_next;
@@ -174,6 +174,8 @@ void aio_context_ref(AioContext *ctx);
*/
void aio_context_unref(AioContext *ctx);
+int aio_context_tryacquire(AioContext *ctx);
+
/* Take ownership of the AioContext. If the AioContext will be shared between
* threads, and a thread does not want to be interrupted, it will have to
* take ownership around calls to aio_poll(). Otherwise, aio_poll()
@@ -498,6 +498,10 @@ void aio_context_unref(AioContext *ctx)
g_source_unref(&ctx->source);
}
+int aio_context_acquire(AioContext *ctx) {
+ return qemu_rec_mutex_trylock(&ctx->lock);
+}
+
void aio_context_acquire(AioContext *ctx)
{
qemu_rec_mutex_lock(&ctx->lock);