]> Git Repo - qemu.git/commit
nbd/server: Quiesce coroutines on context switch
authorSergio Lopez <[email protected]>
Mon, 14 Dec 2020 17:05:18 +0000 (18:05 +0100)
committerEric Blake <[email protected]>
Wed, 20 Jan 2021 20:48:54 +0000 (14:48 -0600)
commitf148ae7d36cbb924447f4b528a94d7799836c749
tree9c08b2964964a841c219c1ea61f7f2addd42ffdf
parentc7040ff64ec93ee925a81d3547db925fe7d1f1c0
nbd/server: Quiesce coroutines on context switch

When switching between AIO contexts we need to me make sure that both
recv_coroutine and send_coroutine are not scheduled to run. Otherwise,
QEMU may crash while attaching the new context with an error like
this one:

aio_co_schedule: Co-routine was already scheduled in 'aio_co_schedule'

To achieve this we need a local implementation of
'qio_channel_readv_all_eof' named 'nbd_read_eof' (a trick already done
by 'nbd/client.c') that allows us to interrupt the operation and to
know when recv_coroutine is yielding.

With this in place, we delegate detaching the AIO context to the
owning context with a BH ('nbd_aio_detach_bh') scheduled using
'aio_wait_bh_oneshot'. This BH signals that we need to quiesce the
channel by setting 'client->quiescing' to 'true', and either waits for
the coroutine to finish using AIO_WAIT_WHILE or, if it's yielding in
'nbd_read_eof', actively enters the coroutine to interrupt it.

RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1900326
Signed-off-by: Sergio Lopez <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Message-Id: <20201214170519[email protected]>
Signed-off-by: Eric Blake <[email protected]>
nbd/server.c
This page took 0.026735 seconds and 4 git commands to generate.