summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2016-08-18 14:42:51 +0100
committerPeter Maydell <peter.maydell@linaro.org>2016-08-18 14:42:51 +0100
commit02b1ad881cbb1795029737a9077db60267dc0c6f (patch)
treecb957f9d06a1dcd3591dc4a19b03edfe0018ff97
parent5844365fe8e5e4598222d276d2af54fd45c7e3d3 (diff)
parent156af3ac98da24f0155eed18ec546157436d6b2e (diff)
downloadqemu-02b1ad881cbb1795029737a9077db60267dc0c6f.tar.gz
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging
# gpg: Signature made Thu 18 Aug 2016 14:39:31 BST # gpg: using RSA key 0x9CA4ABB381AB73C8 # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" # gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" # Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35 775A 9CA4 ABB3 81AB 73C8 * remotes/stefanha/tags/block-pull-request: block: fix possible reorder of flush operations block: fix deadlock in bdrv_co_flush Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--block/io.c8
-rw-r--r--include/block/block_int.h2
2 files changed, 6 insertions, 4 deletions
diff --git a/block/io.c b/block/io.c
index d5493ba349..420944d80d 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2283,11 +2283,11 @@ int coroutine_fn bdrv_co_flush(BlockDriverState *bs)
int current_gen = bs->write_gen;
/* Wait until any previous flushes are completed */
- while (bs->flush_started_gen != bs->flushed_gen) {
+ while (bs->active_flush_req != NULL) {
qemu_co_queue_wait(&bs->flush_queue);
}
- bs->flush_started_gen = current_gen;
+ bs->active_flush_req = &req;
/* Write back all layers by calling one driver function */
if (bs->drv->bdrv_co_flush) {
@@ -2357,7 +2357,9 @@ flush_parent:
out:
/* Notify any pending flushes that we have completed */
bs->flushed_gen = current_gen;
- qemu_co_queue_restart_all(&bs->flush_queue);
+ bs->active_flush_req = NULL;
+ /* Return value is ignored - it's ok if wait queue is empty */
+ qemu_co_queue_next(&bs->flush_queue);
tracked_request_end(&req);
return ret;
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 47665be81e..1e939de4fe 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -443,8 +443,8 @@ struct BlockDriverState {
note this is a reference count */
CoQueue flush_queue; /* Serializing flush queue */
+ BdrvTrackedRequest *active_flush_req; /* Flush request in flight */
unsigned int write_gen; /* Current data generation */
- unsigned int flush_started_gen; /* Generation for which flush has started */
unsigned int flushed_gen; /* Flushed write generation */
BlockDriver *drv; /* NULL means no media */