nbd/server: introduce NBDClient->lock to protect fields
commit7075d235114b40b30524cf1c5b61906c0bbf5f4d
authorStefan Hajnoczi <stefanha@redhat.com>
Thu, 21 Dec 2023 19:24:52 +0000 (21 14:24 -0500)
committerKevin Wolf <kwolf@redhat.com>
Thu, 21 Dec 2023 20:59:10 +0000 (21 21:59 +0100)
tree4d1f64987fcc81d60158cd103bfad42a574145ba
parentf816310d0c32c8482e56807ea0f9faa8d1b5f696
nbd/server: introduce NBDClient->lock to protect fields

NBDClient has a number of fields that are accessed by both the export
AioContext and the main loop thread. When the AioContext lock is removed
these fields will need another form of protection.

Add NBDClient->lock and protect fields that are accessed by both
threads. Also add assertions where possible and otherwise add doc
comments stating assumptions about which thread and lock holding.

Note this patch moves the client->recv_coroutine assertion from
nbd_co_receive_request() to nbd_trip() where client->lock is held.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20231221192452.1785567-7-stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
nbd/server.c