[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v7 14/32] qcow2: Add QCow2SubclusterType and qcow2_get_subclu
From: |
Alberto Garcia |
Subject: |
Re: [PATCH v7 14/32] qcow2: Add QCow2SubclusterType and qcow2_get_subcluster_type() |
Date: |
Wed, 27 May 2020 11:51:48 +0200 |
User-agent: |
Notmuch/0.18.2 (http://notmuchmail.org) Emacs/24.4.1 (i586-pc-linux-gnu) |
On Tue 26 May 2020 10:32:08 PM CEST, Eric Blake wrote:
>> +/* The subcluster X [0..31] is allocated */
>> +#define QCOW_OFLAG_SUB_ALLOC(X) (1ULL << (X))
>> +/* The subcluster X [0..31] reads as zeroes */
>> +#define QCOW_OFLAG_SUB_ZERO(X) (QCOW_OFLAG_SUB_ALLOC(X) << 32)
>> +/* Subclusters [X, Y) (0 <= X <= Y <= 32) are allocated */
>
> As you are now using a half-open range, should this be:
> (0 <= X < Y <= 32)
I changed the macros because I wanted to allow cases where X == Y.
The reason is the new qcow2_get_subcluster_range_type() function:
case QCOW2_SUBCLUSTER_NORMAL:
val = l2_bitmap | QCOW_OFLAG_SUB_ALLOC_RANGE(0, sc_from);
return cto32(val) - sc_from;
If sc_from is 0 then the result of the macro is also 0, and 'val' equals
the lower 32 bits (allocation status bits) of the L2 bitmap, as
expected.
>> +#define QCOW_OFLAG_SUB_ALLOC_RANGE(X, Y) \
>> + (QCOW_OFLAG_SUB_ALLOC(Y) - QCOW_OFLAG_SUB_ALLOC(X))
>
> with <= instead of <, then it is impossible to distinguish between
> QCOW_OFLAG_SUB_ALLOC_RANGE(0,0) and QCOW_OFLAG_SUB_ALLOC_RANGE(31,31)
> which both resolve to 0.
Exactly, there is no difference and there should not be.
Berto
- [PATCH v7 23/32] qcow2: Add subcluster support to discard_in_l2_slice(), (continued)
- [PATCH v7 23/32] qcow2: Add subcluster support to discard_in_l2_slice(), Alberto Garcia, 2020/05/25
- [PATCH v7 01/32] qcow2: Make Qcow2AioTask store the full host offset, Alberto Garcia, 2020/05/25
- [PATCH v7 22/32] qcow2: Add subcluster support to zero_in_l2_slice(), Alberto Garcia, 2020/05/25
- [PATCH v7 13/32] qcow2: Update get/set_l2_entry() and add get/set_l2_bitmap(), Alberto Garcia, 2020/05/25
- [PATCH v7 16/32] qcow2: Add qcow2_cluster_is_allocated(), Alberto Garcia, 2020/05/25
- [PATCH v7 04/32] qcow2: Split cluster_needs_cow() out of count_cow_clusters(), Alberto Garcia, 2020/05/25
- [PATCH v7 14/32] qcow2: Add QCow2SubclusterType and qcow2_get_subcluster_type(), Alberto Garcia, 2020/05/25
- [PATCH v7 08/32] qcow2: Add dummy has_subclusters() function, Alberto Garcia, 2020/05/25
- [PATCH v7 10/32] qcow2: Add offset_to_sc_index(), Alberto Garcia, 2020/05/25
- [PATCH v7 11/32] qcow2: Add offset_into_subcluster() and size_to_subclusters(), Alberto Garcia, 2020/05/25
- [PATCH v7 24/32] qcow2: Add subcluster support to check_refcounts_l2(), Alberto Garcia, 2020/05/25
- [PATCH v7 27/32] qcow2: Add subcluster support to handle_alloc_space(), Alberto Garcia, 2020/05/25
- [PATCH v7 18/32] qcow2: Replace QCOW2_CLUSTER_* with QCOW2_SUBCLUSTER_*, Alberto Garcia, 2020/05/25
- [PATCH v7 31/32] qcow2: Assert that expand_zero_clusters_in_l1() does not support subclusters, Alberto Garcia, 2020/05/25
- [PATCH v7 25/32] qcow2: Update L2 bitmap in qcow2_alloc_cluster_link_l2(), Alberto Garcia, 2020/05/25