On 25.06.2020 18:21, Max Reitz wrote:
If the top node's driver does not provide snapshot functionality and we
want to fall back to a node down the chain, we need to snapshot all
non-COW children.  For simplicity's sake, just do not fall back if there

I guess it comes to COW children like BDRV_CHILD_DATA | BDRV_CHILD_METADATA  rather than non-COW ones, does it?

Andrey


is more than one such child.  Furthermore, we really only can fall back
to bs->file and bs->backing, because bdrv_snapshot_goto() has to modify
the child link (notably, set it to NULL).

Suggested-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Signed-off-by: Max Reitz <[email protected]>
---
  block/snapshot.c | 104 +++++++++++++++++++++++++++++++++++++----------
  1 file changed, 83 insertions(+), 21 deletions(-)

diff --git a/block/snapshot.c b/block/snapshot.c
...
+    /*
+     * Check that there are no other children that would need to be
+     * snapshotted.  If there are, it is not safe to fall back to
+     * *fallback.
+     */
+    QLIST_FOREACH(child, &bs->children, next) {
+        if (child->role & (BDRV_CHILD_DATA | BDRV_CHILD_METADATA |
+                           BDRV_CHILD_FILTERED) &&
+            child != *fallback)
+        {
+            return NULL;
+        }
+    }
+
+    return fallback;
+}

...

Reviewed-by: Andrey Shinkevich <[email protected]>


Reply via email to