nbd: keep send_mutex/free_sema handling outside nbd_co_do_establish_connection
commit8610b4491f02312f3bf0de10826fad7aa99ddfcf
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 14 Apr 2022 17:57:51 +0000 (14 19:57 +0200)
committerEric Blake <eblake@redhat.com>
Tue, 26 Apr 2022 18:16:36 +0000 (26 13:16 -0500)
tree77efdade695b102859eac3cdbd441183d21e1e7d
parent172f5f1a4058c361bfcd19317b0e3151556b3edb
nbd: keep send_mutex/free_sema handling outside nbd_co_do_establish_connection

Elevate s->in_flight early so that other incoming requests will wait
on the CoQueue in nbd_co_send_request; restart them after getting back
from nbd_reconnect_attempt.  This could be after the reconnect timer or
nbd_cancel_in_flight have cancelled the attempt, so there is no
need anymore to cancel the requests there.

nbd_co_send_request now handles both stopping and restarting pending
requests after a successful connection, and there is no need to
hold send_mutex in nbd_co_do_establish_connection.  The current setup
is confusing because nbd_co_do_establish_connection is called both with
send_mutex taken and without it.  Before the patch it uses free_sema which
(at least in theory...) is protected by send_mutex, after the patch it
does not anymore.

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