Skip to contentSkip to conversation

block: fix rq_qos leak for bio based queue

PATCH In review Ming Lei 2 participants 4 messages Jun 14, 2022 Block layer

lore
Share & tools
lore

Ming Lei

author
#0 lore raw

PATCH 1/1 block: fix rq_qos leak for bio based queue

Commit 5ca7546fe317 ("block: move rq_qos_exit() into disk_release()") moves rq_qos_exit() to disk_release(), but only done for blk-mq queue.

However, now rq qos can be created via blkcg_init_queue() for bio based queue, so we need to call rq_qos_exit() for bio queue too.

In theory, so far, rq_qos is only implemented for request based queue, and we should only add it for blk-mq queue. However, if using blk-mq during allocating queue may not be known, fix the rq qos leak issue by always releasing rq qos for both two kinds of queues.

Fixes 285d5731a0cb ('Revert "block: release rq qos structures for queue without disk"')
---
 block/genhd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
block/genhd.c +4 -4
index 556d6e4b38d9..6e7ca8c302aa 100644
@@ -1120,9 +1120,10 @@ static const struct attribute_group *disk_attr_groups[] = {
 	NULL
 };
 
-static void disk_release_mq(struct request_queue *q)
+static void disk_release_queue(struct request_queue *q)
 {
-	blk_mq_cancel_work_sync(q);
+	if (queue_is_mq(q))
+		blk_mq_cancel_work_sync(q);
 
 	/*
 	 * There can't be any non non-passthrough bios in flight here, but
@@ -1166,8 +1167,7 @@ static void disk_release(struct device *dev)
 	might_sleep();
 	WARN_ON_ONCE(disk_live(disk));
 
-	if (queue_is_mq(disk->queue))
-		disk_release_mq(disk->queue);
+	disk_release_queue(disk->queue);
 
 	blkcg_exit_queue(disk->queue);
 
Signature · 1 line
2.31.1
#1 lore raw
Quoted 10 lines · Ming Lei

Commit 5ca7546fe317 ("block: move rq_qos_exit() into disk_release()") moves rq_qos_exit() to disk_release(), but only done for blk-mq queue.

However, now rq qos can be created via blkcg_init_queue() for bio based queue, so we need to call rq_qos_exit() for bio queue too.

In theory, so far, rq_qos is only implemented for request based queue, and we should only add it for blk-mq queue. However, if using blk-mq during allocating queue may not be known, fix the rq qos leak issue by always releasing rq qos for both two kinds of queues.

This is also fixed by "block: disable the elevator int del_gendisk" which was just resent yesterday, and fundamentally gets the lifetimes right rather than doctoring around even more.

author
#2 lore raw
Quoted 7 lines · Christoph Hellwig
Quoted 6 lines · Ming Lei

Commit 5ca7546fe317 ("block: move rq_qos_exit() into disk_release()") moves rq_qos_exit() to disk_release(), but only done for blk-mq queue.

However, now rq qos can be created via blkcg_init_queue() for bio based queue, so we need to call rq_qos_exit() for bio queue too.

Quoted 8 lines
Quoted 4 lines

In theory, so far, rq_qos is only implemented for request based queue, and we should only add it for blk-mq queue. However, if using blk-mq during allocating queue may not be known, fix the rq qos leak issue by always releasing rq qos for both two kinds of queues.

This is also fixed by "block: disable the elevator int del_gendisk" which was just resent yesterday, and fundamentally gets the lifetimes right rather than doctoring around even more.

Just checked my block mbox and lore, not see the patch sent from yesterday.

Thanks,
Ming

#3 lore raw
Quoted 2 lines · Ming Lei

Just checked my block mbox and lore, not see the patch sent from yesterday.

Hmm, weird. vger had some odd hickups the last last days, but you also were Cced personally. I'll resend it.