The reconnection logic doesn't need to stop while in a drained section. Moreover it has to be active during the drained section, as the requests that were caught in-flight with the connection to the server broken can only usefully get drained if the connection is restored. Otherwise such requests can only either stall resulting in a deadlock (before 8c517de24a), or be aborted defeating the purpose of the reconnection machinery (after 8c517de24a).
This series aims to just stop messing with the drained section in the reconnection code. While doing so it undoes the effect of 5ad81b4946 ("nbd: Restrict connection_co reentrance"); as I've missed the point of that commit I'd appreciate more scrutiny in this area. Roman Kagan (7): block/nbd: avoid touching freed connect_thread block/nbd: use uniformly nbd_client_connecting_wait block/nbd: assert attach/detach runs in the proper context block/nbd: transfer reconnection stuff across aio_context switch block/nbd: better document a case in nbd_co_establish_connection block/nbd: decouple reconnect from drain block/nbd: stop manipulating in_flight counter block/nbd.c | 191 +++++++++++++++++++++++---------------------------- nbd/client.c | 2 - 2 files changed, 86 insertions(+), 107 deletions(-) -- 2.30.2