[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v6 16/42] block: Flush all children in generic code
From: |
Max Reitz |
Subject: |
[Qemu-block] [PATCH v6 16/42] block: Flush all children in generic code |
Date: |
Fri, 9 Aug 2019 18:13:41 +0200 |
If the driver does not support .bdrv_co_flush() so bdrv_co_flush()
itself has to flush the children of the given node, it should not flush
just bs->file->bs, but in fact all children.
In any case, the BLKDBG_EVENT() should be emitted on the primary child,
because that is where a blkdebug node would be if there is any.
Suggested-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
---
block/io.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/block/io.c b/block/io.c
index c5a8e3e6a3..bcc770d336 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2572,6 +2572,8 @@ static void coroutine_fn bdrv_flush_co_entry(void *opaque)
int coroutine_fn bdrv_co_flush(BlockDriverState *bs)
{
+ BdrvChild *primary_child = bdrv_primary_child(bs);
+ BdrvChild *child;
int current_gen;
int ret = 0;
@@ -2601,7 +2603,7 @@ int coroutine_fn bdrv_co_flush(BlockDriverState *bs)
}
/* Write back cached data to the OS even with cache=unsafe */
- BLKDBG_EVENT(bs->file, BLKDBG_FLUSH_TO_OS);
+ BLKDBG_EVENT(primary_child, BLKDBG_FLUSH_TO_OS);
if (bs->drv->bdrv_co_flush_to_os) {
ret = bs->drv->bdrv_co_flush_to_os(bs);
if (ret < 0) {
@@ -2611,15 +2613,15 @@ int coroutine_fn bdrv_co_flush(BlockDriverState *bs)
/* But don't actually force it to the disk with cache=unsafe */
if (bs->open_flags & BDRV_O_NO_FLUSH) {
- goto flush_parent;
+ goto flush_children;
}
/* Check if we really need to flush anything */
if (bs->flushed_gen == current_gen) {
- goto flush_parent;
+ goto flush_children;
}
- BLKDBG_EVENT(bs->file, BLKDBG_FLUSH_TO_DISK);
+ BLKDBG_EVENT(primary_child, BLKDBG_FLUSH_TO_DISK);
if (!bs->drv) {
/* bs->drv->bdrv_co_flush() might have ejected the BDS
* (even in case of apparent success) */
@@ -2663,8 +2665,17 @@ int coroutine_fn bdrv_co_flush(BlockDriverState *bs)
/* Now flush the underlying protocol. It will also have BDRV_O_NO_FLUSH
* in the case of cache=unsafe, so there are no useless flushes.
*/
-flush_parent:
- ret = bs->file ? bdrv_co_flush(bs->file->bs) : 0;
+flush_children:
+ ret = 0;
+ QLIST_FOREACH(child, &bs->children, next) {
+ int this_child_ret;
+
+ this_child_ret = bdrv_co_flush(child->bs);
+ if (!ret) {
+ ret = this_child_ret;
+ }
+ }
+
out:
/* Notify any pending flushes that we have completed */
if (ret == 0) {
--
2.21.0
- Re: [Qemu-block] [PATCH v6 09/42] block: Include filters when freezing backing chain, (continued)
- [Qemu-block] [PATCH v6 10/42] block: Drop bdrv_is_encrypted(), Max Reitz, 2019/08/09
- [Qemu-block] [PATCH v6 11/42] block: Add bdrv_supports_compressed_writes(), Max Reitz, 2019/08/09
- [Qemu-block] [PATCH v6 12/42] block: Use bdrv_filtered_rw* where obvious, Max Reitz, 2019/08/09
- [Qemu-block] [PATCH v6 13/42] block: Use CAFs in block status functions, Max Reitz, 2019/08/09
- [Qemu-block] [PATCH v6 14/42] block: Use CAFs when working with backing chains, Max Reitz, 2019/08/09
- [Qemu-block] [PATCH v6 15/42] block: Re-evaluate backing file handling in reopen, Max Reitz, 2019/08/09
- [Qemu-block] [PATCH v6 16/42] block: Flush all children in generic code,
Max Reitz <=
- [Qemu-block] [PATCH v6 17/42] block: Use CAFs in bdrv_refresh_limits(), Max Reitz, 2019/08/09
- [Qemu-block] [PATCH v6 18/42] block: Use CAFs in bdrv_refresh_filename(), Max Reitz, 2019/08/09
- [Qemu-block] [PATCH v6 19/42] block: Use CAF in bdrv_co_rw_vmstate(), Max Reitz, 2019/08/09
- [Qemu-block] [PATCH v6 20/42] block/snapshot: Fix fallback, Max Reitz, 2019/08/09
- [Qemu-block] [PATCH v6 21/42] block: Use CAFs for debug breakpoints, Max Reitz, 2019/08/09