From: no-reply@sashiko.virtuozzo.com
To: Alexander Ivanov <alexander.ivanov@virtuozzo.com>,
andrey.zhadchenko@virtuozzo.com
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.1 3/3] drivers/md/dm-qcow2: do not revalidate inconsistent persistent bitmaps
Date: Fri, 23 Oct 2026 13:25:25 +0000 [thread overview]
Message-ID: <010701a168f0113e-a206ddd3-c75b-46e7-9392-a425636a8df8-000000@eu-central-1.amazonses.com> (raw)
In-Reply-To: <20261023132008.2304901-4-alexander.ivanov@virtuozzo.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] dm-qcow2: qcow2_parse_header() reads autoclear_features from v2 headers
--
commit 023e7aaebe247a5bb8465f4b52b55cce93eb8686
Author: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
drivers/md/dm-qcow2: do not revalidate inconsistent persistent bitmaps
This patch makes qcow2_parse_header() read autoclear_features from the raw
on-disk header. If the bitmaps bit is clear in the image, it clears that bit
in the parsed header after the extensions are parsed. The goal is to stop a
writable open from marking an inconsistent bitmaps extension consistent
again.
Link: https://virtuozzo.atlassian.net/browse/VSTOR-138887
> diff --git a/drivers/md/dm-qcow2-target.c b/drivers/md/dm-qcow2-target.c
> --- a/drivers/md/dm-qcow2-target.c
> +++ b/drivers/md/dm-qcow2-target.c
[ ... ]
> @@ -865,6 +866,7 @@ static int qcow2_parse_header(struct dm_target *ti, struct qcow2 *qcow2,
> max_len = upper->hdr.size;
> }
> ret = qcow2_check_convert_hdr(ti, raw_hdr, hdr, min_len, max_len);
> + raw_autoclear = be64_to_cpu(raw_hdr->autoclear_features);
> kunmap(md->page);
> if (ret < 0)
> goto out;
[Severity: Low]
Is it correct to read autoclear_features from raw_hdr unconditionally here?
qcow2_check_convert_hdr() returns early for version 2 images:
if (hdr->version == 2)
return 0;
so it never parses or zeroes autoclear_features for them. For a v2 image,
the field is not part of the header, and the bytes at that offset belong to
the extension area or padding. The new code then treats those bytes as
autoclear feature flags.
The v3 case looks similar. header_length is only checked against
sizeof(struct QCowHeader) on the compression path. A v3 image with a short
header_length would also have the bytes at that offset read as autoclear
flags.
The new code can only clear QCOW2_AUTOCLEAR_BITMAPS, never set it, and the
read stays inside the mapped page. The effect is therefore small.
Would it be better to do the read and the mask only when hdr->version >= 3?
That could go inside qcow2_check_convert_hdr(), next to the existing
hdr->autoclear_features = 0.
[ ... ]
> @@ -914,6 +916,9 @@ static int qcow2_parse_header(struct dm_target *ti, struct qcow2 *qcow2,
> goto out;
> }
> }
> + /* Bitmaps invalidated before must not become consistent again */
> + if (!(raw_autoclear & QCOW2_AUTOCLEAR_BITMAPS))
> + hdr->autoclear_features &= ~QCOW2_AUTOCLEAR_BITMAPS;
> ret = 0;
> out:
> return ret;
[Severity: Low]
For a v2 image, does this decision depend on a meaningless raw_autoclear
value?
The mask is applied based on whatever bytes sit at offset 88 of the header
page, rather than on a real autoclear_features field. It should be
conditional on hdr->version >= 3, as noted above.
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261023132008.2304901-1-alexander.ivanov@virtuozzo.com?part=3
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-10-23 13:26 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-23 13:20 [Devel] [PATCH hci-8.1 0/3] dm-qcow2: keep images of a read-only table unmodified Alexander Ivanov
2026-10-23 13:20 ` [Devel] [PATCH hci-8.1 1/3] drivers/md/dm-qcow2: treat images of a read-only table as read-only Alexander Ivanov
2026-10-23 13:24 ` no-reply
2026-10-29 11:36 ` Konstantin Khorenko
2026-10-23 13:20 ` [Devel] [PATCH hci-8.1 2/3] drivers/md/dm-qcow2: fail writes to a read-only table Alexander Ivanov
2026-10-23 13:23 ` no-reply
2026-10-28 10:35 ` Andrey Zhadchenko
2026-10-23 13:20 ` [Devel] [PATCH hci-8.1 3/3] drivers/md/dm-qcow2: do not revalidate inconsistent persistent bitmaps Alexander Ivanov
2026-10-23 13:25 ` no-reply [this message]
2026-10-23 13:58 ` Alexander Ivanov
2026-10-29 11:39 ` Konstantin Khorenko
2026-10-28 10:47 ` [Devel] [PATCH hci-8.1 0/3] dm-qcow2: keep images of a read-only table unmodified Andrey Zhadchenko
2026-10-29 11:42 ` Konstantin Khorenko
2026-10-29 14:48 ` Alexander Ivanov
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=010701a168f0113e-a206ddd3-c75b-46e7-9392-a425636a8df8-000000@eu-central-1.amazonses.com \
--to=no-reply@sashiko.virtuozzo.com \
--cc=alexander.ivanov@virtuozzo.com \
--cc=andrey.zhadchenko@virtuozzo.com \
--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