diff mbox series

[08/17] mirror: Make mirror_co_discard() nicer

Message ID 20180813022006.7216-9-mreitz@redhat.com (mailing list archive)
State New, archived
Headers show
Series mirror: Mainly coroutine refinements | expand

Commit Message

Max Reitz Aug. 13, 2018, 2:19 a.m. UTC
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block/mirror.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/block/mirror.c b/block/mirror.c
index df8e0242dc..85b08086cc 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -374,16 +374,13 @@  static int coroutine_fn mirror_co_zero(MirrorBlockJob *s,
                                 s->unmap ? BDRV_REQ_MAY_UNMAP : 0);
 }
 
-static void coroutine_fn mirror_co_discard(void *opaque)
+static int coroutine_fn mirror_co_discard(MirrorBlockJob *s,
+                                          int64_t offset, int64_t bytes)
 {
-    MirrorOp *op = opaque;
-    int ret;
-
-    op->s->in_flight++;
-    op->s->bytes_in_flight += op->bytes;
+    s->in_flight++;
+    s->bytes_in_flight += bytes;
 
-    ret = blk_co_pdiscard(op->s->target, op->offset, op->bytes);
-    mirror_write_complete(op, ret);
+    return blk_co_pdiscard(s->target, offset, bytes);
 }
 
 static void coroutine_fn mirror_co_perform(void *opaque)
@@ -400,8 +397,8 @@  static void coroutine_fn mirror_co_perform(void *opaque)
         ret = mirror_co_zero(s, op->offset, op->bytes);
         break;
     case MIRROR_METHOD_DISCARD:
-        mirror_co_discard(opaque);
-        return;
+        ret = mirror_co_discard(s, op->offset, op->bytes);
+        break;
     default:
         abort();
     }