qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	pbonzini@redhat.com, vsementsov@virtuozzo.com,
	qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>,
	nbd list <nbd@other.debian.org>
Subject: Re: [Qemu-devel] [PATCH v5 11/11] nbd: Minimal structured read for client
Date: Mon, 23 Oct 2017 06:57:21 -0500	[thread overview]
Message-ID: <1ffafe3a-ecd0-74b0-ac76-3a93dee3fb6a@redhat.com> (raw)
In-Reply-To: <20171019222637.17890-12-eblake@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2614 bytes --]

On 10/19/2017 05:26 PM, Eric Blake wrote:
> From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> 
> Minimal implementation: for structured error only error_report error
> message.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> Signed-off-by: Eric Blake <eblake@redhat.com>
> 

> +static int nbd_parse_offset_hole_payload(NBDStructuredReplyChunk *chunk,
> +                                         uint8_t *payload, QEMUIOVector *qiov,
> +                                         Error **errp)
> +{
> +    uint64_t offset;
> +    uint32_t hole_size;
> +
> +    if (chunk->length != sizeof(offset) + sizeof(hole_size)) {
> +        error_setg(errp, "Protocol error: invalid payload for "
> +                         "NBD_REPLY_TYPE_OFFSET_HOLE");
> +        return -EINVAL;
> +    }
> +
> +    offset = payload_advance64(&payload);
> +    hole_size = payload_advance32(&payload);
> +
> +    if (offset > qiov->size - hole_size) {
> +        error_setg(errp, "Protocol error: server sent chunk exceeding requested"
> +                         " region");
> +        return -EINVAL;
> +    }
> +
> +    qemu_iovec_memset(qiov, offset, 0, hole_size);

Ouch. We have a discrepancy here, that needs clarification in the NBD
spec (cc'd).  In your server implementation, you are returning the
offset as sent by the client (that is, all offsets are absolute to the
size of the export).  But in this client implementation, you are
computing where to decode the zeroes by treating offset as though it
were relative to the request, rather than absolute to the export.

Or, in numbers, if I request a read of 2k starting at an offset of 4k,
the server implementation returns an offset of 4k, and the client
rejects the message because 4k is larger than the 2k request.

I think that absolute numbers are better to work with than
request-relative, but don't see anything in the proposed spec that
states one way or the other, so this is your chance to agree with my
preference or else argue why request-relative offsets are nicer, before
wordsmithing a change to the spec to make it obvious which semantics are
intended.  Then I can change either the server to match (if we want
request-relative) or the client to remember the original offset it sent
in order to turn absolute answers from the server back into
request-relative offsets for where to place the zeroes (if we go with
absolute offsets).

-- 
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 --]

  parent reply	other threads:[~2017-10-23 11:57 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-19 22:26 [Qemu-devel] [PATCH v5 00/11] nbd minimal structured read Eric Blake
2017-10-19 22:26 ` [Qemu-devel] [PATCH v5 01/11] nbd: Include error names in trace messages Eric Blake
2017-10-19 22:26 ` [Qemu-devel] [PATCH v5 02/11] nbd: Move nbd_errno_to_system_errno() to public header Eric Blake
2017-10-19 22:26 ` [Qemu-devel] [PATCH v5 03/11] nbd: Expose constants and structs for structured read Eric Blake
2017-10-20  8:00   ` Vladimir Sementsov-Ogievskiy
2017-10-19 22:26 ` [Qemu-devel] [PATCH v5 04/11] nbd/server: Report error for write to read-only export Eric Blake
2017-10-20  8:06   ` Vladimir Sementsov-Ogievskiy
2017-10-19 22:26 ` [Qemu-devel] [PATCH v5 05/11] nbd/server: Refactor zero-length option check Eric Blake
2017-10-20  8:34   ` Vladimir Sementsov-Ogievskiy
2017-10-20 15:07     ` Eric Blake
2017-10-20 18:12       ` Vladimir Sementsov-Ogievskiy
2017-10-19 22:26 ` [Qemu-devel] [PATCH v5 06/11] nbd: Minimal structured read for server Eric Blake
2017-10-20 19:03   ` Vladimir Sementsov-Ogievskiy
2017-10-20 19:11     ` Eric Blake
2017-10-20 19:30       ` Vladimir Sementsov-Ogievskiy
2017-10-21 16:02         ` Eric Blake
2017-10-19 22:26 ` [Qemu-devel] [PATCH v5 07/11] nbd/server: Include human-readable message in structured errors Eric Blake
2017-10-20 19:08   ` Vladimir Sementsov-Ogievskiy
2017-10-19 22:26 ` [Qemu-devel] [PATCH v5 08/11] nbd/client: refactor nbd_receive_starttls Eric Blake
2017-10-20 19:26   ` Vladimir Sementsov-Ogievskiy
2017-10-20 19:33     ` Eric Blake
2017-10-19 22:26 ` [Qemu-devel] [PATCH v5 09/11] nbd/client: prepare nbd_receive_reply for structured reply Eric Blake
2017-10-19 22:26 ` [Qemu-devel] [PATCH v5 10/11] nbd: Move nbd_read() to common header Eric Blake
2017-10-19 22:26 ` [Qemu-devel] [PATCH v5 11/11] nbd: Minimal structured read for client Eric Blake
2017-10-20 19:58   ` Vladimir Sementsov-Ogievskiy
2017-10-20 20:46     ` Eric Blake
2017-10-23 11:57   ` Eric Blake [this message]
2017-10-23 12:24     ` Vladimir Sementsov-Ogievskiy
2017-10-24  7:31   ` Eric Blake
2017-10-19 23:07 ` [Qemu-devel] [PATCH v5 00/11] nbd minimal structured read no-reply
2017-10-20 15:09   ` Eric Blake

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=1ffafe3a-ecd0-74b0-ac76-3a93dee3fb6a@redhat.com \
    --to=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=nbd@other.debian.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).