From patchwork Wed Jan 20 16:25:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 8072951 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 389BF9F1CC for ; Wed, 20 Jan 2016 16:32:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9A7942045E for ; Wed, 20 Jan 2016 16:32:13 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EFCBA20456 for ; Wed, 20 Jan 2016 16:32:12 +0000 (UTC) Received: from localhost ([::1]:43944 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLvg4-0007ff-9v for patchwork-qemu-devel@patchwork.kernel.org; Wed, 20 Jan 2016 11:32:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59136) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLvZd-0003pu-Me for qemu-devel@nongnu.org; Wed, 20 Jan 2016 11:25:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aLvZc-00074R-Gi for qemu-devel@nongnu.org; Wed, 20 Jan 2016 11:25:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56137) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLvZY-00072M-MO; Wed, 20 Jan 2016 11:25:28 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 5E5B291585; Wed, 20 Jan 2016 16:25:28 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-62.ams2.redhat.com [10.36.116.62]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0KGP8Ca032534; Wed, 20 Jan 2016 11:25:27 -0500 From: Kevin Wolf To: qemu-block@nongnu.org Date: Wed, 20 Jan 2016 17:25:02 +0100 Message-Id: <1453307106-28330-14-git-send-email-kwolf@redhat.com> In-Reply-To: <1453307106-28330-1-git-send-email-kwolf@redhat.com> References: <1453307106-28330-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PULL 13/17] qcow2: Fix BDRV_O_INACTIVE handling in qcow2_invalidate_cache() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP What qcow2_invalidate_cache() should do is close the image with BDRV_O_INACTIVE set and reopen it with the flag cleared. In fact, it used to do exactly the opposite: qcow2_close() relied on bs->open_flags, which is already updated to have cleared BDRV_O_INACTIVE at this point, whereas qcow2_open() was called with s->flags, which has the flag still set. Fix this. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- block/qcow2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/qcow2.c b/block/qcow2.c index bfc80ea..0f8c485 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1719,7 +1719,7 @@ static void qcow2_close(BlockDriverState *bs) /* else pre-write overlap checks in cache_destroy may crash */ s->l1_table = NULL; - if (!(bs->open_flags & BDRV_O_INACTIVE)) { + if (!(s->flags & BDRV_O_INACTIVE)) { qcow2_inactivate(bs); } @@ -1770,6 +1770,7 @@ static void qcow2_invalidate_cache(BlockDriverState *bs, Error **errp) memset(s, 0, sizeof(BDRVQcow2State)); options = qdict_clone_shallow(bs->options); + flags &= ~BDRV_O_INACTIVE; ret = qcow2_open(bs, options, flags, &local_err); QDECREF(options); if (local_err) {