From patchwork Thu Sep 13 15:49:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Cody X-Patchwork-Id: 183659 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C001A2C0086 for ; Fri, 14 Sep 2012 01:50:41 +1000 (EST) Received: from localhost ([::1]:44838 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TCBgd-0002Md-Rm for incoming@patchwork.ozlabs.org; Thu, 13 Sep 2012 11:50:39 -0400 Received: from eggs.gnu.org ([208.118.235.92]:35188) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TCBgC-0001lf-0W for qemu-devel@nongnu.org; Thu, 13 Sep 2012 11:50:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TCBg7-0005Bp-FS for qemu-devel@nongnu.org; Thu, 13 Sep 2012 11:50:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:2669) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TCBg6-00058s-P7 for qemu-devel@nongnu.org; Thu, 13 Sep 2012 11:50:07 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8DFo3T9025732 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 13 Sep 2012 11:50:03 -0400 Received: from localhost (ovpn-112-61.phx2.redhat.com [10.3.112.61]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q8DFo023001286 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 13 Sep 2012 11:50:02 -0400 From: Jeff Cody To: qemu-devel@nongnu.org Date: Thu, 13 Sep 2012 11:49:40 -0400 Message-Id: <984108651fa38ec104770e7c3b1130f5d16ac478.1347548248.git.jcody@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, pbonzini@redhat.com, stefanha@gmail.com, eblake@redhat.com, supriyak@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH v2 02/16] block: make bdrv_set_enable_write_cache() modify open_flags 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org bdrv_set_enable_write_cache() sets the bs->enable_write_cache flag, but without the flag recorded in bs->open_flags, then next time a reopen() is performed the enable_write_cache setting may be inadvertently lost. This will set the flag in open_flags, so it is preserved across reopens. Signed-off-by: Jeff Cody --- block.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/block.c b/block.c index c3eb585..2b96c8e 100644 --- a/block.c +++ b/block.c @@ -2164,6 +2164,13 @@ int bdrv_enable_write_cache(BlockDriverState *bs) void bdrv_set_enable_write_cache(BlockDriverState *bs, bool wce) { bs->enable_write_cache = wce; + + /* so a reopen() will preserve wce */ + if (wce) { + bs->open_flags |= BDRV_O_CACHE_WB; + } else { + bs->open_flags &= ~BDRV_O_CACHE_WB; + } } int bdrv_is_encrypted(BlockDriverState *bs)