From: Max Reitz <mreitz@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2] qcow2: Rewrite qcow2_alloc_bytes()
Date: Fri, 06 Feb 2015 09:15:34 -0500 [thread overview]
Message-ID: <54D4CC86.9020404@redhat.com> (raw)
In-Reply-To: <20150206140858.GE13081@noname.redhat.com>
On 2015-02-06 at 09:08, Kevin Wolf wrote:
> Am 05.02.2015 um 16:58 hat Max Reitz geschrieben:
>> qcow2_alloc_bytes() is a function with insufficient error handling and
>> an unnecessary goto. This patch rewrites it.
>>
>> Signed-off-by: Max Reitz <mreitz@redhat.com>
>> ---
>> v2:
>> - s/free_cluster_index/free_byte_index/ [Eric]
>> - added an assertion at the start of the function that
>> s->free_byte_offset is either 0 or points to the tail of a cluster
>> (but never to the start)
>> - use ROUND_UP() instead of start_of_cluster() + cluster_size [Eric]
>> - added an assertion that s->free_byte_offset is set before using it
>> [Eric]
>> ---
>> block/qcow2-refcount.c | 77 +++++++++++++++++++++++++++++---------------------
>> 1 file changed, 45 insertions(+), 32 deletions(-)
>>
[snip]
> The patch looks correct to me. Let me know if you'd like to address the
> point I made above, or if I should apply it as it is.
Good question. On one hand, I like your suggestion because it would
indeed make the code shorter. On the other hand, I somehow feel better
using functions that are prefixed qcow2_* because I feel like it might
make the code harder to read if sometimes we use qcow2_alloc_clusters()
and alloc_clusters_noref() at other times; and sometimes we use
qcow2_update_cluster_refcount() and update_refcount() at other times.
But then again, it might make sense to have this function mirror
qcow2_alloc_clusters(), which does use alloc_clusters_noref() and
update_refcount() (of course).
So I think I'll go with your suggestion, thanks!
Max
prev parent reply other threads:[~2015-02-06 14:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-05 15:58 [Qemu-devel] [PATCH v2] qcow2: Rewrite qcow2_alloc_bytes() Max Reitz
2015-02-05 17:53 ` Eric Blake
2015-02-06 14:08 ` Kevin Wolf
2015-02-06 14:15 ` Max Reitz [this message]
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=54D4CC86.9020404@redhat.com \
--to=mreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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).