diff mbox series

[1/2] mirror: Store MirrorOp.co for debuggability

Message ID 20200128151755.25162-2-kwolf@redhat.com (mailing list archive)
State New, archived
Headers show
Series mirror: Fix hang (operation waiting for itself) | expand

Commit Message

Kevin Wolf Jan. 28, 2020, 3:17 p.m. UTC
If a coroutine is launched, but the coroutine pointer isn't stored
anywhere, debugging any problems inside the coroutine is quite hard.
Let's store the coroutine pointer of a mirror operation in MirrorOp to
have it available in the debugger.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/mirror.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Eric Blake Jan. 28, 2020, 4:26 p.m. UTC | #1
On 1/28/20 9:17 AM, Kevin Wolf wrote:
> If a coroutine is launched, but the coroutine pointer isn't stored
> anywhere, debugging any problems inside the coroutine is quite hard.
> Let's store the coroutine pointer of a mirror operation in MirrorOp to
> have it available in the debugger.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>   block/mirror.c | 2 ++
>   1 file changed, 2 insertions(+)

Doesn't change semantics other than an unobservable performance delay; 
but the rewards in improved debugability warrant it.

Reviewed-by: Eric Blake <eblake@redhat.com>
diff mbox series

Patch

diff --git a/block/mirror.c b/block/mirror.c
index f0f2d9dff1..8959e4255f 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -103,6 +103,7 @@  struct MirrorOp {
     bool is_pseudo_op;
     bool is_active_write;
     CoQueue waiting_requests;
+    Coroutine *co;
 
     QTAILQ_ENTRY(MirrorOp) next;
 };
@@ -429,6 +430,7 @@  static unsigned mirror_perform(MirrorBlockJob *s, int64_t offset,
     default:
         abort();
     }
+    op->co = co;
 
     QTAILQ_INSERT_TAIL(&s->ops_in_flight, op, next);
     qemu_coroutine_enter(co);