On 09.01.20 12:10, Stefan Hajnoczi wrote: > Add qemu-img measure support in the "luks" block driver. > > Signed-off-by: Stefan Hajnoczi <[email protected]> > --- > 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
