From: Laurent Vivier <Laurent.Vivier@bull.net>
To: Kevin Wolf <kwolf@suse.de>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/4] qcow2: Allow update_cluster_refcount() to update several clusters refcount.
Date: Fri, 07 Nov 2008 12:39:26 +0100 [thread overview]
Message-ID: <1226057966.4046.40.camel@frecb07144> (raw)
In-Reply-To: <491416BF.8070007@suse.de>
Le vendredi 07 novembre 2008 à 11:21 +0100, Kevin Wolf a écrit :
> Laurent Vivier schrieb:
[...]
> >>>
> >>> @@ -2437,7 +2469,7 @@ static void update_refcount(BlockDriverS
> >>> int addend)
> >>> {
> >>> BDRVQcowState *s = bs->opaque;
> >>> - int64_t start, last, cluster_offset;
> >>> + int64_t start, last;
> >>>
> >>> #ifdef DEBUG_ALLOC2
> >>> printf("update_refcount: offset=%lld size=%lld addend=%d\n",
> >>> @@ -2445,12 +2477,9 @@ static void update_refcount(BlockDriverS
> >>> #endif
> >>> if (length <= 0)
> >>> return;
> >>> - start = offset & ~(s->cluster_size - 1);
> >>> - last = (offset + length - 1) & ~(s->cluster_size - 1);
> >>> - for(cluster_offset = start; cluster_offset <= last;
> >>> - cluster_offset += s->cluster_size) {
> >>> - update_cluster_refcount(bs, cluster_offset >> s->cluster_bits, addend);
> >>> - }
> >>> + start = offset >> s->cluster_bits;
> >>> + last = (offset + length) >> s->cluster_bits;
> >> Off by one for length % cluster_size == 0?
> >
> > Explain, please (but notice the "<=" in the "for (...)").
>
> I didn't even look at the old code yesterday, but the difference is that
> you dropped the - 1 for last.
>
> Let's do it by example: Assume cluster_size = 0x1000 for simplicity and
> we get offset = 0x1000 and length = 0x2000 (i.e. the last affected byte
> would be 0x2fff). The old code correctly produces start = 0x1000 and
> last = 0x2000 whereas you get start = 1 and last = 3.
Yes, "last" must be "(offset + length - 1) >> s->cluster_bits"
Thank you,
Laurent
--
------------------ Laurent.Vivier@bull.net ------------------
"Tout ce qui est impossible reste à accomplir" Jules Verne
"Things are only impossible until they're not" Jean-Luc Picard
next prev parent reply other threads:[~2008-11-07 11:39 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20081106165212.380421945@bull.net>
2008-11-06 16:55 ` [Qemu-devel] [PATCH 1/4] qcow2: Clean-up update_cluster_refcount() Laurent Vivier
2008-11-06 17:32 ` Kevin Wolf
2008-11-07 8:48 ` Laurent Vivier
2008-11-07 8:54 ` Kevin Wolf
2008-11-07 9:22 ` Laurent Vivier
2008-11-06 16:55 ` [Qemu-devel] [PATCH 2/4] qcow2: Allow update_cluster_refcount() to update several clusters refcount Laurent Vivier
2008-11-06 18:11 ` Kevin Wolf
2008-11-07 10:03 ` Laurent Vivier
2008-11-07 10:21 ` Kevin Wolf
2008-11-07 11:39 ` Laurent Vivier [this message]
2008-11-06 16:55 ` [Qemu-devel] [PATCH 3/4] qcow2: Align I/O access to l2 table and refcount block Laurent Vivier
2008-11-06 16:56 ` [Qemu-devel] [PATCH 4/4] qcow2: detect if no disk cache 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=1226057966.4046.40.camel@frecb07144 \
--to=laurent.vivier@bull.net \
--cc=kwolf@suse.de \
--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.