xen/9pfs: yield when there isn't enough room on the ring
authorStefano Stabellini <stefano.stabellini@xilinx.com>
Thu, 21 May 2020 19:26:26 +0000 (12:26 -0700)
committerGreg Kurz <groug@kaod.org>
Mon, 25 May 2020 09:45:39 +0000 (11:45 +0200)
commita4c4d462729466c4756bac8a0a8d77eb63b21ef7
tree6a772717fd64b378495b2285f9a20490b3dc9612
parentcf45183b718f02b1369e18c795dc51bc1821245d
xen/9pfs: yield when there isn't enough room on the ring

Instead of truncating replies, which is problematic, wait until the
client reads more data and frees bytes on the reply ring.

Do that by calling qemu_coroutine_yield(). The corresponding
qemu_coroutine_enter_if_inactive() is called from xen_9pfs_bh upon
receiving the next notification from the client.

We need to be careful to avoid races in case xen_9pfs_bh and the
coroutine are both active at the same time. In xen_9pfs_bh, wait until
either the critical section is over (ring->co == NULL) or until the
coroutine becomes inactive (qemu_coroutine_yield() was called) before
continuing. Then, simply wake up the coroutine if it is inactive.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Message-Id: <20200521192627.15259-2-sstabellini@kernel.org>
Signed-off-by: Greg Kurz <groug@kaod.org>
hw/9pfs/xen-9p-backend.c