[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [Qemu-devel] [PATCH 2/3] qcow2: Always execute prealloc
From: |
Eric Blake |
Subject: |
Re: [Qemu-block] [Qemu-devel] [PATCH 2/3] qcow2: Always execute preallocate() in a coroutine |
Date: |
Mon, 9 Oct 2017 17:28:21 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 |
On 10/09/2017 04:55 PM, Max Reitz wrote:
> Some qcow2 functions (at least perform_cow()) expect s->lock to be
> taken. Therefore, if we want to make use of them, we should execute
> preallocate() (as "preallocate_co") in a coroutine so that we can use
> the qemu_co_mutex_* functions.
>
> Signed-off-by: Max Reitz <address@hidden>
> ---
> block/qcow2.c | 41 ++++++++++++++++++++++++++++++++++-------
> 1 file changed, 34 insertions(+), 7 deletions(-)
>
> +++ b/block/qcow2.c
> @@ -2460,6 +2460,14 @@ static int qcow2_set_up_encryption(BlockDriverState
> *bs, const char *encryptfmt,
> }
>
>
> +typedef struct PreallocCo {
> + BlockDriverState *bs;
> + uint64_t offset;
> + uint64_t new_length;
> +
> + int ret;
> +} PreallocCo;
Because you create a typedef here...
> +static void coroutine_fn preallocate_co(void *opaque)
> {
> + struct PreallocCo *params = opaque;
you could drop 'struct' here, the way you already dropped it...
> +static int preallocate(BlockDriverState *bs,
> + uint64_t offset, uint64_t new_length)
> +{
> + PreallocCo params = {
> + .bs = bs,
> + .offset = offset,
> + .new_length = new_length,
> + .ret = -EINPROGRESS,
> + };
...here. But that doesn't change semantics, so either way,
Reviewed-by: Eric Blake <address@hidden>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-block] [PATCH 0/3] qcow2: Fix preallocated truncation, Max Reitz, 2017/10/09
- [Qemu-block] [PATCH 1/3] qcow2: Fix unaligned preallocated truncation, Max Reitz, 2017/10/09
- [Qemu-block] [PATCH 2/3] qcow2: Always execute preallocate() in a coroutine, Max Reitz, 2017/10/09
- [Qemu-block] [PATCH 3/3] iotests: Add cluster_size=64k to 125, Max Reitz, 2017/10/09
- Re: [Qemu-block] [PATCH 0/3] qcow2: Fix preallocated truncation, Max Reitz, 2017/10/11
- Re: [Qemu-block] [PATCH 0/3] qcow2: Fix preallocated truncation, Stefan Hajnoczi, 2017/10/11