Skip to contentSkip to conversation

nbd: actually make s->state thread-safe

PATCH In review Paolo Bonzini 2 participants 3 messages Apr 12, 2022 – Apr 13, 2022

lore
Share & tools
lore
#0 lore raw

cover nbd: actually make s->state thread-safe

The main point of this series is patch 6, which removes the dubious and probably wrong use of atomics in block/nbd.c. This in turn is enabled mostly by the cleanups in patches 3-5. Together, they introduce a QemuMutex that synchronizes the NBD client coroutines, the reconnect_delay timer and nbd_cancel_in_flight() as well.

The fixes happen to remove an incorrect use of qemu_co_queue_restart_all and qemu_co_enter_next on the s->free_sema CoQueue, which was not guarded by s->send_mutex.

The rest is bugfixes, simplifying the code a bit, and extra documentation.

Paolo Bonzini (8):
nbd: actually implement reply_possible safeguard
nbd: mark more coroutine_fns
nbd: remove peppering of nbd_client_connected
nbd: keep send_mutex/free_sema handling outside
nbd_co_do_establish_connection
nbd: use a QemuMutex to synchronize reconnection with coroutines
nbd: move s->state under requests_lock
nbd: take receive_mutex when reading requests[].receiving
nbd: document what is protected by the CoMutexes

 block/coroutines.h |   4 +-
 block/nbd.c        | 303 +++++++++++++++++++++++----------------------
 2 files changed, 157 insertions(+), 150 deletions(-)
Signature · 1 line
2.35.1
#1 lore raw
Quoted 23 lines · Paolo Bonzini

The main point of this series is patch 6, which removes the dubious and probably wrong use of atomics in block/nbd.c. This in turn is enabled mostly by the cleanups in patches 3-5. Together, they introduce a QemuMutex that synchronizes the NBD client coroutines, the reconnect_delay timer and nbd_cancel_in_flight() as well.

The fixes happen to remove an incorrect use of qemu_co_queue_restart_all and qemu_co_enter_next on the s->free_sema CoQueue, which was not guarded by s->send_mutex.

The rest is bugfixes, simplifying the code a bit, and extra documentation.

Paolo Bonzini (8):
nbd: actually implement reply_possible safeguard
nbd: mark more coroutine_fns
nbd: remove peppering of nbd_client_connected
nbd: keep send_mutex/free_sema handling outside
nbd_co_do_establish_connection
nbd: use a QemuMutex to synchronize reconnection with coroutines
nbd: move s->state under requests_lock
nbd: take receive_mutex when reading requests[].receiving
nbd: document what is protected by the CoMutexes

Quoted 4 lines
  block/coroutines.h |   4 +-
  block/nbd.c        | 303 +++++++++++++++++++++++----------------------
  2 files changed, 157 insertions(+), 150 deletions(-)

Hmm, no patches come to me except for cover-letter. Neither here: https://patchew.org/QEMU/[email protected]/

Signature · 2 lines
Best regards,
Vladimir
#2 lore raw
Quoted 23 lines · Vladimir Sementsov-Ogievskiy
Quoted 22 lines · Paolo Bonzini

The main point of this series is patch 6, which removes the dubious and
probably wrong use of atomics in block/nbd.c.  This in turn is enabled
mostly by the cleanups in patches 3-5.  Together, they introduce a
QemuMutex that synchronizes the NBD client coroutines, the reconnect_delay timer and nbd_cancel_in_flight() as well.

The fixes happen to remove an incorrect use of qemu_co_queue_restart_all and qemu_co_enter_next on the s->free_sema CoQueue, which was not guarded by s->send_mutex.

The rest is bugfixes, simplifying the code a bit, and extra documentation.

Paolo Bonzini (8):
   nbd: actually implement reply_possible safeguard
   nbd: mark more coroutine_fns
   nbd: remove peppering of nbd_client_connected
   nbd: keep send_mutex/free_sema handling outside nbd_co_do_establish_connection
   nbd: use a QemuMutex to synchronize reconnection with coroutines
   nbd: move s->state under requests_lock
   nbd: take receive_mutex when reading requests[].receiving
   nbd: document what is protected by the CoMutexes

Quoted 6 lines
Quoted 4 lines

  block/coroutines.h |   4 +-
  block/nbd.c        | 303 +++++++++++++++++++++++----------------------

  2 files changed, 157 insertions(+), 150 deletions(-)

Hmm, no patches come to me except for cover-letter. Neither here: https://patchew.org/QEMU/[email protected]/

Network issue, I resent it a couple hours later (and forgot to Cc you, sorry about that).

Paolo