From f4dfd3f3a2a6d8d779252df8703cf83294afb5a6 Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: References: From: Kevin Wolf Date: Fri, 14 Jun 2013 16:08:08 +0200 Subject: [PATCH 5/6] qcow2: Reinitialise counter when restarting allocation RH-Author: Kevin Wolf Message-id: <1371226088-9945-1-git-send-email-kwolf@redhat.com> Patchwork-id: 51973 O-Subject: [RHEL-6.5/6.4.z qemu-kvm PATCH] qcow2: Reinitialise counter when restarting allocation Bugzilla: 974617 RH-Acked-by: Laszlo Ersek RH-Acked-by: Paolo Bonzini RH-Acked-by: Stefan Hajnoczi Bugzilla: 974617 Upstream status: n/a (accidentally fixed in a later commit) When an allocating request is restarted after waiting for a dependency (it's the 'goto again' case), i wasn't reset to zero, potentially leading to an incorrect number of clusters to be COWed. This bug wasn't reported against upstream, where later code changes fixed the bug as a side effect, but against Ubuntu Precise: https://bugs.launchpad.net/ubuntu/precise/+source/qemu-kvm/+bug/1189926 Signed-off-by: Kevin Wolf --- block/qcow2-cluster.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) Signed-off-by: Michal Novotny --- block/qcow2-cluster.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 22dd928..0bea2c5 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -708,7 +708,7 @@ int qcow2_alloc_cluster_offset(BlockDriverState *bs, uint64_t offset, int l2_index, ret; uint64_t l2_offset, *l2_table; int64_t cluster_offset; - unsigned int nb_clusters, i = 0; + unsigned int nb_clusters, i; QCowL2Meta *old_alloc; again: @@ -747,7 +747,7 @@ again: nb_clusters = 1; /* how many available clusters ? */ - + i = 0; while (i < nb_clusters) { i += count_contiguous_clusters(nb_clusters - i, s->cluster_size, &l2_table[l2_index], i, 0); -- 1.7.11.7