Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NjxIG-0006gr-CW for qemu-devel@nongnu.org; Tue, 23 Feb 2010 11:07:28 -0500 Received: from [199.232.76.173] (port=46301 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NjxIG-0006gN-1G for qemu-devel@nongnu.org; Tue, 23 Feb 2010 11:07:28 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NjxIC-0004UN-91 for qemu-devel@nongnu.org; Tue, 23 Feb 2010 11:07:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:4480) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NjxIB-0004UB-To for qemu-devel@nongnu.org; Tue, 23 Feb 2010 11:07:24 -0500 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1NG7Mxr018296 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 23 Feb 2010 11:07:22 -0500 From: Juan Quintela In-Reply-To: <1266939654-26510-3-git-send-email-kwolf@redhat.com> (Kevin Wolf's message of "Tue, 23 Feb 2010 16:40:53 +0100") References: <1266939654-26510-1-git-send-email-kwolf@redhat.com> <1266939654-26510-3-git-send-email-kwolf@redhat.com> Date: Tue, 23 Feb 2010 17:07:20 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: [Qemu-devel] Re: [PATCH v2 2/3] qcow2: Rewrite alloc_refcount_block/grow_refcount_table List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel@nongnu.org Kevin Wolf wrote: > The current implementation of alloc_refcount_block and grow_refcount_table has > fundamental problems regarding error handling. There are some places where an > I/O error means that the image is going to be corrupted. I have found that the > only way to fix this is to completely rewrite the thing. > > In detail, the problem is that the refcount blocks itself are allocated using > alloc_refcount_noref (to avoid endless recursion when updating the refcount of > the new refcount block, which migh access just the same refcount block but its > allocation is not yet completed...). Only at the end of the refcount allocation > the refcount of the refcount block is increased. If an error happens in > between, the refcount block is in use, but has a refcount of zero and will > likely be overwritten later. > > The new approach is explained in comments in the code. The trick is basically > to let new refcount blocks describe their own refcount, so their refcount will > be automatically changed when they are hooked up in the refcount table. > > Signed-off-by: Kevin Wolf Acked-by: Juan Quintela