From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39125) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1asREV-0003i5-IR for qemu-devel@nongnu.org; Tue, 19 Apr 2016 04:42:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1asREU-000166-Mp for qemu-devel@nongnu.org; Tue, 19 Apr 2016 04:42:07 -0400 Message-ID: <5715EFFD.3050508@cn.fujitsu.com> Date: Tue, 19 Apr 2016 16:44:45 +0800 From: Changlong Xie MIME-Version: 1.0 References: <1461030177-29144-1-git-send-email-famz@redhat.com> <1461030177-29144-2-git-send-email-famz@redhat.com> In-Reply-To: <1461030177-29144-2-git-send-email-famz@redhat.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1/2] block: Invalidate all children List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz On 04/19/2016 09:42 AM, Fam Zheng wrote: > 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 > --- > block.c | 20 ++++++++++++++------ > 1 file changed, 14 insertions(+), 6 deletions(-) > > diff --git a/block.c b/block.c > index d4939b4..fa8b38f 100644 > --- a/block.c > +++ b/block.c > @@ -3201,6 +3201,7 @@ void bdrv_init_with_whitelist(void) > > void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp) > { > + BdrvChild *child; > Error *local_err = NULL; > int ret; > > @@ -3215,13 +3216,20 @@ void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp) > > if (bs->drv->bdrv_invalidate_cache) { > bs->drv->bdrv_invalidate_cache(bs, &local_err); Kevin's commit 3456a8d1 introduced unexpected two spaces in this function, would you like remove it? - if (bs->drv && bs->drv->bdrv_invalidate_cache) { + if (!bs->drv) { + return; + } > - } 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; If we really need return here? I just mean for example, Quorum A has 3 children(children.0, children.1, children.2), if we invalidate children.1 failed, then we are not going to invalidate children.2 > + } > } > > ret = refresh_total_sectors(bs, bs->total_sectors); >