]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
blk-mq-debugfs: factor out a helper to register debugfs for all rq_qos
authorYu Kuai <yukuai@fnnas.com>
Mon, 2 Feb 2026 08:05:18 +0000 (16:05 +0800)
committerJens Axboe <axboe@kernel.dk>
Mon, 2 Feb 2026 14:05:19 +0000 (07:05 -0700)
There is already a helper blk_mq_debugfs_register_rqos() to register
one rqos, however this helper is called synchronously when the rqos is
created with queue frozen.

Prepare to fix possible deadlock to create blk-mq debugfs entries while
queue is still frozen.

Reviewed-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Nilay Shroff <nilay@linux.ibm.com>
Signed-off-by: Yu Kuai <yukuai@fnnas.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-mq-debugfs.c
block/blk-mq-debugfs.h

index 4896525b1c0541d21c978f53287238dc88e4b2a1..4fe164b6d6483984a6937bb3012fecc4bdf3670c 100644 (file)
@@ -631,14 +631,7 @@ void blk_mq_debugfs_register(struct request_queue *q)
                        blk_mq_debugfs_register_hctx(q, hctx);
        }
 
-       if (q->rq_qos) {
-               struct rq_qos *rqos = q->rq_qos;
-
-               while (rqos) {
-                       blk_mq_debugfs_register_rqos(rqos);
-                       rqos = rqos->next;
-               }
-       }
+       blk_mq_debugfs_register_rq_qos(q);
 }
 
 static void blk_mq_debugfs_register_ctx(struct blk_mq_hw_ctx *hctx,
@@ -769,6 +762,20 @@ void blk_mq_debugfs_register_rqos(struct rq_qos *rqos)
        debugfs_create_files(rqos->debugfs_dir, rqos, rqos->ops->debugfs_attrs);
 }
 
+void blk_mq_debugfs_register_rq_qos(struct request_queue *q)
+{
+       lockdep_assert_held(&q->debugfs_mutex);
+
+       if (q->rq_qos) {
+               struct rq_qos *rqos = q->rq_qos;
+
+               while (rqos) {
+                       blk_mq_debugfs_register_rqos(rqos);
+                       rqos = rqos->next;
+               }
+       }
+}
+
 void blk_mq_debugfs_register_sched_hctx(struct request_queue *q,
                                        struct blk_mq_hw_ctx *hctx)
 {
index c80e453e301453a67873fa55d4374f96b64947c7..54948a26688995add9c0edc85818831eafad77b4 100644 (file)
@@ -33,6 +33,7 @@ void blk_mq_debugfs_register_sched_hctx(struct request_queue *q,
                                       struct blk_mq_hw_ctx *hctx);
 void blk_mq_debugfs_unregister_sched_hctx(struct blk_mq_hw_ctx *hctx);
 
+void blk_mq_debugfs_register_rq_qos(struct request_queue *q);
 void blk_mq_debugfs_register_rqos(struct rq_qos *rqos);
 void blk_mq_debugfs_unregister_rqos(struct rq_qos *rqos);
 #else
@@ -78,6 +79,10 @@ static inline void blk_mq_debugfs_register_rqos(struct rq_qos *rqos)
 {
 }
 
+static inline void blk_mq_debugfs_register_rq_qos(struct request_queue *q)
+{
+}
+
 static inline void blk_mq_debugfs_unregister_rqos(struct rq_qos *rqos)
 {
 }