[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 2/4] luks: implement .bdrv_measure()
From: |
Stefan Hajnoczi |
Subject: |
Re: [PATCH v2 2/4] luks: implement .bdrv_measure() |
Date: |
Wed, 15 Jan 2020 13:41:40 +0000 |
On Tue, Jan 14, 2020 at 04:43:36PM +0100, Max Reitz wrote:
> 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.
Good points. I may have inherited this from the qcow2 code, where the
L2 tables can still have unallocated/zero clusters.
I'll check if this logic makes sense outside of qcow2.
Stefan
signature.asc
Description: PGP signature