[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 03/30] qcow2: Add calculate_l2_meta()
From: |
Alberto Garcia |
Subject: |
Re: [PATCH v4 03/30] qcow2: Add calculate_l2_meta() |
Date: |
Thu, 09 Apr 2020 17:12:00 +0200 |
User-agent: |
Notmuch/0.18.2 (http://notmuchmail.org) Emacs/24.4.1 (i586-pc-linux-gnu) |
On Thu 09 Apr 2020 10:30:13 AM CEST, Vladimir Sementsov-Ogievskiy wrote:
>> +static void calculate_l2_meta(BlockDriverState *bs,
>> + uint64_t host_cluster_offset,
>> + uint64_t guest_offset, unsigned bytes,
>> + QCowL2Meta **m, bool keep_old)
>> +{
>> + BDRVQcow2State *s = bs->opaque;
>> + unsigned cow_start_from = 0;
>> + unsigned cow_start_to = offset_into_cluster(s, guest_offset);
>> + unsigned cow_end_from = cow_start_to + bytes;
>> + unsigned cow_end_to = ROUND_UP(cow_end_from, s->cluster_size);
>> + unsigned nb_clusters = size_to_clusters(s, cow_end_from);
>> + QCowL2Meta *old_m = *m;
>> +
>> + *m = g_malloc0(sizeof(**m));
>> + **m = (QCowL2Meta) {
>> + .next = old_m,
>> +
>> + .alloc_offset = host_cluster_offset,
>> + .offset = start_of_cluster(s, guest_offset),
>> + .nb_clusters = nb_clusters,
>> +
>> + .keep_old_clusters = keep_old,
>> +
>> + .cow_start = {
>> + .offset = cow_start_from,
>> + .nb_bytes = cow_start_to - cow_start_from,
>> + },
>> + .cow_end = {
>> + .offset = cow_end_from,
>
> Hmm. So, you make it equal to requested_bytes from handle_alloc().
No, requested_bytes from handle_alloc is:
requested_bytes = *bytes + offset_into_cluster(s, guest_offset);
But *bytes is later modified before calling calculate_l2_meta():
*bytes = MIN(*bytes, nb_bytes - offset_into_cluster(s, guest_offset));
More details here:
https://lists.gnu.org/archive/html/qemu-block/2019-10/msg01808.html
Berto