Commit 986c28d655dc9196c9c426c667c1764bd3d6d5bd
Committed by
Christoph Hellwig
1 parent
e19252d3
fix qemu_aio_flush
qemu_aio_wait by invoking the bh or one of the aio completion callbacks, could end up submitting new pending aio, breaking the invariant that qemu_aio_flush returns only when no pending aio is outstanding (possibly a problem for migration as such). Signed-off-by: Andrea Arcangeli <aarcange@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Kevin Wolf <kwolf@redhat.com>
Showing
2 changed files
with
10 additions
and
5 deletions
aio.c
| ... | ... | @@ -103,11 +103,15 @@ void qemu_aio_flush(void) |
| 103 | 103 | do { |
| 104 | 104 | ret = 0; |
| 105 | 105 | |
| 106 | + /* | |
| 107 | + * If there are pending emulated aio start them now so flush | |
| 108 | + * will be able to return 1. | |
| 109 | + */ | |
| 110 | + qemu_aio_wait(); | |
| 111 | + | |
| 106 | 112 | LIST_FOREACH(node, &aio_handlers, node) { |
| 107 | 113 | ret |= node->io_flush(node->opaque); |
| 108 | 114 | } |
| 109 | - | |
| 110 | - qemu_aio_wait(); | |
| 111 | 115 | } while (ret > 0); |
| 112 | 116 | } |
| 113 | 117 | ... | ... |
qemu-aio.h
| ... | ... | @@ -24,9 +24,10 @@ typedef int (AioFlushHandler)(void *opaque); |
| 24 | 24 | * outstanding AIO operations have been completed or cancelled. */ |
| 25 | 25 | void qemu_aio_flush(void); |
| 26 | 26 | |
| 27 | -/* Wait for a single AIO completion to occur. This function will until a | |
| 28 | - * single AIO opeartion has completed. It is intended to be used as a looping | |
| 29 | - * primative when simulating synchronous IO based on asynchronous IO. */ | |
| 27 | +/* Wait for a single AIO completion to occur. This function will wait | |
| 28 | + * until a single AIO event has completed and it will ensure something | |
| 29 | + * has moved before returning. This can issue new pending aio as | |
| 30 | + * result of executing I/O completion or bh callbacks. */ | |
| 30 | 31 | void qemu_aio_wait(void); |
| 31 | 32 | |
| 32 | 33 | /* Register a file descriptor and associated callbacks. Behaves very similarly | ... | ... |