From: Kevin Wolf <kwolf@suse.de>
To: Laurent Vivier <Laurent.Vivier@bull.net>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [patch 3/5][v2] Extract compressing part from alloc_cluster_offset()
Date: Wed, 06 Aug 2008 16:56:15 +0200 [thread overview]
Message-ID: <4899BB8F.80602@suse.de> (raw)
In-Reply-To: <1218033682.3964.19.camel@frecb07144>
Laurent Vivier schrieb:
> Le mercredi 06 août 2008 à 16:20 +0200, Kevin Wolf a écrit :
>> Laurent Vivier schrieb:
>>> Divide alloc_cluster_offset() into alloc_cluster_offset() and
>>> alloc_compressed_cluster_offset(). Factorize code to free clusters into
>>> free_used_clusters().
>>>
>>> Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net>
>> I think free_used_clusters() is misnamed. That it frees clusters is more
>> of an additional action it performs. What it really is doing is to load
>> the appropriate L2 table into memory (and to allocate it if needed).
>
> It frees the cluster if it is found except if it has the flag
> QCOW_OFLAG_COPIED. To do that it needs to load the L2 table.
>
> But I'm open to a new name, I don't like this one too.
Well, yes and no. Of course, it needs to have the L2 table to free the
cluster. But it does not only load that table for local usage but
returns it to the caller using the parameters passed by reference. So
this loading doesn't only happen internally but it belongs to the interface.
Actually, I'm also having a hard time finding a fitting name for the
function. Maybe that's an indication that the function is doing two
things which don't really belong together. I'm not sure if it makes
sense, but you could do the L2 table loading in another function which
is called before free_used_clusters() and pass the already loaded table
into free_used_clusters().
>> Also, the current function name doesn't provide a hint how the return
>> value is to be interpreted. If I'm not mistaken, 0 could mean that
>> everything went fine and the cluster has been freed, or it could mean
>> that an error occurred.
>
> Yes, but this is the original behavior and I don't want to modify it.
>
>> Maybe you meant to return cluster_offset instead of 0 at the end of the
>
> No, at the end of function the cluster has been freed and the offset is
> not valid anymore.
Yes, you have a point there...
>> function (that you check for QCOW_OFLAG_COPIED which is _always_ set if
>> the function returns != 0 suggests this), but I can't tell for sure
>> because there is no documentation on the return value.
>
> You're right. But to return the offset with the flag allows to
> differentiate the case returning 0 from an offset equal to 0.
> If offset is 0, it returns (0 | QCOW_OFLAG_COPIED), but I agree to say
> that offset cannot be 0, but again I keep the original behavior.
I fully agree if you want to keep the original behaviour in the external
interface. However, free_used_clusters() is only used in your own
functions, so you could actually make that change without a too big risk.
But the most important part is really the documentation. You see how I
misunderstood what you were trying to achieve. This could be easily avoided.
Kevin
next prev parent reply other threads:[~2008-08-06 14:57 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 [this message]
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
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=4899BB8F.80602@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).