Skip to contentSkip to conversation

blk-mq: Take tagset lock when updaing hw queues

PATCH In review Keith Busch 3 participants 3 messages May 30, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 blk-mq: Take tagset lock when updaing 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 705cda97e ("blk-mq: Make it safe to use RCU to iterate over blk_mq_tag_set.tag_list")
---
 block/blk-mq.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
block/blk-mq.c +9 -1
index f2224ffd..1bccced 100644
@@ -2641,7 +2641,8 @@ int blk_mq_update_nr_requests(struct request_queue *q, unsigned int nr)
 	return ret;
 }
 
-void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, int nr_hw_queues)
+static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
+							int nr_hw_queues)
 {
 	struct request_queue *q;
 
@@ -2665,6 +2666,13 @@ void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, int nr_hw_queues)
 	list_for_each_entry(q, &set->tag_list, tag_set_list)
 		blk_mq_unfreeze_queue(q);
 }
+
+void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, int nr_hw_queues)
+{
+	mutex_lock(&set->tag_list_lock);
+	__blk_mq_update_nr_hw_queues(set, nr_hw_queues);
+	mutex_unlock(&set->tag_list_lock);
+}
 EXPORT_SYMBOL_GPL(blk_mq_update_nr_hw_queues);
 
 /* Enable polling stats and return whether they were already enabled. */
Signature · 1 line
2.5.5
maintainer
#1 lore raw
Quoted 7 lines · Keith Busch

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.

Thanks Keith, applied for 4.12 with the typo in the subject line fixed up.

Signature · 1 line
Jens Axboe
Tested-by on v1 1/1
#2 lore raw
In reply to Keith Busch
Quoted 5 lines · Keith Busch

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.

Quoted 8 lines

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 705cda97e ("blk-mq: Make it safe to use RCU to iterate over blk_mq_tag_set.tag_list")

I know it is already applied but, FWIW, I can confirm it fixed the issue in our CI. Feel free to add:

Thanks again, Keith.

Signature · 1 line
Gabriel Krisman Bertazi