qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
	qemu-block@nongnu.org, qemu-devel@nongnu.org
Cc: mreitz@redhat.com, kwolf@redhat.com, eblake@redhat.com, den@openvz.org
Subject: Re: [Qemu-devel] [PATCH v2 3/7] block/nbd-client: refactor reading reply
Date: Tue, 19 Sep 2017 14:50:30 +0200	[thread overview]
Message-ID: <11ccb9c4-aecb-e82f-a520-50710dae8ea1@redhat.com> (raw)
In-Reply-To: <5fff43cf-717d-2d64-f51d-57f116888921@virtuozzo.com>

On 19/09/2017 13:03, Vladimir Sementsov-Ogievskiy wrote:
>>>
>> I disagree that it is easier to extend it in the future.  If some
>> commands in the future need a different "how do we read it" (e.g. for
>> structured reply), nbd_read_reply_entry may not have all the information
>> it needs anymore.
> 
> how is it possible? all information is in requests[i].

If you are okay with violating information hiding, then it is.

>>
>> In fact, you're pushing knowledge of the commands from nbd_co_request to
>> nbd_read_reply_entry:
>>
>> +        if (s->reply.error == 0 &&
>> +            s->requests[i].request->type == NBD_CMD_READ)
>>
>> and knowledge of NBD_CMD_READ simply doesn't belong there.  So there is
>> an example of that right now, it is not some arbitrary bad thing that
>> could happen in the future.
> 
> I can't agree that my point of view is wrong, it's just different.
> You want commands, reading from socket, each knows what it should read.
> I want the receiver - one sequential reader, that can read all kinds of
> replies and just wake requesting coroutines when all reading is done.
> For me it looks simpler than switching.

It may look simpler, but I think it goes against the principle of
coroutines which is to have related code in the same function.  Here you
have the command function that takes care of sending the request payload
but not receiving the reply payload (except that for commands that
aren't as simple as read or write, it will have to _process_ the reply
payload).  What to do with the reply payload is in another function that
has to peek at the command in order to find out what to do.  It doesn't
seem like a better design, honestly.

Paolo

  reply	other threads:[~2017-09-19 12:50 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-18 13:59 [Qemu-devel] [PATCH v2 0/7] nbd client refactoring and fixing Vladimir Sementsov-Ogievskiy
2017-09-18 13:59 ` [Qemu-devel] [PATCH v2 1/7] block/nbd-client: refactor nbd_co_receive_reply Vladimir Sementsov-Ogievskiy
2017-09-18 15:38   ` Eric Blake
2017-09-18 13:59 ` [Qemu-devel] [PATCH v2 2/7] block/nbd-client: exit reply-reading coroutine on incorrect handle Vladimir Sementsov-Ogievskiy
2017-09-18 15:45   ` Eric Blake
2017-09-18 19:50   ` Eric Blake
2017-09-18 13:59 ` [Qemu-devel] [PATCH v2 3/7] block/nbd-client: refactor reading reply Vladimir Sementsov-Ogievskiy
2017-09-18 15:43   ` Paolo Bonzini
2017-09-18 15:54     ` Eric Blake
2017-09-19  9:25     ` Vladimir Sementsov-Ogievskiy
2017-09-19 10:01       ` Paolo Bonzini
2017-09-19 11:03         ` Vladimir Sementsov-Ogievskiy
2017-09-19 12:50           ` Paolo Bonzini [this message]
2017-09-18 13:59 ` [Qemu-devel] [PATCH v2 4/7] block/nbd-client: drop reply field from NBDClientSession Vladimir Sementsov-Ogievskiy
2017-09-18 22:00   ` Eric Blake
2017-09-18 13:59 ` [Qemu-devel] [PATCH v2 5/7] block/nbd-client: nbd_co_send_request: return -EIO if s->quit was set in parallel Vladimir Sementsov-Ogievskiy
2017-09-18 16:01   ` Eric Blake
2017-09-18 19:16     ` Eric Blake
2017-09-20 12:03     ` Vladimir Sementsov-Ogievskiy
2017-09-18 13:59 ` [Qemu-devel] [PATCH v2 6/7] block/nbd-client: early fail nbd_read_reply_entry if s->quit is set Vladimir Sementsov-Ogievskiy
2017-09-18 22:27   ` Eric Blake
2017-09-19  9:43     ` Vladimir Sementsov-Ogievskiy
2017-09-19 10:03       ` Paolo Bonzini
2017-09-19 11:07         ` Vladimir Sementsov-Ogievskiy
2017-09-18 13:59 ` [Qemu-devel] [PATCH v2 7/7] block/nbd-client: do not yield from nbd_read_reply_entry Vladimir Sementsov-Ogievskiy
2017-09-18 22:36   ` Eric Blake
2017-09-19 10:00     ` Vladimir Sementsov-Ogievskiy
2017-09-19 13:45       ` Eric Blake
  -- strict thread matches above, loose matches on Subject: below --
2017-10-09 17:27 [Qemu-devel] [PATCH v2 00/10] nbd minimal structured read Vladimir Sementsov-Ogievskiy
2017-10-09 17:27 ` [Qemu-devel] [PATCH v2 3/7] block/nbd-client: refactor reading reply Vladimir Sementsov-Ogievskiy

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=11ccb9c4-aecb-e82f-a520-50710dae8ea1@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=den@openvz.org \
    --cc=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@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).