I'm a bit unsure here, actually. So you lock a mutex, send a request,
wait for a response, then unlock the mutex. Surely this code doesn't
allow more than one request to be in flight at a time?
No, it doesn't. It shouldn't be hard to do it though. You could have
two mutexes, one for sending and one for receiving. You yield after
sending, and let nbd_coroutine_restart read the reply. It can then
reenter that reply's coroutine based on the handle in the reply. I
still prefer to do it in a separate patch.