From: Konstantin Khorenko <khorenko@virtuozzo.com>
To: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
Cc: OpenVZ devel <devel@openvz.org>
Subject: Re: [Devel] [PATCH RHEL10 COMMIT] drivers/md/dm-qcow2: allow shared L1 entries during merge from RO image
Date: Fri, 28 Aug 2026 19:03:49 +0200 [thread overview]
Message-ID: <202608281703.67SH3nrj1063988@f0.sw.ru> (raw)
In-Reply-To: <20260827160619.303398-10-andrey.zhadchenko@virtuozzo.com>
The commit is pushed to "branch-rh10-6.12.0-211.39.1.16.x.vz10-ovz" and will appear at git@bitbucket.org:openvz/vzkernel.git
after rh10-6.12.0-211.39.1.16.11.vz10
------>
commit 08f42e9ddb46a95e8cf467d93248fb985e55b9b8
Author: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
Date: Thu Aug 27 19:06:17 2026 +0300
drivers/md/dm-qcow2: allow shared L1 entries during merge from RO image
For RO images with internal snapshots L1 entries are shared.
Write-mode metadata parsing stops at such entries to avoid
modifying a shared L2 table, which made prepare_backward_merge()
see the cluster as unallocated and skip it with
"nothing to merge": the merged result would silently lose all
data under shared L1 entries.
Allow such scenario in parse_l1() and ease WARN in
prepare_backward_merge().
https://virtuozzo.atlassian.net/browse/VSTOR-138288
Feature: dm-qcow2: block device over QCOW2 files driver
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
Reviewed-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
Reviewed-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
drivers/md/dm-qcow2-map.c | 18 ++++++++++++++++--
drivers/md/dm-qcow2.h | 5 +++++
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
index 3154cae955916..c5a79a51942ae 100644
--- a/drivers/md/dm-qcow2-map.c
+++ b/drivers/md/dm-qcow2-map.c
@@ -1726,6 +1726,14 @@ static bool qio_is_fully_alloced(struct qcow2 *qcow2, struct qio *qio,
return !(subclus_mask & ~alloced_mask);
}
+static bool qio_may_modify_image(struct qcow2 *qcow2, struct qio *qio)
+{
+ if (qcow2_file_is_writable(qcow2))
+ return true;
+
+ return !fake_merge_qio(qio);
+}
+
static loff_t parse_l1(struct qcow2 *qcow2, struct qcow2_map *map,
struct qio **qio, bool write)
@@ -1762,7 +1770,8 @@ static loff_t parse_l1(struct qcow2 *qcow2, struct qcow2_map *map,
goto out;
if (delay_if_dirty(qcow2, l1->md, l1->index_in_page, qio))
goto out;
- if (write && map->clu_is_cow)
+ /* Don't refuse L1 parse for merge qios with readonly disks */
+ if (write && map->clu_is_cow && qio_may_modify_image(qcow2, *qio))
goto out; /* Avoid to return pos */
ret = pos;
@@ -2061,6 +2070,10 @@ static int parse_metadata(struct qcow2 *qcow2, struct qio **qio,
qio_discard_unmaps_cluster(qcow2, *qio, map)))
return 0;
+ /* Don't need refcount table if we don't modify the image */
+ if (!qio_may_modify_image(qcow2, *qio))
+ return 0;
+
/* Now refcounters table/block */
ret = qcow2_handle_r1r2_maps(qcow2, pos, qio, &map->r1,
&map->r2, map->compressed);
@@ -2732,7 +2745,8 @@ static int prepare_backward_merge(struct qcow2 *qcow2, struct qio **qio,
int ret;
if (!map->data_clu_alloced) {
- WARN_ON_ONCE(map->clu_is_cow); /* Strange COW at L1 */
+ /* Strange COW at L1, except the merge from RO image */
+ WARN_ON_ONCE(map->clu_is_cow && qio_may_modify_image(qcow2, *qio));
if (fake_merge_qio(*qio)) {
/* Nothing is to merge */
goto endio;
diff --git a/drivers/md/dm-qcow2.h b/drivers/md/dm-qcow2.h
index 0f006f1ae48cc..d9b8c38e093f5 100644
--- a/drivers/md/dm-qcow2.h
+++ b/drivers/md/dm-qcow2.h
@@ -460,6 +460,11 @@ static inline bool qcow2_wants_check(struct qcow2_target *tgt)
return !!(tgt->md_writeback_error|tgt->truncate_error);
}
+static inline bool qcow2_file_is_writable(struct qcow2 *qcow2)
+{
+ return qcow2->file->f_mode & FMODE_WRITE;
+}
+
static inline void remap_to_clu(struct qcow2 *qcow2, struct qio *qio, loff_t clu_pos)
{
qio->bi_iter.bi_sector &= (to_sector(qcow2->clu_size) - 1);
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-08-28 17:05 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 16:06 [Devel] [PATCH VZ10 v4 00/11] dm-qcow2: improve discard and read-only merge handling Andrey Zhadchenko
2026-08-27 16:06 ` [Devel] [PATCH VZ10 v4 01/11] drivers/md/dm-qcow2: do not attach a bvec to discard qios Andrey Zhadchenko
2026-08-28 17:03 ` [Devel] [PATCH RHEL10 COMMIT] " Konstantin Khorenko
2026-08-27 16:06 ` [Devel] [PATCH VZ10 v4 02/11] drivers/md/dm-qcow2: fix revert_cluster_alloc() for ext_l2 case Andrey Zhadchenko
2026-08-28 17:03 ` [Devel] [PATCH RHEL10 COMMIT] " Konstantin Khorenko
2026-08-27 16:06 ` [Devel] [PATCH VZ10 v4 03/11] drivers/md/dm-qcow2: generalize COW index update machinery Andrey Zhadchenko
2026-08-28 17:03 ` [Devel] [PATCH RHEL10 COMMIT] " Konstantin Khorenko
2026-08-27 16:06 ` [Devel] [PATCH VZ10 v4 04/11] drivers/md/dm-qcow2: update metadata on whole cluster discard Andrey Zhadchenko
2026-08-28 17:03 ` [Devel] [PATCH RHEL10 COMMIT] " Konstantin Khorenko
2026-08-27 16:06 ` [Devel] [PATCH VZ10 v4 05/11] drivers/md/dm-qcow2: never trigger COW or allocation on discard Andrey Zhadchenko
2026-08-28 17:03 ` [Devel] [PATCH RHEL10 COMMIT] " Konstantin Khorenko
2026-08-27 16:06 ` [Devel] [PATCH VZ10 v4 06/11] drivers/md/dm-qcow2: set L2_READS_ALL_ZEROES after some discards Andrey Zhadchenko
2026-08-28 17:03 ` [Devel] [PATCH RHEL10 COMMIT] " Konstantin Khorenko
2026-08-27 16:06 ` [Devel] [PATCH VZ10 v4 07/11] drivers/md/dm-qcow2: update metadata on subclusters discard Andrey Zhadchenko
2026-08-28 17:03 ` [Devel] [PATCH RHEL10 COMMIT] " Konstantin Khorenko
2026-08-27 16:06 ` [Devel] [PATCH VZ10 v4 08/11] drivers/md/dm-qcow2: unmap cluster when discard clears last allocated subclusters Andrey Zhadchenko
2026-08-28 17:03 ` [Devel] [PATCH RHEL10 COMMIT] " Konstantin Khorenko
2026-08-27 16:06 ` [Devel] [PATCH VZ10 v4 09/11] drivers/md/dm-qcow2: allow shared L1 entries during merge from RO image Andrey Zhadchenko
2026-08-28 17:03 ` Konstantin Khorenko [this message]
2026-08-27 16:06 ` [Devel] [PATCH VZ10 v4 10/11] drivers/md/dm-qcow2: do discards during backward merge only for writable image Andrey Zhadchenko
2026-08-28 17:03 ` [Devel] [PATCH RHEL10 COMMIT] " Konstantin Khorenko
2026-08-27 16:06 ` [Devel] [PATCH VZ10 v4 11/11] drivers/md/dm-qcow2: respect zeroes during merge Andrey Zhadchenko
2026-08-28 17:03 ` [Devel] [PATCH RHEL10 COMMIT] " Konstantin Khorenko
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=202608281703.67SH3nrj1063988@f0.sw.ru \
--to=khorenko@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