]> git.proxmox.com Git - mirror_qemu.git/commit
nbd: remove peppering of nbd_client_connected
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 14 Apr 2022 17:57:50 +0000 (19:57 +0200)
committerEric Blake <eblake@redhat.com>
Tue, 26 Apr 2022 18:16:36 +0000 (13:16 -0500)
commit172f5f1a4058c361bfcd19317b0e3151556b3edb
tree75b8b2e04cef5dfe4954ff5a51c32e0e71c5097f
parent0c43c6fc896ff0894627b9464c3db94a33c8c7ac
nbd: remove peppering of nbd_client_connected

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.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20220414175756.671165-4-pbonzini@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@openvz.org>
Reviewed-by: Lukas Straub <lukasstraub2@web.de>
Signed-off-by: Eric Blake <eblake@redhat.com>
block/nbd.c