From: Max Reitz <mreitz@redhat.com>
To: Eric Blake <eblake@redhat.com>, qemu-devel@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>,
"Benoît Canet" <benoit.canet@nodalink.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v3 2/3] raw-posix: raw_co_get_block_status() return value
Date: Thu, 23 Oct 2014 09:29:36 +0200 [thread overview]
Message-ID: <5448AE60.5060608@redhat.com> (raw)
In-Reply-To: <5447E2BB.7070508@redhat.com>
On 2014-10-22 at 19:00, Eric Blake wrote:
> On 10/22/2014 09:57 AM, Max Reitz wrote:
>> Instead of generating the full return value thrice in try_fiemap(),
>> try_seek_hole() and as a fall-back in raw_co_get_block_status() itself,
>> generate the value only in raw_co_get_block_status().
>>
>> While at it, also remove the pnum parameter from try_fiemap() and
>> try_seek_hole().
>>
>> Suggested-by: Kevin Wolf <kwolf@redhat.com>
>> Signed-off-by: Max Reitz <mreitz@redhat.com>
>> ---
>> block/raw-posix.c | 28 ++++++++++++++--------------
>> 1 file changed, 14 insertions(+), 14 deletions(-)
> Reviewed-by: Eric Blake <eblake@redhat.com>
>
>> - ret = try_seek_hole(bs, start, &data, &hole, pnum);
>> + ret = try_seek_hole(bs, start, &data, &hole);
>> if (ret < 0) {
>> - ret = try_fiemap(bs, start, &data, &hole, nb_sectors, pnum);
>> + ret = try_fiemap(bs, start, &data, &hole, nb_sectors);
>> if (ret < 0) {
>> /* Assume everything is allocated. */
>> data = 0;
>> hole = start + nb_sectors * BDRV_SECTOR_SIZE;
>> - ret = BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | start;
>> + ret = 0;
>> }
>> }
>>
>> + assert(ret >= 0);
> I'm not sure the assertion adds much (the lines above are fairly easy to
> reason about ret always being set), but it does protect against later
> code addition, so I'm not opposed to leaving it.
I just liked it there to make clear that the previous code always goes
into a fallback, so while some parts of it may throw errors, after
everything is done, we're fine. The compiler will hopefully optimize it
out anyway.
Max
next prev parent reply other threads:[~2014-10-23 7:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-22 15:57 [Qemu-devel] [PATCH v3 0/3] raw-posix: Fix raw_co_get_block_status() Max Reitz
2014-10-22 15:57 ` [Qemu-devel] [PATCH v3 1/3] raw-posix: Fix raw_co_get_block_status() after EOF Max Reitz
2014-10-22 16:57 ` Eric Blake
2014-10-23 7:27 ` Max Reitz
2014-10-23 7:28 ` Max Reitz
2014-10-22 15:57 ` [Qemu-devel] [PATCH v3 2/3] raw-posix: raw_co_get_block_status() return value Max Reitz
2014-10-22 17:00 ` Eric Blake
2014-10-23 7:29 ` Max Reitz [this message]
2014-10-22 15:57 ` [Qemu-devel] [PATCH v3 3/3] iotests: Add test for external image truncation Max Reitz
2014-10-22 16:50 ` Eric Blake
2014-10-23 7:26 ` Max Reitz
2014-10-23 7:46 ` Kevin Wolf
2014-10-23 7:47 ` Max Reitz
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=5448AE60.5060608@redhat.com \
--to=mreitz@redhat.com \
--cc=benoit.canet@nodalink.com \
--cc=eblake@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 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.