Received: from [140.186.70.92] (port=47885 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P60DO-00017a-Gx for qemu-devel@nongnu.org; Wed, 13 Oct 2010 08:14:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P60D8-0000Iy-AL for qemu-devel@nongnu.org; Wed, 13 Oct 2010 08:13:35 -0400 Received: from mtagate2.de.ibm.com ([195.212.17.162]:60323) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P60D8-0000Ie-2P for qemu-devel@nongnu.org; Wed, 13 Oct 2010 08:13:34 -0400 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate2.de.ibm.com (8.13.1/8.13.1) with ESMTP id o9DCDWUE001641 for ; Wed, 13 Oct 2010 12:13:32 GMT Received: from d12av04.megacenter.de.ibm.com (d12av04.megacenter.de.ibm.com [9.149.165.229]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o9DCDU2n3985460 for ; Wed, 13 Oct 2010 14:13:32 +0200 Received: from d12av04.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av04.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id o9DCDTHS025195 for ; Wed, 13 Oct 2010 14:13:30 +0200 Date: Wed, 13 Oct 2010 13:13:29 +0100 From: Stefan Hajnoczi Message-ID: <20101013121328.GB8998@stefan-thinkpad.transitives.com> References: <1286552914-27014-1-git-send-email-stefanha@linux.vnet.ibm.com> <1286552914-27014-7-git-send-email-stefanha@linux.vnet.ibm.com> <4CB479D2.7030901@redhat.com> <4CB47D38.3060602@linux.vnet.ibm.com> <4CB48144.9030607@redhat.com> <20101012155953.GA13872@stefan-thinkpad.transitives.com> <4CB489D1.3050204@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4CB489D1.3050204@linux.vnet.ibm.com> Subject: [Qemu-devel] Re: [PATCH v2 6/7] qed: Read/write support List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Kevin Wolf , Avi Kivity , qemu-devel@nongnu.org, Christoph Hellwig On Tue, Oct 12, 2010 at 11:16:17AM -0500, Anthony Liguori wrote: > On 10/12/2010 10:59 AM, Stefan Hajnoczi wrote: > >On Tue, Oct 12, 2010 at 05:39:48PM +0200, Kevin Wolf wrote: > >>Am 12.10.2010 17:22, schrieb Anthony Liguori: > >>>On 10/12/2010 10:08 AM, Kevin Wolf wrote: > >>>> Otherwise we might destroy data that isn't > >>>>even touched by the guest request in case of a crash. > >>>> > >>>The failure scenarios are either that the cluster is leaked in which > >>>case, the old version of the data is still present or the cluster is > >>>orphaned because the L2 entry is written, in which case the old version > >>>of the data is present. > >>Hm, how does the latter case work? Or rather, what do mean by "orphaned"? > >> > >>>Are you referring to a scenario where the cluster is partially written > >>>because the data is present in the write cache and the write cache isn't > >>>flushed on power failure? > >>The case I'm referring to is a COW. So let's assume a partial write to > >>an unallocated cluster, we then need to do a COW in pre/postfill. Then > >>we do a normal write and link the new cluster in the L2 table. > >> > >>Assume that the write to the L2 table is already on the disk, but the > >>pre/postfill data isn't yet. At this point we have a bad state because > >>if we crash now we have lost the data that should have been copied from > >>the backing file. > >In this case QED_F_NEED_CHECK is set and the invalid cluster offset > >should be reset to zero on open. > > > >However, I think we can get into a state where the pre/postfill data > >isn't on the disk yet but another allocation has increased the file > >size, making the unwritten cluster "valid". This fools consistency > >check into thinking the data cluster (which was never written to on > >disk) is valid. > > > >Will think about this more tonight. > > It's fairly simple to add a sync to this path. It's probably worth > checking the prefill/postfill for zeros and avoiding the write/sync > if that's the case. That should optimize the common cases of > allocating new space within a file. > > My intuition is that we can avoid the sync entirely but we'll need > to think about it further. We can avoid it when a backing image is not used. Your idea to check for zeroes in the backing image is neat too, it may well reduce the common case even for backing images. Stefan