[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v7 18/47] block: Flush all children in generic code

From: Andrey Shinkevich
Subject: Re: [PATCH v7 18/47] block: Flush all children in generic code
Date: Tue, 14 Jul 2020 15:52:18 +0300
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.9.0

On 25.06.2020 18:21, Max Reitz wrote:
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 that might have been written
to (judging from the permissions taken on them).

This is a bug fix for qcow2 images with an external data file, as they
so far did not flush that data_file node.

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 <vsementsov@virtuozzo.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
  block/io.c | 23 +++++++++++++++++------
  1 file changed, 17 insertions(+), 6 deletions(-)
@@ 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.
-    ret = bs->file ? bdrv_co_flush(bs->file->bs) : 0;
+    ret = 0;
+    QLIST_FOREACH(child, &bs->children, next) {
+        if (child->perm & (BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED)) {
+            int this_child_ret = bdrv_co_flush(child->bs);
+            if (!ret) {
+                ret = this_child_ret;
+            }
+        }
+    }
      /* Notify any pending flushes that we have completed */
      if (ret == 0) {

I have not tested if the running application do reaches the flush_parent point to flush the data_file but with the code it looks OK.

Reviewed-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]