[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 2/4] luks: implement .bdrv_measure()
From: |
Max Reitz |
Subject: |
Re: [PATCH v2 2/4] luks: implement .bdrv_measure() |
Date: |
Tue, 14 Jan 2020 16:43:36 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 |
On 09.01.20 12:10, Stefan Hajnoczi wrote:
> Add qemu-img measure support in the "luks" block driver.
>
> Signed-off-by: Stefan Hajnoczi <address@hidden>
> ---
> block/crypto.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 82 insertions(+)
>
> diff --git a/block/crypto.c b/block/crypto.c
> index ed32202fa2..51f37bb1f6 100644
> --- a/block/crypto.c
> +++ b/block/crypto.c
> @@ -548,6 +548,87 @@ static int64_t block_crypto_getlength(BlockDriverState
> *bs)
[...]
> + if (ret & BDRV_BLOCK_ZERO) {
> + /* Skip zero regions */
> + } else if ((ret & (BDRV_BLOCK_DATA | BDRV_BLOCK_ALLOCATED)) ==
> + (BDRV_BLOCK_DATA | BDRV_BLOCK_ALLOCATED)) {
> + /* Count clusters we've seen */
> + required += pnum;
> + }
Don’t LUKS-encrypted files allocate effectively everything because zero
data has to be encrypted, too?
(“Effectively”, because you could zero out regions that are zero when
encrypted, but...)
> + }
> + }
> +
> + /* Take into account preallocation. Nothing special is needed for
> + * PREALLOC_MODE_METADATA since metadata is always counted.
> + */
> + if (prealloc == PREALLOC_MODE_FULL || prealloc == PREALLOC_MODE_FALLOC) {
> + required = virtual_size;
Same here. I think required should always be set to virtual_size.
Max
signature.asc
Description: OpenPGP digital signature