[Devel] [PATCH hci-8.2 9/9] dm: default dm-qcow2 devices to no I/O scheduler

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


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

Request-based dm has one hardware queue by default, so it gets
mq-deadline. On that queue mq-deadline caps requests in flight at 256
by default (2 * min(depth, BLKDEV_DEFAULT_RQ)) and serialises insert
and dispatch on its lock. The cost grows with queue depth and the
number of submitters. Sorting by device sector buys little for dm-qcow2
because adjacent guest sectors can be far apart in the image, and the
backing device can schedule the image I/O itself.

Set DM_TARGET_NO_SCHED_BY_DEFAULT on dm-qcow2. When the target in the
initial request-based table has this flag, dm_mq_init_request_queue()
sets BLK_MQ_F_NO_SCHED_BY_DEFAULT, as loop does, so elevator_set_default()
leaves the device with none.

mq-deadline arbitrates between I/O priority classes at dispatch. With
none, the dm device loses that arbitration. dm-qcow2 issues image I/O
from its workers, so the request's priority class does not reach the
backing device either. mq-deadline can still be selected through sysfs.

libploop creates qcow2 devices and ploop_dmcreate_stub() devices with a
zero-rq table and loads the real table later. Set the flag on zero-rq
as well because the scheduler is chosen when the device is created.

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-target.c  | 3 ++-
 drivers/md/dm-rq.c            | 2 ++
 drivers/md/dm-zero-rq.c       | 2 +-
 include/linux/device-mapper.h | 5 +++++
 4 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm-qcow2-target.c b/drivers/md/dm-qcow2-target.c
index af8a6d286830..3789fb191207 100644
--- a/drivers/md/dm-qcow2-target.c
+++ b/drivers/md/dm-qcow2-target.c
@@ -1274,7 +1274,8 @@ static void qcow2_resume(struct dm_target *ti)
 static struct target_type qcow2_target = {
 	.name = "qcow2",
 	.version = {1, 0, 0},
-	.features = DM_TARGET_SINGLETON | DM_TARGET_NOWAIT,
+	.features = DM_TARGET_SINGLETON | DM_TARGET_NOWAIT |
+		    DM_TARGET_NO_SCHED_BY_DEFAULT,
 	.module = THIS_MODULE,
 	.ctr = qcow2_ctr,
 	.dtr = qcow2_dtr,
diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c
index 0d31fcf84aed..af05ec40bf85 100644
--- a/drivers/md/dm-rq.c
+++ b/drivers/md/dm-rq.c
@@ -585,6 +585,8 @@ int dm_mq_init_request_queue(struct mapped_device *md, struct dm_table *t)
 	md->tag_set->queue_depth = dm_get_blk_mq_queue_depth();
 	md->tag_set->numa_node = md->numa_node_id;
 	md->tag_set->flags = BLK_MQ_F_STACKING;
+	if (dm_target_no_sched_by_default(dm_table_get_target(t, 0)->type))
+		md->tag_set->flags |= BLK_MQ_F_NO_SCHED_BY_DEFAULT;
 	md->tag_set->nr_hw_queues = dm_get_blk_mq_nr_hw_queues();
 	md->tag_set->driver_data = md;
 
diff --git a/drivers/md/dm-zero-rq.c b/drivers/md/dm-zero-rq.c
index 315ef8c930b3..3584e86e80e2 100644
--- a/drivers/md/dm-zero-rq.c
+++ b/drivers/md/dm-zero-rq.c
@@ -60,7 +60,7 @@ static int zero_clone_and_map_rq(struct dm_target *ti, struct request *rq,
 static struct target_type zero_target = {
 	.name   = "zero-rq",
 	.version = {1, 1, 0},
-	.features = DM_TARGET_NOWAIT,
+	.features = DM_TARGET_NOWAIT | DM_TARGET_NO_SCHED_BY_DEFAULT,
 	.module = THIS_MODULE,
 	.ctr    = zero_ctr,
 	.clone_and_map_rq = zero_clone_and_map_rq,
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
index 05715910fae9..1b131ef7060b 100644
--- a/include/linux/device-mapper.h
+++ b/include/linux/device-mapper.h
@@ -313,6 +313,11 @@ struct target_type {
 #define DM_TARGET_ATOMIC_WRITES		0x00000400
 #define dm_target_supports_atomic_writes(type) ((type)->features & DM_TARGET_ATOMIC_WRITES)
 
+/* Skip the default I/O scheduler for this request-based target. */
+#define DM_TARGET_NO_SCHED_BY_DEFAULT	0x00000800
+#define dm_target_no_sched_by_default(type) \
+		((type)->features & DM_TARGET_NO_SCHED_BY_DEFAULT)
+
 struct dm_target {
 	struct dm_table *table;
 	struct target_type *type;
-- 
2.55.0



More information about the Devel mailing list