[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 09/17] block: Refactor bdrv_has_zero_init{,_truncate}
From: |
Max Reitz |
Subject: |
Re: [PATCH 09/17] block: Refactor bdrv_has_zero_init{,_truncate} |
Date: |
Wed, 5 Feb 2020 17:43:25 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 |
On 04.02.20 18:51, Eric Blake wrote:
> On 2/4/20 11:42 AM, Max Reitz wrote:
>
>>>
>>> I understand that this is preexisting logic, but could I ask: why?
>>> What's wrong
>>> if driver can guarantee that created file is all-zero, but is not sure
>>> about
>>> file resizing? I agree that it's normal for these flags to have the same
>>> value,
>>> but what is the reason for this restriction?..
>>
>> If areas added by truncation (or growth, rather) are always zero, then
>> the file can always be created with size 0 and grown from there. Thus,
>> images where truncation adds zeroed areas will generally always be zero
>> after creation.
>>
>>> So, the only possible combination of flags, when they differs, is
>>> create=0 and
>>> truncate=1.. How is it possible?
>>
>> For preallocated qcow2 images, it depends on the storage whether they
>> are actually 0 after creation. Hence qcow2_has_zero_init() then defers
>> to bdrv_has_zero_init() of s->data_file->bs.
>>
>> But when you truncate them (with PREALLOC_MODE_OFF, as
>> BlockDriver.bdrv_has_zero_init_truncate()’s comment explains), the new
>> area is always going to be 0, regardless of initial preallocation.
>>
>>
>> I just noticed a bug there, though: Encrypted qcow2 images will not see
>> areas added through growth as 0. Hence, qcow2’s
>> bdrv_has_zero_init_truncate() implementation should not return true
>> unconditionally, but only for unencrypted images.
>
> Hence patch 5 earlier in the series :)
Ah, good. :-)
Max
signature.asc
Description: OpenPGP digital signature
- Re: [PATCH 09/17] block: Refactor bdrv_has_zero_init{,_truncate}, Vladimir Sementsov-Ogievskiy, 2020/02/04
- Re: [PATCH 09/17] block: Refactor bdrv_has_zero_init{,_truncate}, Eric Blake, 2020/02/04
- Re: [PATCH 09/17] block: Refactor bdrv_has_zero_init{,_truncate}, Max Reitz, 2020/02/04
- Re: [PATCH 09/17] block: Refactor bdrv_has_zero_init{,_truncate}, Eric Blake, 2020/02/04
- Re: [PATCH 09/17] block: Refactor bdrv_has_zero_init{,_truncate},
Max Reitz <=
- Re: [PATCH 09/17] block: Refactor bdrv_has_zero_init{,_truncate}, Vladimir Sementsov-Ogievskiy, 2020/02/05
- Re: [PATCH 09/17] block: Refactor bdrv_has_zero_init{,_truncate}, Max Reitz, 2020/02/05