qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [6986] Fix (at least one cause of) qcow2 corruption.


From: Anthony Liguori
Subject: [Qemu-devel] [6986] Fix (at least one cause of) qcow2 corruption.
Date: Sun, 05 Apr 2009 18:16:00 +0000

Revision: 6986
          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6986
Author:   aliguori
Date:     2009-04-05 18:15:59 +0000 (Sun, 05 Apr 2009)
Log Message:
-----------
Fix (at least one cause of) qcow2 corruption. (Nolan Leake)

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 <nolan <at> sigbus.net>
Signed-off-by: Anthony Liguori <address@hidden>

Modified Paths:
--------------
    branches/stable_0_10/block-qcow2.c

Modified: branches/stable_0_10/block-qcow2.c
===================================================================
--- branches/stable_0_10/block-qcow2.c  2009-04-05 18:15:54 UTC (rev 6985)
+++ branches/stable_0_10/block-qcow2.c  2009-04-05 18:15:59 UTC (rev 6986)
@@ -670,6 +670,10 @@
 
     nb_available = (nb_available >> 9) + index_in_cluster;
 
+    if (nb_needed > nb_available) {
+        nb_needed = nb_available;
+    }
+
     cluster_offset = 0;
 
     /* seek the the l2 offset in the l1 table */





reply via email to

[Prev in Thread] Current Thread [Next in Thread]