From: "Denis V. Lunev" <den@openvz.org>
To: andrey.zhadchenko@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.1 2/2] dm-qcow2: fix a merge reporting success after a failed write
Date: Tue, 27 Oct 2026 18:49:22 +0100 [thread overview]
Message-ID: <20261027174922.2254893-3-den@openvz.org> (raw)
In-Reply-To: <20261027174922.2254893-1-den@openvz.org>
From: Denis V. Lunev <den@openvz.org>
qcow2_service_iter() collects the status of its service qios in a
function-local static shared by every dm-qcow2 device, and resets it
to OK when it starts. A merge or L1 COW break starting on one device
while another one runs wipes the error the other one recorded. That
one then finishes and reports success although a qio failed, so
userspace may complete the merge and drop the top image, losing data
that never reached the lower image.
Keep the status on the stack. The qios carry a pointer to it, so the
function must not return while one of them is outstanding: every exit
already waits for service_qios to drain, and a BUG_ON after the wait
stops the kernel rather than let a late qio write into a dead stack
frame if that ever changes.
Fixes: 222b6f1291c1 ("dm-qcow2: Introduce driver to create block devices over QCOW2 files")
Signed-off-by: Denis V. Lunev <den@openvz.org>
Feature: dm-qcow2: block device over QCOW2 files driver
---
drivers/md/dm-qcow2-cmd.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/md/dm-qcow2-cmd.c b/drivers/md/dm-qcow2-cmd.c
index 2865940cff30..c7e77677d8e6 100644
--- a/drivers/md/dm-qcow2-cmd.c
+++ b/drivers/md/dm-qcow2-cmd.c
@@ -65,13 +65,11 @@ static bool qcow2_backward_merge_should_stop(struct qcow2_target *tgt);
static int qcow2_service_iter(struct qcow2_target *tgt, struct qcow2 *qcow2,
loff_t end, loff_t step, unsigned int bi_op, u8 qio_flags)
{
- static blk_status_t service_status;
+ blk_status_t service_status = BLK_STS_OK;
struct qio *qio;
int ret = 0;
loff_t pos;
- WRITE_ONCE(service_status, BLK_STS_OK);
-
backward_merge_update_max_progress(tgt, end);
for (pos = 0; pos < end; pos += step) {
backward_merge_update_progress(tgt, pos);
@@ -106,6 +104,8 @@ static int qcow2_service_iter(struct qcow2_target *tgt, struct qcow2 *qcow2,
}
wait_event(tgt->service_wq, !atomic_read(&tgt->service_qios));
+ /* The qios point at service_status on our stack */
+ BUG_ON(atomic_read(&tgt->service_qios));
if (!ret) {
smp_rmb(); /* Pairs with smp_wmb() in service_qio_endio() */
ret = blk_status_to_errno(READ_ONCE(service_status));
--
2.53.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-10-27 17:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 17:49 [Devel] [PATCH hci-8.1 0/2] dm-ploop, dm-qcow2: fix merge status shared by all devices Denis V. Lunev
2026-10-27 17:49 ` [Devel] [PATCH hci-8.1 1/2] dm-ploop: fix a failed merge failing every later merge on the host Denis V. Lunev
2026-10-27 17:49 ` Denis V. Lunev [this message]
2026-10-28 12:56 ` [Devel] [PATCH hci-8.1 0/2] dm-ploop, dm-qcow2: fix merge status shared by all devices Andrey Zhadchenko
2026-10-28 13:21 [Devel] [PATCH hci-8.1 v2 " Denis V. Lunev
2026-10-28 13:21 ` [Devel] [PATCH hci-8.1 2/2] dm-qcow2: fix a merge reporting success after a failed write Denis V. Lunev
2026-10-28 13:25 ` no-reply
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=20261027174922.2254893-3-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