Skip to content

nbd: move reconnect-thread to separate file

Vladimir Sementsov-Ogievskiy qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest14 patches 6 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/14block/nbd: BDRVNBDState: drop unused connect_errblock/nbd.c+2 -71 reply
2/14block/nbd: nbd_co_establish_connection(): drop unused errpblock/nbd.c+4 -51 reply
3/14block/nbd: drop unused NBDConnectThread::err fieldblock/nbd.c+2 -132 replies
4/14block/nbd: split connect_thread_cb() out of connect_thread_func()block/nbd.c+17 -100 replies
5/14block/nbd: rename NBDConnectThread to NBDConnectCBblock/nbd.c+10 -100 replies
6/14block/nbd: further segregation of connect-threadblock/nbd.c+39 -181 reply
7/14block/nbd: drop nbd_free_connect_thread()block/nbd.c+2 -70 replies
8/14block/nbd: move nbd connect-thread to nbd/client-connect.cblock/nbd.c include/block/nbd.h nbd/client-connect.c +1 more+79 -460 replies
9/14block/nbd: NBDConnectCB: drop bh_* fieldsblock/nbd.c+19 -200 replies
10/14block/nbd: move wait_connect field under mutex protectionblock/nbd.c+21 -210 replies
11/14block/nbd: refactor connect_bh()block/nbd.c+4 -50 replies
12/14block/nbd: refactor nbd_co_establish_connectionblock/nbd.c+8 -120 replies
13/14block/nbd: nbd_co_establish_connection_cancel(): rename wake to do_wakeblock/nbd.c+3 -30 replies
14/14block/nbd: drop thr->stateblock/nbd.c+34 -880 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 00/14] nbd: move reconnect-thread to separate file

Hi all!

There are problems with nbd driver:

- nbd reconnect is cancelled on drain, which is bad as Roman describes in his "[PATCH 0/7] block/nbd: decouple reconnect from drain"
- nbd driver is too complicated around drained sections and aio context switch. It's nearly impossible to follow all the logic, including abuse of bs->in_flight, which is temporary decreased in some places (like nbd_read_eof()). Additional reconnect thread and two different state machines (we have BDRVNBDState::state and BDRVNBDState::connect_thread->state) doesn't make things simpler :)

So, I have a plan:

1. Move nbd negotiation to connect_thread

2. Do receive NBD replies in request coroutines, not in connection_co

At this point we can drop connection_co, and when we don't have endless running coroutine, NBD driver becomes a usual block driver, and we can drop abuse of bs->in_flight, and probably drop most of complicated logic around drained section and aio context switch in nbd driver.

3. Still, as Roman describes, with [2] we loose a possibility to reconnect immediately when connection breaks (with current code we have endless read in reconnect_co, but actually for this to work keep-alive should be setup correctly). So, we'll need to reinvent it, checking connection periodically by timeout, with help of getsockopt or just sending a kind of PING request (zero-length READ or something like this).

And this series a kind of preparation. The main point of it is moving connect-thread to a separate file.

This series may crash on iotest 277. So, it's based on corresponding
fix: "[PATCH 1/7] block/nbd: avoid touching freed connect_thread":

Based-on: <[email protected]>

Vladimir Sementsov-Ogievskiy (14):
block/nbd: BDRVNBDState: drop unused connect_err block/nbd: nbd_co_establish_connection(): drop unused errp block/nbd: drop unused NBDConnectThread::err field block/nbd: split connect_thread_cb() out of connect_thread_func() block/nbd: rename NBDConnectThread to NBDConnectCB block/nbd: further segregation of connect-thread block/nbd: drop nbd_free_connect_thread()
block/nbd: move nbd connect-thread to nbd/client-connect.c block/nbd: NBDConnectCB: drop bh_* fields
block/nbd: move wait_connect field under mutex protection block/nbd: refactor connect_bh()
block/nbd: refactor nbd_co_establish_connection block/nbd: nbd_co_establish_connection_cancel(): rename wake to
do_wake
block/nbd: drop thr->state

 include/block/nbd.h  |   6 +
 block/nbd.c          | 266 ++++++++++++++-----------------------------
 nbd/client-connect.c |  72 ++++++++++++
 nbd/meson.build      |   1 +
 4 files changed, 162 insertions(+), 183 deletions(-)
 create mode 100644 nbd/client-connect.c
Signature · 1 line
2.29.2