From: Eric Blake <eblake@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
qemu-devel@nongnu.org, qemu-block@nongnu.org
Cc: pbonzini@redhat.com, den@openvz.org
Subject: Re: [Qemu-devel] [PATCH 2/2] nbd/server: send more than one extent of base:allocation context
Date: Fri, 20 Jul 2018 15:42:05 -0500 [thread overview]
Message-ID: <9f971ed8-e43c-28a5-e44e-6f7f3720afed@redhat.com> (raw)
In-Reply-To: <894031cf-d826-1d20-21de-a8f7af4be5fc@virtuozzo.com>
On 07/10/2018 09:33 AM, Vladimir Sementsov-Ogievskiy wrote:
> 04.07.2018 14:23, Vladimir Sementsov-Ogievskiy wrote:
>> This is necessary for efficient block-status export, for clients which
>> support it.
>>
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>> ---
>> +static int blockstatus_to_extents(BlockDriverState *bs, uint64_t offset,
>> + uint64_t *bytes, NBDExtent *extents,
>> + unsigned int *nb_extents)
>> {
>> - uint64_t remaining_bytes = bytes;
>> + uint64_t remaining_bytes = *bytes;
>> + NBDExtent *extent = extents, *extents_end = extents + *nb_extents;
>> + bool first_extent = true;
>> + assert(*nb_extents);
>> while (remaining_bytes) {
>> uint32_t flags;
>> int64_t num;
>> @@ -1860,21 +1871,40 @@ static int
>> blockstatus_to_extent_be(BlockDriverState *bs, uint64_t offset,
>
> after bdrv_block_status_above, is there a guarantee that num > 0? Should
> we add an assertion?
bdrv_block_status_above() asserts that drivers set *pnum to non-zero on
success (that is, a driver's .bdrv_co_block_status must make progress or
fail); however, a caller can still get *pnum == 0 on the corner case of
requesting status at or beyond the end-of-file boundary (where
bdrv_block_status_above() does not call into a driver's
.bdrv_co_block_status callback). Since the NBD code already validated
that the client's code does not exceed EOF, and the block layer
guaranteed that an in-range request made progress on success, you should
be fine with an assertion that num > 0.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
prev parent reply other threads:[~2018-07-20 20:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-04 11:23 [Qemu-devel] [PATCH 0/2] nbd base:allocation several extents Vladimir Sementsov-Ogievskiy
2018-07-04 11:23 ` [Qemu-devel] [PATCH 1/2] nbd/server: fix nbd_co_send_block_status Vladimir Sementsov-Ogievskiy
2018-07-05 15:42 ` Eric Blake
2018-07-04 11:23 ` [Qemu-devel] [PATCH 2/2] nbd/server: send more than one extent of base:allocation context Vladimir Sementsov-Ogievskiy
2018-07-05 15:59 ` Eric Blake
2018-07-05 16:18 ` Vladimir Sementsov-Ogievskiy
2018-07-10 14:33 ` Vladimir Sementsov-Ogievskiy
2018-07-20 20:42 ` Eric Blake [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=9f971ed8-e43c-28a5-e44e-6f7f3720afed@redhat.com \
--to=eblake@redhat.com \
--cc=den@openvz.org \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.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).