[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 01/10] stream: Traverse graph after modification
From: |
Hanna Reitz |
Subject: |
[PATCH v2 01/10] stream: Traverse graph after modification |
Date: |
Thu, 11 Nov 2021 13:08:20 +0100 |
bdrv_cor_filter_drop() modifies the block graph. That means that other
parties can also modify the block graph before it returns. Therefore,
we cannot assume that the result of a graph traversal we did before
remains valid afterwards.
We should thus fetch `base` and `unfiltered_base` afterwards instead of
before.
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
block/stream.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/block/stream.c b/block/stream.c
index 97bee482dc..e45113aed6 100644
--- a/block/stream.c
+++ b/block/stream.c
@@ -54,8 +54,8 @@ static int stream_prepare(Job *job)
{
StreamBlockJob *s = container_of(job, StreamBlockJob, common.job);
BlockDriverState *unfiltered_bs = bdrv_skip_filters(s->target_bs);
- BlockDriverState *base = bdrv_filter_or_cow_bs(s->above_base);
- BlockDriverState *unfiltered_base = bdrv_skip_filters(base);
+ BlockDriverState *base;
+ BlockDriverState *unfiltered_base;
Error *local_err = NULL;
int ret = 0;
@@ -63,6 +63,9 @@ static int stream_prepare(Job *job)
bdrv_cor_filter_drop(s->cor_filter_bs);
s->cor_filter_bs = NULL;
+ base = bdrv_filter_or_cow_bs(s->above_base);
+ unfiltered_base = bdrv_skip_filters(base);
+
if (bdrv_cow_child(unfiltered_bs)) {
const char *base_id = NULL, *base_fmt = NULL;
if (unfiltered_base) {
--
2.33.1
- [PATCH v2 00/10] block: Attempt on fixing 030-reported errors, Hanna Reitz, 2021/11/11
- [PATCH v2 01/10] stream: Traverse graph after modification,
Hanna Reitz <=
- [PATCH v2 02/10] block: Manipulate children list in .attach/.detach, Hanna Reitz, 2021/11/11
- [PATCH v2 04/10] block: Drop detached child from ignore list, Hanna Reitz, 2021/11/11
- [PATCH v2 03/10] block: Unite remove_empty_child and child_free, Hanna Reitz, 2021/11/11
- [PATCH v2 05/10] block: Pass BdrvChild ** to replace_child_noperm, Hanna Reitz, 2021/11/11
- [PATCH v2 06/10] block: Restructure remove_file_or_backing_child(), Hanna Reitz, 2021/11/11
- [PATCH v2 08/10] block: Let replace_child_tran keep indirect pointer, Hanna Reitz, 2021/11/11
- [PATCH v2 07/10] transactions: Invoke clean() after everything else, Hanna Reitz, 2021/11/11