[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Ensure the PV ring is drained on disconnect
From: |
Mark Syms |
Subject: |
[PATCH] Ensure the PV ring is drained on disconnect |
Date: |
Wed, 29 Mar 2023 11:53:44 +0100 |
Also ensure all pending AIO is complete.
Signed-off-by: Mark Syms <mark.syms@citrix.com>
---
hw/block/dataplane/xen-block.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/hw/block/dataplane/xen-block.c b/hw/block/dataplane/xen-block.c
index 734da42ea7..067f8e2f45 100644
--- a/hw/block/dataplane/xen-block.c
+++ b/hw/block/dataplane/xen-block.c
@@ -523,6 +523,10 @@ static bool xen_block_handle_requests(XenBlockDataPlane
*dataplane)
dataplane->more_work = 0;
+ if (dataplane->sring == 0) {
+ return done_something;
+ }
+
rc = dataplane->rings.common.req_cons;
rp = dataplane->rings.common.sring->req_prod;
xen_rmb(); /* Ensure we see queued requests up to 'rp'. */
@@ -666,11 +670,23 @@ void xen_block_dataplane_destroy(XenBlockDataPlane
*dataplane)
void xen_block_dataplane_stop(XenBlockDataPlane *dataplane)
{
XenDevice *xendev;
+ XenBlockRequest *request, *next;
if (!dataplane) {
return;
}
+ /* Ensure we have drained the ring */
+ do {
+ xen_block_handle_requests(dataplane);
+ } while (dataplane->more_work);
+
+ /* Now ensure that all inflight requests are complete */
+ QLIST_FOREACH_SAFE(request, &dataplane->inflight, list, next) {
+ blk_aio_flush(request->dataplane->blk, xen_block_complete_aio,
+ request);
+ }
+
xendev = dataplane->xendev;
aio_context_acquire(dataplane->ctx);
--
2.39.2