From 120bf15cb6607f960f648d1ddd5171bfe58f36e4 Mon Sep 17 00:00:00 2001 From: John Snow Date: Wed, 14 Sep 2016 20:04:35 +0200 Subject: [PATCH 11/18] block: Invalidate all children RH-Author: John Snow Message-id: <1473883477-31953-2-git-send-email-jsnow@redhat.com> Patchwork-id: 72331 O-Subject: [RHEV-7.3 qemu-kvm-rhev PATCH 1/3] block: Invalidate all children Bugzilla: 1355927 RH-Acked-by: Fam Zheng RH-Acked-by: Kevin Wolf RH-Acked-by: Miroslav Rezanina From: Fam Zheng Currently we only recurse to bs->file, which will miss the children in quorum and VMDK. Recurse into the whole subtree to avoid that. Signed-off-by: Fam Zheng Reviewed-by: Alberto Garcia Signed-off-by: Kevin Wolf (cherry picked from commit 0d1c5c91607d1c55a8f5db39c57c6e5c76e21131) Signed-off-by: John Snow Signed-off-by: Miroslav Rezanina --- block.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/block.c b/block.c index 65ee043..c5a4391 100644 --- a/block.c +++ b/block.c @@ -3205,6 +3205,7 @@ void bdrv_init_with_whitelist(void) void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp) { + BdrvChild *child; Error *local_err = NULL; int ret; @@ -3219,13 +3220,20 @@ void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp) if (bs->drv->bdrv_invalidate_cache) { bs->drv->bdrv_invalidate_cache(bs, &local_err); - } else if (bs->file) { - bdrv_invalidate_cache(bs->file->bs, &local_err); + if (local_err) { + bs->open_flags |= BDRV_O_INACTIVE; + error_propagate(errp, local_err); + return; + } } - if (local_err) { - bs->open_flags |= BDRV_O_INACTIVE; - error_propagate(errp, local_err); - return; + + QLIST_FOREACH(child, &bs->children, next) { + bdrv_invalidate_cache(child->bs, &local_err); + if (local_err) { + bs->open_flags |= BDRV_O_INACTIVE; + error_propagate(errp, local_err); + return; + } } ret = refresh_total_sectors(bs, bs->total_sectors); -- 1.8.3.1