[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 05/10] qcow2-refcount: fix_l2_entry_by_zero(): also zero L2 e
From: |
Eric Blake |
Subject: |
Re: [PATCH 05/10] qcow2-refcount: fix_l2_entry_by_zero(): also zero L2 entry bitmap |
Date: |
Tue, 4 May 2021 14:38:29 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 |
On 5/4/21 10:20 AM, Vladimir Sementsov-Ogievskiy wrote:
> We'll reuse the function to fix wrong L2 entry bitmap. Support it now.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
> block/qcow2-refcount.c | 18 +++++++++++++++---
> 1 file changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
> index f1e771d742..62d59eb2e9 100644
> --- a/block/qcow2-refcount.c
> +++ b/block/qcow2-refcount.c
> @@ -1588,7 +1588,8 @@ enum {
> };
>
> /*
> - * Fix L2 entry by making it QCOW2_CLUSTER_ZERO_PLAIN.
> + * Fix L2 entry by making it QCOW2_CLUSTER_ZERO_PLAIN (or maing all its
> present
making
> + * subclusters QCOW2_SUBCLUSTER_ZERO_PLAIN).
> *
> * Function do res->corruptions-- on success, so caller is responsible to do
> * corresponding res->corruptions++ prior to the call.
> @@ -1605,9 +1606,20 @@ static int fix_l2_entry_by_zero(BlockDriverState *bs,
> BdrvCheckResult *res,
> int idx = l2_index * (l2_entry_size(s) / sizeof(uint64_t));
> uint64_t l2e_offset = l2_offset + (uint64_t)l2_index * l2_entry_size(s);
> int ign = active ? QCOW2_OL_ACTIVE_L2 : QCOW2_OL_INACTIVE_L2;
> - uint64_t l2_entry = has_subclusters(s) ? 0 : QCOW_OFLAG_ZERO;
>
> - set_l2_entry(s, l2_table, l2_index, l2_entry);
> + if (has_subclusters(s)) {
> + uint64_t l2_bitmap = get_l2_bitmap(s, l2_table, l2_index);
> +
> + /* Allocated subclusters becomes zero */
become
> + l2_bitmap |= l2_bitmap << 32;
> + l2_bitmap &= QCOW_L2_BITMAP_ALL_ZEROES;
> +
> + set_l2_bitmap(s, l2_table, l2_index, l2_bitmap);
> + set_l2_entry(s, l2_table, l2_index, 0);
> + } else {
> + set_l2_entry(s, l2_table, l2_index, QCOW_OFLAG_ZERO);
> + }
> +
> ret = qcow2_pre_write_overlap_check(bs, ign, l2e_offset,
> l2_entry_size(s),
> false);
> if (metadata_overlap) {
>
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
- [PATCH 00/10] qcow2 check: check some reserved bits and subcluster bitmaps, Vladimir Sementsov-Ogievskiy, 2021/05/04
- [PATCH 01/10] qcow2-refcount: improve style of check_refcounts_l2(), Vladimir Sementsov-Ogievskiy, 2021/05/04
- [PATCH 03/10] qcow2: introduce qcow2_parse_compressed_l2_entry() helper, Vladimir Sementsov-Ogievskiy, 2021/05/04
- [PATCH 04/10] qcow2-refcount: introduce fix_l2_entry_by_zero(), Vladimir Sementsov-Ogievskiy, 2021/05/04
- [PATCH 05/10] qcow2-refcount: fix_l2_entry_by_zero(): also zero L2 entry bitmap, Vladimir Sementsov-Ogievskiy, 2021/05/04
- Re: [PATCH 05/10] qcow2-refcount: fix_l2_entry_by_zero(): also zero L2 entry bitmap,
Eric Blake <=
- [PATCH 06/10] qcow2-refcount: check_refcounts_l2(): check l2_bitmap, Vladimir Sementsov-Ogievskiy, 2021/05/04
- [PATCH 07/10] qcow2-refcount: check_refcounts_l2(): check reserved bits, Vladimir Sementsov-Ogievskiy, 2021/05/04
- [PATCH 08/10] qcow2-refcount: improve style of check_refcounts_l1(), Vladimir Sementsov-Ogievskiy, 2021/05/04
- [PATCH 10/10] qcow2-refcount: check_refblocks(): add separate message for reserved, Vladimir Sementsov-Ogievskiy, 2021/05/04