Skip to content

Commit e4dc2b3

Browse files
Keith Buschaxboe
authored andcommitted
blk-mq: Take tagset lock when updating hw queues
The tagset lock needs to be held when iterating the tag_list, so a lockdep assert was added when updating number of hardware queues. The drivers calling this API, however, were unaware of the new requirement, so are failing the assertion. This patch takes the lock within the blk-mq function so the drivers do not have to be modified in order to be safe. Fixes: 705cda9 ("blk-mq: Make it safe to use RCU to iterate over blk_mq_tag_set.tag_list") Reported-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk> Reviewed-by: Bart Van Assche <Bart.VanAssche@sandisk.com> Signed-off-by: Keith Busch <keith.busch@intel.com> Signed-off-by: Jens Axboe <axboe@fb.com>
1 parent fa97653 commit e4dc2b3

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

block/blk-mq.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2641,7 +2641,8 @@ int blk_mq_update_nr_requests(struct request_queue *q, unsigned int nr)
26412641
return ret;
26422642
}
26432643

2644-
void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, int nr_hw_queues)
2644+
static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
2645+
int nr_hw_queues)
26452646
{
26462647
struct request_queue *q;
26472648

@@ -2665,6 +2666,13 @@ void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, int nr_hw_queues)
26652666
list_for_each_entry(q, &set->tag_list, tag_set_list)
26662667
blk_mq_unfreeze_queue(q);
26672668
}
2669+
2670+
void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, int nr_hw_queues)
2671+
{
2672+
mutex_lock(&set->tag_list_lock);
2673+
__blk_mq_update_nr_hw_queues(set, nr_hw_queues);
2674+
mutex_unlock(&set->tag_list_lock);
2675+
}
26682676
EXPORT_SYMBOL_GPL(blk_mq_update_nr_hw_queues);
26692677

26702678
/* Enable polling stats and return whether they were already enabled. */

0 commit comments

Comments
 (0)