From: Konstantin Khorenko <khorenko@virtuozzo.com>
To: "Denis V. Lunev" <den@openvz.org>
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.2] dm-qcow2: fix stale host data showing in a zero cluster after a write
Date: Tue, 24 Nov 2026 13:08:20 +0100 [thread overview]
Message-ID: <179552210098.10044.15846686166662724394.b4-review@b4> (raw)
In-Reply-To: <20261123191317.199611-1-den@openvz.org>
I won't apply this version, please send v2 with the changes below.
On Mon, 23 Nov 2026 20:13:17 +0100, Denis V. Lunev wrote:
> dm-qcow2: fix stale host data showing in a zero cluster after a write
- Cover an unallocated subcluster of an allocated cluster too, when
there is no backing image or the write is past its end: it shows the
same stale data.
- Share one border-mask helper with
qio_border_is_inside_unmapped_unit() instead of a third copy of the
border test.
- Keep the unchanged new_ext_l2 and calc_cow_mask() lines as they were.
- Commit message: drop the sentence that retells the rename, say why
cow_in_place is needed besides only_set_ext_l2, reword "whose other
border".
The zero unit part is right: the zero slices come from the map with no
disk read, the cluster is written in place, and on a non-extended image
the L2 entry is rewritten only after the data is on disk.
> - qio_border_is_inside_unmapped_unit(qcow2, *qio, map) &&
> - maybe_mapped_in_lower_delta(qcow2, *qio)) {
> + ((qio_border_is_inside_unmapped_unit(qcow2, *qio, map) &&
> + maybe_mapped_in_lower_delta(qcow2, *qio)) ||
> + qio_border_is_inside_zero_unit(qcow2, *qio, map))) {
A subcluster with neither the alloc nor the zero bit set, in an
allocated cluster, can keep old host data as well: qemu allocates a
cluster for a subcluster write, copies only that subcluster, and may
reuse a freed cluster for it. Without a backing image
maybe_mapped_in_lower_delta() is false and the zero mask is 0, so a 4K
write into such a subcluster goes to prepare_l1l2_allocation() and the
rest of the subcluster reads back the old data instead of zeroes. qemu
copies this subcluster type whole on a partial write, like a zero one.
The sliced path already zero-fills an unmapped slice when there is no
lower image, so taking an allocated cluster here as well should be
enough.
> +/* Zero subclusters with a border of @qio inside, which keep host blocks */
> +static u32 qio_border_zero_subclus_mask(struct qcow2 *qcow2, struct qio *qio,
> + struct qcow2_map *map)
This repeats the border test of qio_border_is_inside_unmapped_unit()
(and of calc_cow_mask()): qio_subclu_indexes(), then SUBCLU_OFF() and
a bit test for each end; only the mask differs. One helper that takes
the mask would serve both, and the case above becomes a mask change.
> + ext->new_ext_l2 = mask | map->subclus_mask;
> + ext->only_set_ext_l2 = ext->cow_in_place;
> + ext->cow_mask = calc_cow_mask(qcow2, map->ext_l2, qio,
> + true, map->clu_is_cow, false);
The new_ext_l2 and calc_cow_mask() lines change only from qio->ext-> to
ext->; please leave them as they were, so the diff shows the logic
change only.
> cluster stays where it is. map->backing_file_cow becomes sliced_cow,
> and qio_ext gets cow_in_place for the non-extended case, where the L2
> entry is still rewritten.
The rename needs no sentence. What the reader needs is why cow_in_place
exists: only_set_ext_l2 cannot mark an in-place write on a non-extended
image, where the L2 entry must still be rewritten to drop the zero
flag. It is set in both modes, so "for the non-extended case" reads as
if it were set only there.
> backing file COW of a write whose other border is in an unallocated
> subcluster copies only that subcluster.
"Other" than which border? Something like "a write with one border in
an unallocated subcluster and the other in a zero subcluster" says it
directly.
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
prev parent reply other threads:[~2026-11-24 12:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 19:13 Denis V. Lunev
2026-11-23 19:21 ` no-reply
2026-11-24 12:08 ` Konstantin Khorenko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179552210098.10044.15846686166662724394.b4-review@b4 \
--to=khorenko@virtuozzo.com \
--cc=den@openvz.org \
--cc=devel@openvz.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox