[Devel] [PATCH hci-8.2 v2 7/8] dm-qcow2: cancel the backward merge before destroying the workqueue
Denis V. Lunev
den at openvz.org
Mon Nov 23 18:36:39 MSK 2026
From: Denis V. Lunev <den at openvz.org>
qcow2_tgt_destroy() cancels the backward merge only after it has
flushed the images and destroyed tgt->wq. A merge still running there
would dispatch its service qios to the destroyed workqueue and to
images whose deferred activity was already flushed. DM suspends a
target before destroying it, and presuspend already cancels the merge,
so this does not happen today; cancel it first anyway, so that the
teardown does not depend on that.
tgt->wq is never NULL here, since alloc_qcow2_target() fails without
it, so drop the check.
https://virtuozzo.atlassian.net/browse/VSTOR-156036
Feature: dm-qcow2: block device over QCOW2 files driver
Signed-off-by: Denis V. Lunev <den at openvz.org>
---
drivers/md/dm-qcow2-target.c | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/drivers/md/dm-qcow2-target.c b/drivers/md/dm-qcow2-target.c
index d5e94753ddbb..9c173e1dce87 100644
--- a/drivers/md/dm-qcow2-target.c
+++ b/drivers/md/dm-qcow2-target.c
@@ -241,24 +241,22 @@ void qcow2_destroy(struct qcow2 *qcow2)
static void qcow2_tgt_destroy(struct qcow2_target *tgt)
{
- struct qcow2 *lower, *qcow2 = tgt->top;
+ struct qcow2 *lower, *qcow2;
unsigned int i;
+ qcow2_merge_backward_cancel(tgt);
timer_shutdown_sync(&tgt->enospc_timer);
- if (tgt->wq) {
- /*
- * All activity from DM bios are already done,
- * since DM waits them. Complete our deferred:
- */
- qcow2_flush_deferred_activity_all(tgt);
- for (qcow2 = tgt->top; qcow2; qcow2 = qcow2->lower)
- timer_shutdown_sync(&qcow2->slow_wb_timer);
- /* Now kill the queue */
- destroy_workqueue(tgt->wq);
- }
+ /*
+ * All activity from DM bios are already done,
+ * since DM waits them. Complete our deferred:
+ */
+ qcow2_flush_deferred_activity_all(tgt);
+ for (qcow2 = tgt->top; qcow2; qcow2 = qcow2->lower)
+ timer_shutdown_sync(&qcow2->slow_wb_timer);
+ /* Now kill the queue */
+ destroy_workqueue(tgt->wq);
cancel_work_sync(&tgt->event_work);
- qcow2_merge_backward_cancel(tgt);
mempool_destroy(tgt->qio_pool);
mempool_destroy(tgt->qrq_pool);
--
2.55.0
More information about the Devel
mailing list