diff options
-rw-r--r-- | block/io.c | 5 | ||||
-rw-r--r-- | include/block/block_int.h | 2 |
2 files changed, 4 insertions, 3 deletions
diff --git a/block/io.c b/block/io.c index d5493ba349..9c04086286 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,6 +2357,7 @@ flush_parent: out: /* Notify any pending flushes that we have completed */ bs->flushed_gen = current_gen; + bs->active_flush_req = NULL; qemu_co_queue_restart_all(&bs->flush_queue); tracked_request_end(&req); 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 */ |