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 <vsement...@virtuozzo.com>
---
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 <ebl...@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org