From: Eric Blake <eblake@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, pbonzini@redhat.com, kwolf@redhat.com,
Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 5/7] nbd-client: Short-circuit 0-length operations
Date: Thu, 9 Nov 2017 08:44:15 -0600 [thread overview]
Message-ID: <357c1ac7-8ec1-dd39-dbe3-027415b93e28@redhat.com> (raw)
In-Reply-To: <0f12d1c5-64a8-7e45-b927-bf7ce52ac5b6@virtuozzo.com>
[-- Attachment #1: Type: text/plain, Size: 1592 bytes --]
On 11/09/2017 03:20 AM, Vladimir Sementsov-Ogievskiy wrote:
> 09.11.2017 00:57, Eric Blake wrote:
>> The NBD spec was recently clarified to state that clients should
>> not send 0-length requests to the server, as the server behavior
>> is undefined [1]. We know that qemu-nbd's behavior is a successful
>> no-op (once it has filtered for read-only exports), but other NBD
>> implementations might return an error. To avoid any questionable
>> server implementations, it is better to just short-circuit such
>> requests on the client side (we are relying on the block layer to
>> already filter out requests such as invalid offset, write to a
>> read-only volume, and so forth).
>>
>> [1] https://github.com/NetworkBlockDevice/nbd/commit/ee926037
>>
>> Signed-off-by: Eric Blake <eblake@redhat.com>
>
> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>
>> @@ -705,6 +708,9 @@ int nbd_client_co_pwritev(BlockDriverState *bs,
>> uint64_t offset,
>>
>> assert(bytes <= NBD_MAX_BUFFER_SIZE);
>>
>> + if (!bytes) {
>> + return 0;
>> + }
>
> we don't do this check before flags manipulation to do not miss possible
> asserts...
>
>> return nbd_co_request(bs, &request, qiov);
Correct - I put the short-circuit as late as possible to ensure that
preconditions are still being met. I can tweak the commit message to
make that more obvious, if desired.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]
next prev parent reply other threads:[~2017-11-09 14:44 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-08 21:56 [Qemu-devel] [PATCH v2 0/7] various NBD fixes for 2.11 Eric Blake
2017-11-08 21:56 ` [Qemu-devel] [PATCH v2 1/7] nbd-client: Fix error message typos Eric Blake
2017-11-09 8:58 ` Vladimir Sementsov-Ogievskiy
2017-11-09 14:43 ` Eric Blake
2017-11-08 21:56 ` [Qemu-devel] [PATCH v2 2/7] nbd-client: Refuse read-only client with BDRV_O_RDWR Eric Blake
2017-11-08 22:07 ` Eric Blake
2017-11-08 22:23 ` [Qemu-devel] [PATCH v2 2.5/7] fixup! " Eric Blake
2017-11-09 9:05 ` Vladimir Sementsov-Ogievskiy
2017-11-09 9:04 ` [Qemu-devel] [PATCH v2 2/7] " Vladimir Sementsov-Ogievskiy
2017-11-08 21:56 ` [Qemu-devel] [PATCH v2 3/7] nbd/client: Nicer trace of structured reply Eric Blake
2017-11-09 9:10 ` Vladimir Sementsov-Ogievskiy
2017-11-08 21:57 ` [Qemu-devel] [PATCH v2 4/7] nbd: Fix struct name for structured reads Eric Blake
2017-11-09 9:13 ` Vladimir Sementsov-Ogievskiy
2017-11-08 21:57 ` [Qemu-devel] [PATCH v2 5/7] nbd-client: Short-circuit 0-length operations Eric Blake
2017-11-09 9:20 ` Vladimir Sementsov-Ogievskiy
2017-11-09 14:44 ` Eric Blake [this message]
2017-11-08 21:57 ` [Qemu-devel] [PATCH v2 6/7] nbd-client: Stricter enforcing of structured reply spec Eric Blake
2017-11-09 9:37 ` Vladimir Sementsov-Ogievskiy
2017-11-09 14:45 ` Eric Blake
2017-11-08 21:57 ` [Qemu-devel] [PATCH v2 7/7] nbd/server: Fix structured read of length 0 Eric Blake
2017-11-09 9:43 ` Vladimir Sementsov-Ogievskiy
2017-11-08 22:24 ` [Qemu-devel] [PATCH v2 0/7] various NBD fixes for 2.11 no-reply
2017-11-08 23:05 ` Eric Blake
2017-11-09 5:34 ` Fam Zheng
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=357c1ac7-8ec1-dd39-dbe3-027415b93e28@redhat.com \
--to=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--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).