OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: Konstantin Khorenko <khorenko@virtuozzo.com>
Subject: [Devel] [PATCH RHEL10 COMMIT] dm-qcow2: fix seek skip to the next L2 table
Date: Tue, 25 Aug 2026 12:41:56 +0200	[thread overview]
Message-ID: <202608251041.67PAfuj7774806@f0.sw.ru> (raw)
In-Reply-To: <20260819000745.28823-5-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 at bitbucket.org:openvz/vzkernel.git
after rh10-6.12.0-211.39.1.16.9.vz10
------>
commit fef1e3ed3933512286b531bf4d01bc3d4b721621
Author: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
Date:   Wed Aug 19 03:07:42 2026 +0300

    dm-qcow2: fix seek skip to the next L2 table
    
    get_next_l2() adds the number of remaining clusters to the current
    sector, so for a position which is not cluster aligned (e.g. the
    llseek offset itself) the result overshoots the L2 table boundary by
    the in-cluster offset.
    
    Compute the boundary by simple round_up to the size covered by a
    single L2 table.
    
    Also allow skipping l2 if we have lower delta but range does not
    exist there (e.g. past the delta end).
    
    https://virtuozzo.atlassian.net/browse/VSTOR-139407
    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>
---
 drivers/md/dm-qcow2-map.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
index d6d15b04215c6..43188ceebc9af 100644
--- a/drivers/md/dm-qcow2-map.c
+++ b/drivers/md/dm-qcow2-map.c
@@ -4405,12 +4405,9 @@ static struct qio *free_seek_qio_ret_higher(struct qio *qio)
 static inline sector_t get_next_l2(struct qio *qio)
 {
 	struct qcow2 *qcow2 = qio->qcow2;
-	loff_t start, add;
+	u64 l2_cover = to_sector((u64)qcow2->clu_size * qcow2->l2_entries);
 
-	start = to_bytes(qio->bi_iter.bi_sector);
-	add = qcow2->l2_entries - (start / qcow2->clu_size) % qcow2->l2_entries;
-
-	return qio->bi_iter.bi_sector + (qcow2->clu_size / to_bytes(1)) * add;
+	return round_up(qio->bi_iter.bi_sector + 1, l2_cover);
 }
 
 static inline sector_t get_next_clu(struct qio *qio)
@@ -4431,9 +4428,10 @@ static inline void seek_qio_next_clu(struct qio *qio, struct qcow2_map *map)
 
 	/*
 	 * Whole L2 table is unmapped - skip to next l2 table,
-	 * but only if there is no backing image
+	 * but only if there is no backing data
 	 */
-	if (map && !(map->level & L2_LEVEL) && !qio->qcow2->lower)
+	if (map && !(map->level & L2_LEVEL) &&
+	    !maybe_mapped_in_lower_delta(qio->qcow2, qio))
 		bi_sector = get_next_l2(qio);
 	else
 		bi_sector = get_next_clu(qio);

  reply	other threads:[~2026-08-25 10:41 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-19  0:07 [Devel] [PATCH VZ10 v2 0/7] dm-qcow: lseek improvements Andrey Zhadchenko
2026-08-19  0:07 ` [Devel] [PATCH VZ10 v2 1/7] drivers/md/dm-qcow2: fix lower delta seek window clamp Andrey Zhadchenko
2026-08-25 10:41   ` [Devel] [PATCH RHEL10 COMMIT] dm-qcow2: " Konstantin Khorenko
2026-08-19  0:07 ` [Devel] [PATCH VZ10 v2 2/7] drivers/md/dm-qcow2: keep seek parse window within limit Andrey Zhadchenko
2026-08-25 10:41   ` [Devel] [PATCH RHEL10 COMMIT] dm-qcow2: " Konstantin Khorenko
2026-08-19  0:07 ` [Devel] [PATCH VZ10 v2 3/7] drivers/md/dm-qcow2: fix seek constant comparison Andrey Zhadchenko
2026-08-25 10:41   ` [Devel] [PATCH RHEL10 COMMIT] dm-qcow2: " Konstantin Khorenko
2026-08-19  0:07 ` [Devel] [PATCH VZ10 v2 4/7] drivers/md/dm-qcow2: fix seek skip to the next L2 table Andrey Zhadchenko
2026-08-25 10:41   ` Konstantin Khorenko [this message]
2026-08-19  0:07 ` [Devel] [PATCH VZ10 v2 5/7] drivers/md/dm-qcow2: scan lower delta in one pass over empty L1 entry Andrey Zhadchenko
2026-08-25 10:41   ` [Devel] [PATCH RHEL10 COMMIT] dm-qcow2: " Konstantin Khorenko
2026-08-19  0:07 ` [Devel] [PATCH VZ10 v2 6/7] drivers/md/dm-qcow2: seek unallocated L2 entries in one pass within md Andrey Zhadchenko
2026-08-25 10:41   ` [Devel] [PATCH RHEL10 COMMIT] dm-qcow2: " Konstantin Khorenko
2026-08-19  0:07 ` [Devel] [PATCH VZ10 v2 7/7] drivers/md/dm-qcow2: forbid unaligned virtual size for images Andrey Zhadchenko
2026-08-25 10:41   ` [Devel] [PATCH RHEL10 COMMIT] dm-qcow2: " Konstantin Khorenko
2026-08-19  8:54 ` [Devel] [PATCH VZ10 v2 0/7] dm-qcow: lseek improvements Vasileios Almpanis
2026-08-24 14:38 ` Pavel Tikhomirov

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=202608251041.67PAfuj7774806@f0.sw.ru \
    --to=khorenko@virtuozzo.com \
    /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