From: Gleb Natapov <gleb@redhat.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: qemu-devel@nongnu.org, Alexander Graf <agraf@suse.de>
Subject: Re: [Qemu-devel] [5860] Cleanup {alloc|get}_cluster_offset() (Gleb Natapov)
Date: Thu, 11 Dec 2008 13:00:56 +0200 [thread overview]
Message-ID: <20081211110056.GJ5555@redhat.com> (raw)
In-Reply-To: <493FD45B.5010500@codemonkey.ws>
On Wed, Dec 10, 2008 at 08:38:19AM -0600, Anthony Liguori wrote:
> Hi Gleb,
>
> Anthony Liguori wrote:
>> Revision: 5860
>> http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5860
>> Author: aliguori
>> Date: 2008-12-02 20:11:27 +0000 (Tue, 02 Dec 2008)
>>
>
> According to https://bugzilla.novell.com/show_bug.cgi?id=457957, this
> changeset breaks compressed qcow2 on write and savevm.
>
> Can you please look into this?
>
Alexander, can you try the patch below?
diff --git a/block-qcow2.c b/block-qcow2.c
index b3b5f8f..d8ac647 100644
--- a/block-qcow2.c
+++ b/block-qcow2.c
@@ -620,6 +620,9 @@ static int count_contiguous_clusters(uint64_t nb_clusters, int cluster_size,
int i;
uint64_t offset = be64_to_cpu(l2_table[0]) & ~mask;
+ if (!offset)
+ return 0;
+
for (i = 0; i < nb_clusters; i++)
if (offset + i * cluster_size != (be64_to_cpu(l2_table[i]) & ~mask))
break;
@@ -981,6 +984,12 @@ static uint64_t alloc_cluster_offset(BlockDriverState *bs,
/* how many available clusters ? */
while (i < nb_clusters) {
+ i += count_contiguous_clusters(nb_clusters - i, s->cluster_size,
+ &l2_table[l2_index + i], 0);
+
+ if(be64_to_cpu(l2_table[l2_index + i]))
+ break;
+
i += count_contiguous_free_clusters(nb_clusters - i,
&l2_table[l2_index + i]);
@@ -989,12 +998,6 @@ static uint64_t alloc_cluster_offset(BlockDriverState *bs,
if ((cluster_offset & QCOW_OFLAG_COPIED) ||
(cluster_offset & QCOW_OFLAG_COMPRESSED))
break;
-
- i += count_contiguous_clusters(nb_clusters - i, s->cluster_size,
- &l2_table[l2_index + i], 0);
-
- if(be64_to_cpu(l2_table[l2_index + i]))
- break;
}
nb_clusters = i;
--
Gleb.
next prev parent reply other threads:[~2008-12-11 11:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-02 20:11 [Qemu-devel] [5860] Cleanup {alloc|get}_cluster_offset() (Gleb Natapov) Anthony Liguori
2008-12-10 14:38 ` Anthony Liguori
2008-12-10 14:47 ` Gleb Natapov
2008-12-11 11:00 ` Gleb Natapov [this message]
2008-12-11 13:21 ` Alexander Graf
2008-12-11 13:58 ` Gleb Natapov
2008-12-11 15:16 ` Alexander Graf
2008-12-11 15:28 ` Gleb Natapov
2008-12-11 17:32 ` Kevin Wolf
2008-12-11 17:42 ` Gleb Natapov
2008-12-17 13:06 ` Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081211110056.GJ5555@redhat.com \
--to=gleb@redhat.com \
--cc=agraf@suse.de \
--cc=anthony@codemonkey.ws \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.