qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC PATCH v2 8/8] mirror: protect drains in coroutine with rdlock


From: Emanuele Giuseppe Esposito
Subject: [RFC PATCH v2 8/8] mirror: protect drains in coroutine with rdlock
Date: Tue, 26 Apr 2022 04:51:14 -0400

Drain performed in coroutine schedules a bh in the main loop.
However, drain itself still is a read, and we need to signal
the writer that we are going through the graph.

Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
 block/mirror.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/block/mirror.c b/block/mirror.c
index ce6bc58d1f..de86729f9b 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -1065,10 +1065,14 @@ static int coroutine_fn mirror_run(Job *job, Error 
**errp)
             trace_mirror_before_drain(s, cnt);
 
             s->in_drain = true;
+            bdrv_graph_co_rdlock();
             bdrv_drained_begin(bs);
+            bdrv_graph_co_rdunlock();
             cnt = bdrv_get_dirty_count(s->dirty_bitmap);
             if (cnt > 0 || mirror_flush(s) < 0) {
+                bdrv_graph_co_rdlock();
                 bdrv_drained_end(bs);
+                bdrv_graph_co_rdunlock();
                 s->in_drain = false;
                 continue;
             }
@@ -1110,7 +1114,9 @@ immediate_exit:
 
     if (need_drain) {
         s->in_drain = true;
+        bdrv_graph_co_rdlock();
         bdrv_drained_begin(bs);
+        bdrv_graph_co_rdunlock();
     }
 
     return ret;
-- 
2.31.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]