OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: "Denis V. Lunev" <den@openvz.org>
To: andrey.zhadchenko@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.1 v3 4/5] dm-qcow2: fix SEEK_HOLE/SEEK_DATA hanging after a failed metadata read
Date: Wed,  4 Nov 2026 19:01:04 +0100	[thread overview]
Message-ID: <20261104180105.1807820-5-den@openvz.org> (raw)
In-Reply-To: <20261104180105.1807820-1-den@openvz.org>

From: Denis V. Lunev <den@openvz.org>

qcow2_llseek_hole_qio() parks its seek qio on an md page that is not
loaded yet and sleeps until the qio is dispatched to QLIST_SEEK, where
process_seek_qios() completes it. When the page read fails,
do_md_page_read_complete() ends the waiting qios instead. A seek qio
has no endio_cb, so nothing wakes the walk, and the lseek() caller
sleeps uninterruptibly forever while it holds seek_rwsem: the next
merge_backward complete and every target message after it hang under
ctl_mutex as well.

Complete the seek from an endio_cb and return the error the qio was
ended with.

Fixes: 412d5a4f7bf1 ("dm/dm-qcow2: add llseek_hole")
Reported-by: Konstantin Khorenko <khorenko@virtuozzo.com>
https://virtuozzo.atlassian.net/browse/VSTOR-153422
Feature: dm-qcow2: block device over QCOW2 files driver
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
 drivers/md/dm-qcow2-map.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
index fa535d7716da..eee865989ef7 100644
--- a/drivers/md/dm-qcow2-map.c
+++ b/drivers/md/dm-qcow2-map.c
@@ -4600,6 +4600,13 @@ static void seek_qio_set_sector(struct qio *qio, sector_t bi_sector)
 	qio->bi_iter.bi_size = end > pos ? end - pos : 0;
 }
 
+/* A failed md page read ends the qios waiting for it */
+static void seek_qio_endio(struct qcow2_target *tgt, struct qio *qio,
+			   void *data, blk_status_t bi_status)
+{
+	complete(&((struct qio_data_llseek_hole *)data)->compl);
+}
+
 static struct qio *alloc_seek_qio(struct qcow2 *qcow2, struct qio *parent, loff_t new_lim)
 {
 	struct qio_data_llseek_hole *data;
@@ -4619,6 +4626,8 @@ static struct qio *alloc_seek_qio(struct qcow2 *qcow2, struct qio *parent, loff_
 	}
 
 	qio->data = data;
+	qio->endio_cb = seek_qio_endio;
+	qio->endio_cb_data = data;
 	init_completion(&data->compl);
 	data->lim = new_lim;
 
@@ -4752,6 +4761,10 @@ static int qcow2_llseek_hole_qio(struct qio *qio, int whence, loff_t *result)
 			/* one of metadata pages is not loaded and qio is postponed*/
 			wait_for_completion(&SEEK_QIO_DATA(qio)->compl);
 			reinit_completion(&SEEK_QIO_DATA(qio)->compl);
+			if (qio->bi_status != BLK_STS_OK) {
+				ret = blk_status_to_errno(qio->bi_status);
+				break;
+			}
 			continue;
 		}
 
-- 
2.53.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  parent reply	other threads:[~2026-11-04 18:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04 18:01 [Devel] [PATCH hci-8.1 v3 0/5] dm-qcow2: fix merges not stopping the users of the images they change Denis V. Lunev
2026-11-04 18:01 ` [Devel] [PATCH hci-8.1 v3 1/5] dm-qcow2: fix a failed refcount table relocation leaking md pages Denis V. Lunev
2026-11-04 18:52   ` no-reply
2026-11-04 18:01 ` [Devel] [PATCH hci-8.1 v3 2/5] dm-qcow2: fix backward merge of an inner image racing its reads Denis V. Lunev
2026-11-04 18:52   ` no-reply
2026-11-04 18:01 ` [Devel] [PATCH hci-8.1 v3 3/5] dm-qcow2: fix SEEK_HOLE/SEEK_DATA using an image freed by a merge Denis V. Lunev
2026-11-04 18:54   ` no-reply
2026-11-04 18:01 ` Denis V. Lunev [this message]
2026-11-04 18:55   ` [Devel] [PATCH hci-8.1 v3 4/5] dm-qcow2: fix SEEK_HOLE/SEEK_DATA hanging after a failed metadata read no-reply
2026-11-04 18:01 ` [Devel] [PATCH hci-8.1 v3 5/5] dm-qcow2: fix a refcount table relocation failing on a valid image Denis V. Lunev
2026-11-04 18:55   ` no-reply
2026-11-04 18:30 ` [Devel] [PATCH hci-8.1 v3 0/5] dm-qcow2: fix merges not stopping the users of the images they change 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=20261104180105.1807820-5-den@openvz.org \
    --to=den@openvz.org \
    --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