[Devel] [PATCH hci-8.2 7/9] dm-qcow2: requeue requests when the request pool is empty

Denis V. Lunev den at openvz.org
Wed Nov 25 04:25:23 MSK 2026


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

The request pool was sized at twice mq-deadline's default nr_requests
of 2 * min(depth, BLKDEV_DEFAULT_RQ). With the default single hardware
queue, even a request from every tag could not exhaust the reserve.

Without a scheduler the device has dm_mq_queue_depth tags per hardware
queue. If GFP_ATOMIC slab allocation fails with more requests in flight
than the reserve can cover, qcow2_clone_and_map() kills the next request
and the guest gets an I/O error. Return DM_MAPIO_REQUEUE so blk-mq
applies backpressure and retries the request when resources free up.

https://virtuozzo.atlassian.net/browse/VSTOR-95494
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 | 2 +-
 drivers/md/dm-qcow2.h     | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
index d1dec85236b8..c450d1de5689 100644
--- a/drivers/md/dm-qcow2-map.c
+++ b/drivers/md/dm-qcow2-map.c
@@ -4938,7 +4938,7 @@ int qcow2_clone_and_map(struct dm_target *ti, struct request *rq,
 
 	qrq = mempool_alloc(tgt->qrq_pool, GFP_ATOMIC);
 	if (!qrq)
-		return DM_MAPIO_KILL;
+		return DM_MAPIO_REQUEUE;
 	qio = (void *)qrq + sizeof(*qrq);
 	init_qrq_and_embedded_qio(tgt, rq, qrq, qio);
 
diff --git a/drivers/md/dm-qcow2.h b/drivers/md/dm-qcow2.h
index accac35fa345..dce623ccc78e 100644
--- a/drivers/md/dm-qcow2.h
+++ b/drivers/md/dm-qcow2.h
@@ -193,7 +193,8 @@ struct qcow2_backward_merge {
 
 struct qcow2_target {
 	struct dm_target *ti;
-#define QCOW2_QRQ_POOL_SIZE 512 /* Twice nr_requests from blk_mq_init_sched() */
+/* Reserve to keep requests moving when slab allocations fail. */
+#define QCOW2_QRQ_POOL_SIZE 512
 	mempool_t *qrq_pool;
 	mempool_t *qio_pool;
 	/*
-- 
2.55.0



More information about the Devel mailing list