[Devel] [PATCH hci-8.2 2/2] dm-qcow2: queue the worker before dropping deferred_lock in completions
Denis V. Lunev
den at openvz.org
Thu Nov 19 14:49:14 MSK 2026
From: Denis V. Lunev <den at openvz.org>
qcow2_dispatch_qios(), qcow2_queue_resubmit() and
md_page_write_complete() add a qio to a worker list under
deferred_lock, drop the lock and only then queue the worker. Called
from an image I/O completion, they let the worker take the qio in that
gap and end it, and suspend and a dmsetup remove can then destroy
tgt->wq before queue_work() runs on it. A backward merge has the same
gap without a remove: qcow2_merge_backward_complete() frees the merged
image, and with it the qcow2->worker that the late queue_work() uses.
Queue the worker before dropping the lock. The worker takes its lists
under the same lock, so the qio, and the inflight reference it holds,
outlive the queue_work() call.
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 at openvz.org>
---
drivers/md/dm-qcow2-map.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
index ec07bcce6150..1b1367bb2ef8 100644
--- a/drivers/md/dm-qcow2-map.c
+++ b/drivers/md/dm-qcow2-map.c
@@ -463,9 +463,8 @@ void qcow2_dispatch_qios(struct qcow2 *qcow2, struct qio *qio,
qcow2_dispatch_qio(qcow2, qio);
}
- spin_unlock_irqrestore(&qcow2->deferred_lock, flags);
-
queue_work(qcow2->tgt->wq, &qcow2->worker);
+ spin_unlock_irqrestore(&qcow2->deferred_lock, flags);
}
static void end_qios(struct list_head *qio_list, blk_status_t status)
@@ -1584,8 +1583,8 @@ static void md_page_write_complete(struct qio *qio)
qio->queue_list_id = QLIST_COMPLETED_WB;
spin_lock_irqsave(&qcow2->deferred_lock, flags);
list_add_tail(&qio->link, &qcow2->qios[QLIST_COMPLETED_WB]);
- spin_unlock_irqrestore(&qcow2->deferred_lock, flags);
queue_work(qcow2->tgt->wq, &qcow2->fsync_worker);
+ spin_unlock_irqrestore(&qcow2->deferred_lock, flags);
}
static void submit_rw_md_page(unsigned int rw, struct qcow2 *qcow2,
@@ -3003,8 +3002,8 @@ static void qcow2_queue_resubmit(struct qio *qio)
spin_lock_irqsave(&qcow2->deferred_lock, flags);
list_add_tail(&qio->link, &qcow2->resubmit_qios);
- spin_unlock_irqrestore(&qcow2->deferred_lock, flags);
queue_work(qcow2->tgt->wq, &qcow2->worker);
+ spin_unlock_irqrestore(&qcow2->deferred_lock, flags);
}
static void data_rw_complete(struct qio *qio)
--
2.55.0
More information about the Devel
mailing list