Skip to content

Commit 3f0bea9

Browse files
hailan94axboe
authored andcommitted
blk-mq-debugfs: factor out a helper to register debugfs for all rq_qos
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>
1 parent 41afaee commit 3f0bea9

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

block/blk-mq-debugfs.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -631,14 +631,7 @@ void blk_mq_debugfs_register(struct request_queue *q)
631631
blk_mq_debugfs_register_hctx(q, hctx);
632632
}
633633

634-
if (q->rq_qos) {
635-
struct rq_qos *rqos = q->rq_qos;
636-
637-
while (rqos) {
638-
blk_mq_debugfs_register_rqos(rqos);
639-
rqos = rqos->next;
640-
}
641-
}
634+
blk_mq_debugfs_register_rq_qos(q);
642635
}
643636

644637
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)
769762
debugfs_create_files(rqos->debugfs_dir, rqos, rqos->ops->debugfs_attrs);
770763
}
771764

765+
void blk_mq_debugfs_register_rq_qos(struct request_queue *q)
766+
{
767+
lockdep_assert_held(&q->debugfs_mutex);
768+
769+
if (q->rq_qos) {
770+
struct rq_qos *rqos = q->rq_qos;
771+
772+
while (rqos) {
773+
blk_mq_debugfs_register_rqos(rqos);
774+
rqos = rqos->next;
775+
}
776+
}
777+
}
778+
772779
void blk_mq_debugfs_register_sched_hctx(struct request_queue *q,
773780
struct blk_mq_hw_ctx *hctx)
774781
{

block/blk-mq-debugfs.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ void blk_mq_debugfs_register_sched_hctx(struct request_queue *q,
3333
struct blk_mq_hw_ctx *hctx);
3434
void blk_mq_debugfs_unregister_sched_hctx(struct blk_mq_hw_ctx *hctx);
3535

36+
void blk_mq_debugfs_register_rq_qos(struct request_queue *q);
3637
void blk_mq_debugfs_register_rqos(struct rq_qos *rqos);
3738
void blk_mq_debugfs_unregister_rqos(struct rq_qos *rqos);
3839
#else
@@ -78,6 +79,10 @@ static inline void blk_mq_debugfs_register_rqos(struct rq_qos *rqos)
7879
{
7980
}
8081

82+
static inline void blk_mq_debugfs_register_rq_qos(struct request_queue *q)
83+
{
84+
}
85+
8186
static inline void blk_mq_debugfs_unregister_rqos(struct rq_qos *rqos)
8287
{
8388
}

0 commit comments

Comments
 (0)