Skip to content

Commit 0da73d0

Browse files
minwooimaxboe
authored andcommitted
blk-mq: code clean-up by adding an API to clear set->mq_map
set->mq_map is now currently cleared if something goes wrong when establishing a queue map in blk-mq-pci.c. It's also cleared before updating a queue map in blk_mq_update_queue_map(). This patch provides an API to clear set->mq_map to make it clear. Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 5efac89 commit 0da73d0

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

block/blk-mq-pci.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include <linux/pci.h>
1818
#include <linux/module.h>
1919

20+
#include "blk-mq.h"
21+
2022
/**
2123
* blk_mq_pci_map_queues - provide a default queue mapping for PCI device
2224
* @set: tagset to provide the mapping for
@@ -48,8 +50,7 @@ int blk_mq_pci_map_queues(struct blk_mq_tag_set *set, struct pci_dev *pdev,
4850

4951
fallback:
5052
WARN_ON_ONCE(set->nr_hw_queues > 1);
51-
for_each_possible_cpu(cpu)
52-
set->mq_map[cpu] = 0;
53+
blk_mq_clear_mq_map(set);
5354
return 0;
5455
}
5556
EXPORT_SYMBOL_GPL(blk_mq_pci_map_queues);

block/blk-mq.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2683,7 +2683,6 @@ static int blk_mq_alloc_rq_maps(struct blk_mq_tag_set *set)
26832683
static int blk_mq_update_queue_map(struct blk_mq_tag_set *set)
26842684
{
26852685
if (set->ops->map_queues) {
2686-
int cpu;
26872686
/*
26882687
* transport .map_queues is usually done in the following
26892688
* way:
@@ -2698,8 +2697,7 @@ static int blk_mq_update_queue_map(struct blk_mq_tag_set *set)
26982697
* killing stale mapping since one CPU may not be mapped
26992698
* to any hw queue.
27002699
*/
2701-
for_each_possible_cpu(cpu)
2702-
set->mq_map[cpu] = 0;
2700+
blk_mq_clear_mq_map(set);
27032701

27042702
return set->ops->map_queues(set);
27052703
} else

block/blk-mq.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,12 @@ static inline void blk_mq_put_driver_tag(struct request *rq)
202202
__blk_mq_put_driver_tag(hctx, rq);
203203
}
204204

205+
static inline void blk_mq_clear_mq_map(struct blk_mq_tag_set *set)
206+
{
207+
int cpu;
208+
209+
for_each_possible_cpu(cpu)
210+
set->mq_map[cpu] = 0;
211+
}
212+
205213
#endif

0 commit comments

Comments
 (0)