From patchwork Tue Sep 18 18:53:07 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Cody X-Patchwork-Id: 184815 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 25F712C0095 for ; Wed, 19 Sep 2012 05:49:18 +1000 (EST) Received: from localhost ([::1]:54395 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TE3nI-00055i-8A for incoming@patchwork.ozlabs.org; Tue, 18 Sep 2012 15:49:16 -0400 Received: from eggs.gnu.org ([208.118.235.92]:34125) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TE2w3-0003MZ-5n for qemu-devel@nongnu.org; Tue, 18 Sep 2012 14:54:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TE2vy-0004X4-Mj for qemu-devel@nongnu.org; Tue, 18 Sep 2012 14:54:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:3137) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TE2vy-0004Wn-DQ for qemu-devel@nongnu.org; Tue, 18 Sep 2012 14:54:10 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8IIrVHA015733 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 18 Sep 2012 14:53:31 -0400 Received: from localhost (ovpn-112-22.phx2.redhat.com [10.3.112.22]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q8IIrTgG022963 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Tue, 18 Sep 2012 14:53:30 -0400 From: Jeff Cody To: qemu-devel@nongnu.org Date: Tue, 18 Sep 2012 14:53:07 -0400 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 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 v3 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 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)