From patchwork Tue Apr 19 01:42:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 611953 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qpnpp5VQ8z9t8g for ; Tue, 19 Apr 2016 11:43:30 +1000 (AEST) Received: from localhost ([::1]:48525 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1asKhM-0001TQ-BK for incoming@patchwork.ozlabs.org; Mon, 18 Apr 2016 21:43:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44181) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1asKgt-0000YD-Uh for qemu-devel@nongnu.org; Mon, 18 Apr 2016 21:43:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1asKgt-0004o4-5Z for qemu-devel@nongnu.org; Mon, 18 Apr 2016 21:42:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53499) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1asKgr-0004lA-Er; Mon, 18 Apr 2016 21:42:57 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1A45A85365; Tue, 19 Apr 2016 01:42:57 +0000 (UTC) Received: from lemon.redhat.com (vpn1-4-251.pek2.redhat.com [10.72.4.251]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3J1gmHo023210; Mon, 18 Apr 2016 21:42:54 -0400 From: Fam Zheng To: qemu-devel@nongnu.org Date: Tue, 19 Apr 2016 09:42:57 +0800 Message-Id: <1461030177-29144-3-git-send-email-famz@redhat.com> In-Reply-To: <1461030177-29144-1-git-send-email-famz@redhat.com> References: <1461030177-29144-1-git-send-email-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/2] block: Inactivate all children X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Currently we only inactivate the top BDS. Actually bdrv_inactivate should be the opposite of bdrv_invalidate_cache. Recurse into the whole subtree instead. Signed-off-by: Fam Zheng --- block.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/block.c b/block.c index fa8b38f..9a84ed1 100644 --- a/block.c +++ b/block.c @@ -3260,8 +3260,16 @@ void bdrv_invalidate_cache_all(Error **errp) static int bdrv_inactivate(BlockDriverState *bs) { + BdrvChild *child; int ret; + QLIST_FOREACH(child, &bs->children, next) { + ret = bdrv_inactivate(child->bs); + if (ret < 0) { + return ret; + } + } + if (bs->drv->bdrv_inactivate) { ret = bs->drv->bdrv_inactivate(bs); if (ret < 0) {