From: Kevin Wolf <kwolf@suse.de>
To: Laurent Vivier <Laurent.Vivier@bull.net>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [patch 5/5][v2] Try to aggregate free clusters and freed clusters
Date: Mon, 11 Aug 2008 17:03:34 +0200 [thread overview]
Message-ID: <48A054C6.1010104@suse.de> (raw)
In-Reply-To: <1218463441.3871.29.camel@frecb07144>
Laurent Vivier schrieb:
> Le lundi 11 août 2008 à 15:13 +0200, Kevin Wolf a écrit :
>> Hi Laurent,
>>
>> Laurent Vivier schrieb:
>>> In free_used_clusters(), try to aggregate free clusters and freed clusters.
>>>
>>> Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net>
>>> ---
>>> block-qcow2.c | 61 ++++++++++++++++++++++++++++++++++------------------------
>>> 1 file changed, 36 insertions(+), 25 deletions(-)
>> I know that this patch will be rewritten as well, but I'll comment on it
>> nevertheless. Maybe the comments apply to your new version, too.
>>
>>
>>> Index: qemu/block-qcow2.c
>>> ===================================================================
>>> --- qemu.orig/block-qcow2.c 2008-07-29 15:22:28.000000000 +0200
>>> +++ qemu/block-qcow2.c 2008-07-29 15:22:30.000000000 +0200
>>> @@ -714,22 +703,44 @@ static uint64_t free_used_clusters(Block
>>> return 0;
>>> }
>>>
>>> - if (nb_clusters) {
>>> - int i = 1;
>>> - uint64_t current;
>>> - while (i < *nb_clusters) {
>>> - current = be64_to_cpu((*l2_table)[(*l2_index) + i]);
>>> - if (cluster_offset + (i << s->cluster_bits) != current)
>>> - break;
>>> - i++;
>>> - }
>>> - *nb_clusters = i;
>>> - free_clusters(bs, cluster_offset, i << s->cluster_bits);
>>> + if (!nb_clusters) {
>>> + if (cluster_offset)
>>> + free_clusters(bs, cluster_offset, s->cluster_size);
>>> return 0;
>>> }
>>>
>>> - free_clusters(bs, cluster_offset, s->cluster_size);
>>> + i = 0;
>>> + do_loop = 1;
>>> + while (i < *nb_clusters && do_loop) {
>>> + i++;
>>> + if (!cluster_offset) {
>>> + while (i < *nb_clusters) {
>>> + cluster_offset = (*l2_table)[(*l2_index) + i];
>>> + if (cluster_offset)
>>> + break;
>>> + i++;
>>> + }
>>> + if ((cluster_offset & QCOW_OFLAG_COPIED) ||
>>> + (cluster_offset & QCOW_OFLAG_COMPRESSED))
>>> + do_loop = 0;
>>> + } else {
>>> + j = 1;
>>> + current = 0;
>>> + while (i < *nb_clusters) {
>>> + current = be64_to_cpu((*l2_table)[(*l2_index) + i]);
>>> + if (cluster_offset + (j << s->cluster_bits) != current)
>>> + break;
>>> + i++;
>>> + j++;
>>> + }
>>> + free_clusters(bs, cluster_offset, j << s->cluster_bits);
>>> + cluster_offset = current;
>>> + if (current)
>>> + do_loop = 0;
>> The else block changes its behaviour with this patch: I think you should
>> take QCOW_OFLAG_COPIED into consideration. In this implementation, when
>> a cluster with QCOW_OFLAG_COPIED is found, the inner loop aborts, but
>> the outer one will just call the else block once again. So you're also
>> accumulating clusters with QCOW_OFLAG_COPIED set.
>
> No,
> before the first loop QCOW_OFLAG_COPIED is not set.
> if cluster_offset is 0 and flag appears, we set do_loop to 0 and exit
> from the main loop.
> if cluster_offset is != 0 we go into the else until current becomes 0 or
> a flag is set and then if current is not 0 (i.e. a flag or a non
> contiguous cluster) we set do_loop to 0 and exit from the loop.
You're right. I really should learn reading. Sorry for the noise.
Kevin
next prev parent reply other threads:[~2008-08-11 15:04 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-29 14:13 [Qemu-devel] [patch 0/5][v2] qcow2: improve I/O performance with cache=off Laurent Vivier
2008-07-29 14:13 ` [Qemu-devel] [patch 1/5][v2] Extract code from get_cluster_offset() Laurent Vivier
2008-08-05 14:15 ` Kevin Wolf
2008-08-05 14:28 ` Laurent Vivier
2008-08-05 14:34 ` Kevin Wolf
2008-08-05 14:45 ` Laurent Vivier
2008-07-29 14:13 ` [Qemu-devel] [patch 2/5][v2] Divide get_cluster_offset() Laurent Vivier
2008-08-05 15:13 ` Kevin Wolf
2008-08-05 15:25 ` Laurent Vivier
2008-08-05 15:41 ` Kevin Wolf
2008-07-29 14:13 ` [Qemu-devel] [patch 3/5][v2] Extract compressing part from alloc_cluster_offset() Laurent Vivier
2008-08-06 14:20 ` Kevin Wolf
2008-08-06 14:41 ` Laurent Vivier
2008-08-06 14:56 ` Kevin Wolf
2008-08-06 15:03 ` Laurent Vivier
2008-07-29 14:13 ` [Qemu-devel] [patch 4/5][v2] Aggregate same type clusters Laurent Vivier
2008-08-11 12:10 ` Kevin Wolf
2008-08-11 12:39 ` Laurent Vivier
2008-07-29 14:13 ` [Qemu-devel] [patch 5/5][v2] Try to aggregate free clusters and freed clusters Laurent Vivier
2008-08-11 13:13 ` Kevin Wolf
2008-08-11 14:04 ` Laurent Vivier
2008-08-11 14:42 ` Laurent Vivier
2008-08-11 15:03 ` Kevin Wolf [this message]
2008-07-29 19:15 ` [Qemu-devel] [patch 0/5][v2] qcow2: improve I/O performance with cache=off Anthony Liguori
2008-07-29 21:35 ` Laurent Vivier
2008-07-29 21:49 ` Anthony Liguori
2008-07-29 21:59 ` Laurent Vivier
2008-08-01 14:54 ` Anthony Liguori
2008-08-01 15:05 ` Laurent Vivier
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=48A054C6.1010104@suse.de \
--to=kwolf@suse.de \
--cc=Laurent.Vivier@bull.net \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).