[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH v2 10/26] qcow2: Update get/set_l2_entry() and add get/se
From: |
Max Reitz |
Subject: |
Re: [RFC PATCH v2 10/26] qcow2: Update get/set_l2_entry() and add get/set_l2_bitmap() |
Date: |
Wed, 30 Oct 2019 17:55:04 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 |
On 26.10.19 23:25, Alberto Garcia wrote:
> Extended L2 entries are 128-bit wide: 64 bits for the entry itself and
> 64 bits for the subcluster allocation bitmap.
>
> In order to support them correctly get/set_l2_entry() need to be
> updated so they take the entry width into account in order to
> calculate the correct offset.
>
> This patch also adds the get/set_l2_bitmap() functions that are used
> to access the bitmaps. For convenience, these functions are no-ops
> when used in traditional qcow2 images.
Granted, I haven’t seen the following patches yet, but if these
functions are indeed called for images that don’t have subclusters,
shouldn’t they return 0x0*0f*f then? (i.e. everything allocated)
If they aren’t, they should probably just abort(). Well,
set_l2_bitmap() should probably always abort() if there aren’t any
subclusters.
Max
> Signed-off-by: Alberto Garcia <address@hidden>
> ---
> block/qcow2.h | 22 ++++++++++++++++++++++
> 1 file changed, 22 insertions(+)
>
> diff --git a/block/qcow2.h b/block/qcow2.h
> index 29a253bfb9..741c41c80f 100644
> --- a/block/qcow2.h
> +++ b/block/qcow2.h
> @@ -507,15 +507,37 @@ static inline size_t l2_entry_size(BDRVQcow2State *s)
> static inline uint64_t get_l2_entry(BDRVQcow2State *s, uint64_t *l2_slice,
> int idx)
> {
> + idx *= l2_entry_size(s) / sizeof(uint64_t);
> return be64_to_cpu(l2_slice[idx]);
> }
>
> +static inline uint64_t get_l2_bitmap(BDRVQcow2State *s, uint64_t *l2_slice,
> + int idx)
> +{
> + if (has_subclusters(s)) {
> + idx *= l2_entry_size(s) / sizeof(uint64_t);
> + return be64_to_cpu(l2_slice[idx + 1]);
> + } else {
> + return 0;
> + }
> +}
> +
> static inline void set_l2_entry(BDRVQcow2State *s, uint64_t *l2_slice,
> int idx, uint64_t entry)
> {
> + idx *= l2_entry_size(s) / sizeof(uint64_t);
> l2_slice[idx] = cpu_to_be64(entry);
> }
>
> +static inline void set_l2_bitmap(BDRVQcow2State *s, uint64_t *l2_slice,
> + int idx, uint64_t bitmap)
> +{
> + if (has_subclusters(s)) {
> + idx *= l2_entry_size(s) / sizeof(uint64_t);
> + l2_slice[idx + 1] = cpu_to_be64(bitmap);
> + }
> +}
> +
> static inline bool has_data_file(BlockDriverState *bs)
> {
> BDRVQcow2State *s = bs->opaque;
>
signature.asc
Description: OpenPGP digital signature
- Re: [RFC PATCH v2 01/26] qcow2: Add calculate_l2_meta(), (continued)
- [RFC PATCH v2 25/26] qcow2: Allow preallocation and backing files if extended_l2 is set, Alberto Garcia, 2019/10/26
- [RFC PATCH v2 13/26] qcow2: Add subcluster support to calculate_l2_meta(), Alberto Garcia, 2019/10/26
- [RFC PATCH v2 21/26] qcow2: Clear the L2 bitmap when allocating a compressed cluster, Alberto Garcia, 2019/10/26
- [RFC PATCH v2 08/26] qcow2: Add offset_to_sc_index(), Alberto Garcia, 2019/10/26
- [RFC PATCH v2 06/26] qcow2: Add dummy has_subclusters() function, Alberto Garcia, 2019/10/26
- [RFC PATCH v2 10/26] qcow2: Update get/set_l2_entry() and add get/set_l2_bitmap(), Alberto Garcia, 2019/10/26
- Re: [RFC PATCH v2 10/26] qcow2: Update get/set_l2_entry() and add get/set_l2_bitmap(),
Max Reitz <=
- [RFC PATCH v2 22/26] qcow2: Add subcluster support to handle_alloc_space(), Alberto Garcia, 2019/10/26
- [RFC PATCH v2 05/26] qcow2: Document the Extended L2 Entries feature, Alberto Garcia, 2019/10/26
- [RFC PATCH v2 14/26] qcow2: Add subcluster support to qcow2_get_cluster_offset(), Alberto Garcia, 2019/10/26
- [RFC PATCH v2 20/26] qcow2: Update L2 bitmap in qcow2_alloc_cluster_link_l2(), Alberto Garcia, 2019/10/26
- [RFC PATCH v2 19/26] qcow2: Fix offset calculation in handle_dependencies(), Alberto Garcia, 2019/10/26
- [RFC PATCH v2 18/26] qcow2: Add subcluster support to expand_zero_clusters_in_l1(), Alberto Garcia, 2019/10/26
- [RFC PATCH v2 07/26] qcow2: Add subcluster-related fields to BDRVQcow2State, Alberto Garcia, 2019/10/26
- [RFC PATCH v2 12/26] qcow2: Handle QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER, Alberto Garcia, 2019/10/26