[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH for-7.1 3/8] nbd: remove peppering of nbd_client_connected
From: |
Eric Blake |
Subject: |
Re: [PATCH for-7.1 3/8] nbd: remove peppering of nbd_client_connected |
Date: |
Wed, 13 Apr 2022 07:48:02 -0500 |
User-agent: |
NeoMutt/20211029-6-a115bf |
On Tue, Apr 12, 2022 at 09:41:59PM +0200, Paolo Bonzini wrote:
> It is unnecessary to check nbd_client_connected() because every time
> s->state is moved out of NBD_CLIENT_CONNECTED the socket is shut down
> and all coroutines are resumed.
>
> The only case where it was actually needed is when the NBD
> server disconnects and there is no reconnect-delay. In that
> case, nbd_receive_replies() does not set s->reply.handle and
> nbd_co_do_receive_one_chunk() cannot continue. For that one case,
> check the return value of nbd_receive_replies().
>
> As to the others:
>
> * nbd_receive_replies() can put the current coroutine to sleep if another
> reply is ongoing; then it will be woken by nbd_channel_error() called
> by the ongoing reply. Or it can try itself to read a reply header and
> fail, thus calling nbd_channel_error() itself.
>
> * nbd_co_send_request() will write the body of the request and fail
>
> * nbd_reply_chunk_iter_receive() will call nbd_co_receive_one_chunk()
> and then nbd_co_do_receive_one_chunk(), which will handle the failure as
> above; or it will just detect a previous call to nbd_iter_channel_error()
> via iter->ret < 0.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> block/nbd.c | 17 ++++-------------
> 1 file changed, 4 insertions(+), 13 deletions(-)
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[PATCH for-7.1 6/8] nbd: move s->state under requests_lock, Paolo Bonzini, 2022/04/12
[PATCH for-7.1 7/8] nbd: take receive_mutex when reading requests[].receiving, Paolo Bonzini, 2022/04/12
[PATCH for-7.1 8/8] nbd: document what is protected by the CoMutexes, Paolo Bonzini, 2022/04/12