[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 2/3] qcow2: Always execute preallocate() in a co
From: |
Max Reitz |
Subject: |
Re: [Qemu-devel] [PATCH 2/3] qcow2: Always execute preallocate() in a coroutine |
Date: |
Wed, 11 Oct 2017 13:31:11 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 |
On 2017-10-10 00:28, Eric Blake wrote:
> 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...
Ah, yes, that was from before I added the typedef... Will fix.
Max
>
>> +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>
>
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH 0/3] qcow2: Fix preallocated truncation, Max Reitz, 2017/10/09
- [Qemu-devel] [PATCH 1/3] qcow2: Fix unaligned preallocated truncation, Max Reitz, 2017/10/09
- [Qemu-devel] [PATCH 2/3] qcow2: Always execute preallocate() in a coroutine, Max Reitz, 2017/10/09
- [Qemu-devel] [PATCH 3/3] iotests: Add cluster_size=64k to 125, Max Reitz, 2017/10/09
- Re: [Qemu-devel] [PATCH 0/3] qcow2: Fix preallocated truncation, Max Reitz, 2017/10/11
- Re: [Qemu-devel] [PATCH 0/3] qcow2: Fix preallocated truncation, Stefan Hajnoczi, 2017/10/11