Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

blk-rq-qos: fix possible debugfs_mutex deadlock

Currently rq-qos debugfs entries are created from rq_qos_add(), while
rq_qos_add() can be called while queue is still frozen. This can
deadlock because creating new entries can trigger fs reclaim.

Fix this problem by delaying creating rq-qos debugfs entries after queue
is unfrozen.

- For wbt, 1) it can be initialized by default, fix it by calling new
helper after wbt_init() from wbt_init_enable_default(); 2) it can be
initialized by sysfs, fix it by calling new helper after queue is
unfrozen from wbt_set_lat().
- For iocost and iolatency, they can only be initialized by blkcg
configuration, however, they don't have debugfs entries for now, hence
they are not handled yet.

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

authored by

Yu Kuai and committed by
Jens Axboe
3c17a346 3f0bea9f

+12 -8
-7
block/blk-rq-qos.c
··· 347 347 blk_queue_flag_set(QUEUE_FLAG_QOS_ENABLED, q); 348 348 349 349 blk_mq_unfreeze_queue(q, memflags); 350 - 351 - if (rqos->ops->debugfs_attrs) { 352 - mutex_lock(&q->debugfs_mutex); 353 - blk_mq_debugfs_register_rqos(rqos); 354 - mutex_unlock(&q->debugfs_mutex); 355 - } 356 - 357 350 return 0; 358 351 ebusy: 359 352 blk_mq_unfreeze_queue(q, memflags);
+12 -1
block/blk-wbt.c
··· 774 774 775 775 void wbt_init_enable_default(struct gendisk *disk) 776 776 { 777 + struct request_queue *q = disk->queue; 777 778 struct rq_wb *rwb; 778 779 779 780 if (!__wbt_enable_default(disk)) ··· 784 783 if (WARN_ON_ONCE(!rwb)) 785 784 return; 786 785 787 - if (WARN_ON_ONCE(wbt_init(disk, rwb))) 786 + if (WARN_ON_ONCE(wbt_init(disk, rwb))) { 788 787 wbt_free(rwb); 788 + return; 789 + } 790 + 791 + mutex_lock(&q->debugfs_mutex); 792 + blk_mq_debugfs_register_rq_qos(q); 793 + mutex_unlock(&q->debugfs_mutex); 789 794 } 790 795 791 796 static u64 wbt_default_latency_nsec(struct request_queue *q) ··· 1015 1008 blk_mq_unquiesce_queue(q); 1016 1009 out: 1017 1010 blk_mq_unfreeze_queue(q, memflags); 1011 + mutex_lock(&q->debugfs_mutex); 1012 + blk_mq_debugfs_register_rq_qos(q); 1013 + mutex_unlock(&q->debugfs_mutex); 1014 + 1018 1015 return ret; 1019 1016 }