From patchwork Thu Sep 20 19:13:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Cody X-Patchwork-Id: 185443 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 412EA2C009E for ; Fri, 21 Sep 2012 05:13:58 +1000 (EST) Received: from localhost ([::1]:35524 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEmCC-0007KA-9l for incoming@patchwork.ozlabs.org; Thu, 20 Sep 2012 15:13:56 -0400 Received: from eggs.gnu.org ([208.118.235.92]:41071) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEmC6-0007Ju-0U for qemu-devel@nongnu.org; Thu, 20 Sep 2012 15:13:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TEmC4-0000QY-TU for qemu-devel@nongnu.org; Thu, 20 Sep 2012 15:13:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30881) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEmC4-0000QM-LK for qemu-devel@nongnu.org; Thu, 20 Sep 2012 15:13:48 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8KJDkp4020718 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 20 Sep 2012 15:13:46 -0400 Received: from localhost (ovpn-112-41.phx2.redhat.com [10.3.112.41]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q8KJDhc7007166 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 20 Sep 2012 15:13:45 -0400 From: Jeff Cody To: qemu-devel@nongnu.org Date: Thu, 20 Sep 2012 15:13:18 -0400 Message-Id: <83d32be6a2bbecce4e3ebf156498f92021e2f5b1.1348157913.git.jcody@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 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, eblake@redhat.com, supriyak@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH v4 02/19] 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 4c0e7f5..458bcc9 100644 --- a/block.c +++ b/block.c @@ -2168,6 +2168,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)