From patchwork Tue Jan 12 12:49:23 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 42722 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5E115B7C67 for ; Tue, 12 Jan 2010 23:53:57 +1100 (EST) Received: from localhost ([127.0.0.1]:46010 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NUgCt-0008PV-Q3 for incoming@patchwork.ozlabs.org; Tue, 12 Jan 2010 07:50:47 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NUgBi-0008Og-A6 for qemu-devel@nongnu.org; Tue, 12 Jan 2010 07:49:34 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NUgBd-0008NT-DI for qemu-devel@nongnu.org; Tue, 12 Jan 2010 07:49:33 -0500 Received: from [199.232.76.173] (port=33989 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NUgBc-0008NL-Uu for qemu-devel@nongnu.org; Tue, 12 Jan 2010 07:49:29 -0500 Received: from verein.lst.de ([213.95.11.210]:32989) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA1:24) (Exim 4.60) (envelope-from ) id 1NUgBc-0001MU-El for qemu-devel@nongnu.org; Tue, 12 Jan 2010 07:49:28 -0500 Received: from verein.lst.de (localhost [127.0.0.1]) by verein.lst.de (8.12.3/8.12.3/Debian-7.1) with ESMTP id o0CCnNWY019809 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Tue, 12 Jan 2010 13:49:23 +0100 Received: (from hch@localhost) by verein.lst.de (8.12.3/8.12.3/Debian-7.2) id o0CCnNIR019808 for qemu-devel@nongnu.org; Tue, 12 Jan 2010 13:49:23 +0100 Date: Tue, 12 Jan 2010 13:49:23 +0100 From: Christoph Hellwig To: qemu-devel@nongnu.org Message-ID: <20100112124923.GA19631@lst.de> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.3.28i X-Spam-Score: 0 () X-Scanned-By: MIMEDefang 2.39 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Qemu-devel] [PATCH 1/2] block: flush backing_hd in the right place X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The backing device is only modified from bdrv_commit. So instead of flushing it every time bdrv_flush is called for the front-end device only flush it after we're written data to it in bdrv_commit. Signed-off-by: Christoph Hellwig Index: qemu/block.c =================================================================== --- qemu.orig/block.c 2010-01-12 11:34:35.549024986 +0100 +++ qemu/block.c 2010-01-12 11:43:28.965006129 +0100 @@ -623,6 +623,12 @@ int bdrv_commit(BlockDriverState *bs) if (drv->bdrv_make_empty) return drv->bdrv_make_empty(bs); + /* + * Make sure all data we wrote to the backing device is actually + * stable on disk. + */ + if (bs->backing_hd) + bdrv_flush(bs->backing_hd); return 0; } @@ -1124,12 +1130,8 @@ const char *bdrv_get_device_name(BlockDr void bdrv_flush(BlockDriverState *bs) { - if (!bs->drv) - return; - if (bs->drv->bdrv_flush) + if (bs->drv && bs->drv->bdrv_flush) bs->drv->bdrv_flush(bs); - if (bs->backing_hd) - bdrv_flush(bs->backing_hd); } void bdrv_flush_all(void) @@ -1806,11 +1808,6 @@ BlockDriverAIOCB *bdrv_aio_flush(BlockDr if (!drv) return NULL; - - /* - * Note that unlike bdrv_flush the driver is reponsible for flushing a - * backing image if it exists. - */ return drv->bdrv_aio_flush(bs, cb, opaque); }