qemu-block
[Top][All Lists]
Advanced

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

Re: [PATCH v2 1/9] block/io: refactor bdrv_is_allocated_above to run onl


From: Eric Blake
Subject: Re: [PATCH v2 1/9] block/io: refactor bdrv_is_allocated_above to run only one coroutine
Date: Fri, 1 May 2020 16:25:51 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0

On 4/27/20 9:38 AM, Vladimir Sementsov-Ogievskiy wrote:
bdrv_is_allocated_above creates new coroutine on each iteration if
called from non-coroutine context. To simplify expansion of in_flight
inc/dec sections in further patch let's refactor it.

Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
---
  block/io.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++----
  1 file changed, 71 insertions(+), 5 deletions(-)


Quite a lot of lines added, but it fits the the mechanical boilerplate we have elsewhere.

diff --git a/block/io.c b/block/io.c
index aba67f66b9..94ab8eaa0f 100644
--- a/block/io.c
+++ b/block/io.c

+int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base,
+                            bool include_base, int64_t offset, int64_t bytes,
+                            int64_t *pnum)
+{
+    Coroutine *co;
+    BdrvCoIsAllocatedAboveData data = {
+        .top = top,
+        .base = base,
+        .include_base = include_base,
+        .offset = offset,
+        .bytes = bytes,
+        .pnum = pnum,
+        .done = false,
+    };

Omitting the line '.done = false,' has the same effect, since once you use a designated initializer, all remaining unspecified fields are 0-initialized. But explicitly mentioning it doesn't hurt.

Reviewed-by: Eric Blake <address@hidden>

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org




reply via email to

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