OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: "Denis V. Lunev" <den@openvz.org>
To: andrey.zhadchenko@virtuozzo.com, alexander.ivanov@virtuozzo.com,
	vasileios.almpanis@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.2 v2 5/8] dm-qcow2: fix qcow2_flush_deferred_activity() skipping a running timer
Date: Mon, 23 Nov 2026 16:36:37 +0100	[thread overview]
Message-ID: <20261123153640.128227-6-den@openvz.org> (raw)
In-Reply-To: <20261123153640.128227-1-den@openvz.org>

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

qcow2_flush_deferred_activity() runs the slow writeback timer callback
itself in each of its two passes, so that dirty R1/R2 pages are
written, but skips that when timer_delete_sync_try() finds the callback
running on another CPU. A callback skipped in the first pass is over by
the second, as the inflight reference switch in between waits for an
RCU grace period. The timer can however be rearmed by an R1/R2 page
that the first pass failed to write with ENOSPC, and expire just as the
second pass starts. That callback queues the worker after the last
flush_workqueue(), so the pages are written after the flush returns:
after suspend has cleared the dirty bit of the image, or, at backward
merge complete, on an image that is already freed.

Wait for the callback with timer_delete_sync() and then run it
unconditionally. Every caller can sleep and none holds md_pages_lock.

https://virtuozzo.atlassian.net/browse/VSTOR-156036

Fixes: 222b6f1291c1 ("dm-qcow2: Introduce driver to create block devices over QCOW2 files")
Feature: dm-qcow2: block device over QCOW2 files driver
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
 drivers/md/dm-qcow2-target.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm-qcow2-target.c b/drivers/md/dm-qcow2-target.c
index f839b444b328..2a51beaebcab 100644
--- a/drivers/md/dm-qcow2-target.c
+++ b/drivers/md/dm-qcow2-target.c
@@ -177,8 +177,8 @@ void qcow2_flush_deferred_activity(struct qcow2_target *tgt, struct qcow2 *qcow2
 	/* Do not redirty R1/R2 failed with ENOSPC on the last pass */
 	for (i = 0; i < 2; i++) {
 		WRITE_ONCE(qcow2->md_wb_no_retry, i == 1);
-		if (timer_delete_sync_try(&qcow2->slow_wb_timer) != -1)
-			qcow2_slow_wb_timer_fn(&qcow2->slow_wb_timer);
+		timer_delete_sync(&qcow2->slow_wb_timer);
+		qcow2_slow_wb_timer_fn(&qcow2->slow_wb_timer);
 		/* Start md writeback */
 		flush_workqueue(tgt->wq);
 		/* Wait AIO of md wb */
-- 
2.55.0

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

  parent reply	other threads:[~2026-11-23 15:38 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 15:36 [Devel] [PATCH hci-8.2 v2 0/8] dm-qcow2: fix image I/O completions using a freed target Denis V. Lunev
2026-11-23 15:36 ` [Devel] [PATCH hci-8.2 v2 1/8] dm-qcow2: drop the qio argument of endio callbacks Denis V. Lunev
2026-11-23 15:40   ` no-reply
2026-11-23 15:36 ` [Devel] [PATCH hci-8.2 v2 2/8] dm-qcow2: fix do_qio_endio() freeing a qio into a destroyed pool Denis V. Lunev
2026-11-23 15:41   ` no-reply
2026-11-23 15:36 ` [Devel] [PATCH hci-8.2 v2 3/8] dm-qcow2: fix queue_work() after the target or image is freed Denis V. Lunev
2026-11-23 15:42   ` no-reply
2026-11-23 15:36 ` [Devel] [PATCH hci-8.2 v2 4/8] dm-qcow2: fix service_qio_endio() waking a freed target Denis V. Lunev
2026-11-23 15:43   ` no-reply
2026-11-23 15:36 ` Denis V. Lunev [this message]
2026-11-23 15:45   ` [Devel] [PATCH hci-8.2 v2 5/8] dm-qcow2: fix qcow2_flush_deferred_activity() skipping a running timer no-reply
2026-11-23 15:36 ` [Devel] [PATCH hci-8.2 v2 6/8] dm-qcow2: stop slow_wb_timer and flush the workers before freeing an image Denis V. Lunev
2026-11-23 15:45   ` no-reply
2026-11-23 15:36 ` [Devel] [PATCH hci-8.2 v2 7/8] dm-qcow2: cancel the backward merge before destroying the workqueue Denis V. Lunev
2026-11-23 15:47   ` no-reply
2026-11-23 15:36 ` [Devel] [PATCH hci-8.2 v2 8/8] dm-qcow2: flush the backward merge work before freeing the target Denis V. Lunev
2026-11-23 15:48   ` no-reply
2026-11-24 10:57 ` [Devel] [PATCH hci-8.2 v2 0/8] dm-qcow2: fix image I/O completions using a freed target Alexander Ivanov
2026-11-30 16:14 ` 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=20261123153640.128227-6-den@openvz.org \
    --to=den@openvz.org \
    --cc=alexander.ivanov@virtuozzo.com \
    --cc=andrey.zhadchenko@virtuozzo.com \
    --cc=devel@openvz.org \
    --cc=vasileios.almpanis@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