aboutsummaryrefslogtreecommitdiff
path: root/chardev/char-win.c
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2023-12-21 14:24:51 -0500
committerKevin Wolf <kwolf@redhat.com>2023-12-21 21:59:07 +0100
commitf816310d0c32c8482e56807ea0f9faa8d1b5f696 (patch)
tree850d6fcfbb4b8a05d232f1004a6077e0f230a146 /chardev/char-win.c
parentefade66d5872e3bfb906944105145007ff2e26a3 (diff)
downloadqemu-f816310d0c32c8482e56807ea0f9faa8d1b5f696.zip
qemu-f816310d0c32c8482e56807ea0f9faa8d1b5f696.tar.gz
qemu-f816310d0c32c8482e56807ea0f9faa8d1b5f696.tar.bz2
nbd/server: only traverse NBDExport->clients from main loop thread
The NBD clients list is currently accessed from both the export AioContext and the main loop thread. When the AioContext lock is removed there will be nothing protecting the clients list. Adding a lock around the clients list is tricky because NBDClient structs are refcounted and may be freed from the export AioContext or the main loop thread. nbd_export_request_shutdown() -> client_close() -> nbd_client_put() is also tricky because the list lock would be held while indirectly dropping references to NDBClients. A simpler approach is to only allow nbd_client_put() and client_close() calls from the main loop thread. Then the NBD clients list is only accessed from the main loop thread and no fancy locking is needed. nbd_trip() just needs to reschedule itself in the main loop AioContext before calling nbd_client_put() and client_close(). This costs more CPU cycles per NBD request so add nbd_client_put_nonzero() to optimize the common case where more references to NBDClient remain. Note that nbd_client_get() can still be called from either thread, so make NBDClient->refcount atomic. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-ID: <20231221192452.1785567-6-stefanha@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'chardev/char-win.c')
0 files changed, 0 insertions, 0 deletions