From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NUztP-0004u0-2Q for qemu-devel@nongnu.org; Wed, 13 Jan 2010 04:51:59 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NUztJ-0004tc-29 for qemu-devel@nongnu.org; Wed, 13 Jan 2010 04:51:57 -0500 Received: from [199.232.76.173] (port=48774 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NUztI-0004tZ-TW for qemu-devel@nongnu.org; Wed, 13 Jan 2010 04:51:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38869) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NUztI-0004Ak-86 for qemu-devel@nongnu.org; Wed, 13 Jan 2010 04:51:52 -0500 Message-ID: <4B4D977A.1090508@redhat.com> Date: Wed, 13 Jan 2010 10:50:50 +0100 From: Kevin Wolf MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 1/2 v2] block: flush backing_hd in the right place References: <20100112124923.GA19631@lst.de> <20100112181306.GA1849@lst.de> In-Reply-To: <20100112181306.GA1849@lst.de> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Christoph Hellwig Cc: qemu-devel@nongnu.org Am 12.01.2010 19:13, schrieb Christoph Hellwig: > 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. > > Also flush the frontend image if we have a make_empty method that > possibly writes to it. > > Signed-off-by: Christoph Hellwig > > Index: qemu/block.c > =================================================================== > --- qemu.orig/block.c 2010-01-12 19:08:07.363003775 +0100 > +++ qemu/block.c 2010-01-12 19:09:10.836255948 +0100 > @@ -589,6 +589,7 @@ int bdrv_commit(BlockDriverState *bs) > BlockDriver *drv = bs->drv; > int64_t i, total_sectors; > int n, j; > + int ret = 0; > unsigned char sector[512]; > > if (!drv) > @@ -620,10 +621,18 @@ int bdrv_commit(BlockDriverState *bs) > } > } > > - if (drv->bdrv_make_empty) > - return drv->bdrv_make_empty(bs); > + if (drv->bdrv_make_empty) { > + ret = drv->bdrv_make_empty(bs); > + bdrv_flush(bs); > + } Indentation is off here (but it already was before the patch). The logic looks good to me now. Kevin