From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LqWMW-0003B1-74 for qemu-devel@nongnu.org; Sun, 05 Apr 2009 13:42:28 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LqWMR-00039O-Im for qemu-devel@nongnu.org; Sun, 05 Apr 2009 13:42:27 -0400 Received: from [199.232.76.173] (port=34555 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LqWMR-00039K-7E for qemu-devel@nongnu.org; Sun, 05 Apr 2009 13:42:23 -0400 Received: from e39.co.us.ibm.com ([32.97.110.160]:38342) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LqWMQ-0004KE-Qx for qemu-devel@nongnu.org; Sun, 05 Apr 2009 13:42:23 -0400 Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by e39.co.us.ibm.com (8.13.1/8.13.1) with ESMTP id n35HdGk1004376 for ; Sun, 5 Apr 2009 11:39:16 -0600 Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v9.2) with ESMTP id n35HgLZP205602 for ; Sun, 5 Apr 2009 11:42:21 -0600 Received: from d03av03.boulder.ibm.com (loopback [127.0.0.1]) by d03av03.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n35HgLAT014793 for ; Sun, 5 Apr 2009 11:42:21 -0600 Received: from squirrel.codemonkey.ws (sig-9-65-213-73.mts.ibm.com [9.65.213.73]) by d03av03.boulder.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id n35HgKUj014776 for ; Sun, 5 Apr 2009 11:42:20 -0600 Message-ID: <49D8ED7B.3050507@us.ibm.com> Date: Sun, 05 Apr 2009 12:42:19 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] Fix (at least one cause of) qcow2 corruption. References: <1238539254.15350.554.camel@voxel> In-Reply-To: <1238539254.15350.554.camel@voxel> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Nolan wrote: > qcow2's get_cluster_offset() scans forward in the l2 table to find other > clusters that have the same allocation status as the first cluster. > This is used by (among others) qcow_is_allocated(). > > Unfortunately, it was not checking to be sure that it didn't fall off > the end of the l2 table. This patch adds that check. > > The symptom that motivated me to look into this was that > bdrv_is_allocated() was returning false when there was in fact data > there. This is one of many ways this bug could lead to data corruption. > > I checked the other place that scans for consecutive unallocated blocks > (alloc_cluster_offset()) and it appears to be OK: > nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); > appears to prevent the same problem from occurring. > > Signed-off-by: Nolan Leake sigbus.net> > Applied. Very good work. Thanks! Regards, Anthony Liguori