Skip to content

Commit 24d2f90

Browse files
Christoph Hellwigaxboe
authored andcommitted
blk-mq: split out tag initialization, support shared tags
Add a new blk_mq_tag_set structure that gets set up before we initialize the queue. A single blk_mq_tag_set structure can be shared by multiple queues. Signed-off-by: Christoph Hellwig <hch@lst.de> Modular export of blk_mq_{alloc,free}_tagset added by me. Signed-off-by: Jens Axboe <axboe@fb.com>
1 parent ed44832 commit 24d2f90

8 files changed

Lines changed: 262 additions & 200 deletions

File tree

‎block/blk-mq-cpumap.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,17 @@ int blk_mq_update_queue_map(unsigned int *map, unsigned int nr_queues)
8080
return 0;
8181
}
8282

83-
unsigned int *blk_mq_make_queue_map(struct blk_mq_reg *reg)
83+
unsigned int *blk_mq_make_queue_map(struct blk_mq_tag_set *set)
8484
{
8585
unsigned int *map;
8686

8787
/* If cpus are offline, map them to first hctx */
8888
map = kzalloc_node(sizeof(*map) * num_possible_cpus(), GFP_KERNEL,
89-
reg->numa_node);
89+
set->numa_node);
9090
if (!map)
9191
return NULL;
9292

93-
if (!blk_mq_update_queue_map(map, reg->nr_hw_queues))
93+
if (!blk_mq_update_queue_map(map, set->nr_hw_queues))
9494
return map;
9595

9696
kfree(map);

‎block/blk-mq-tag.c‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,11 @@
11
#include <linux/kernel.h>
22
#include <linux/module.h>
3-
#include <linux/percpu_ida.h>
43

54
#include <linux/blk-mq.h>
65
#include "blk.h"
76
#include "blk-mq.h"
87
#include "blk-mq-tag.h"
98

10-
/*
11-
* Per tagged queue (tag address space) map
12-
*/
13-
struct blk_mq_tags {
14-
unsigned int nr_tags;
15-
unsigned int nr_reserved_tags;
16-
unsigned int nr_batch_move;
17-
unsigned int nr_max_cache;
18-
19-
struct percpu_ida free_tags;
20-
struct percpu_ida reserved_tags;
21-
};
22-
239
void blk_mq_wait_for_tags(struct blk_mq_tags *tags)
2410
{
2511
int tag = blk_mq_get_tag(tags, __GFP_WAIT, false);

‎block/blk-mq-tag.h‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
11
#ifndef INT_BLK_MQ_TAG_H
22
#define INT_BLK_MQ_TAG_H
33

4-
struct blk_mq_tags;
4+
#include <linux/percpu_ida.h>
5+
6+
/*
7+
* Tag address space map.
8+
*/
9+
struct blk_mq_tags {
10+
unsigned int nr_tags;
11+
unsigned int nr_reserved_tags;
12+
unsigned int nr_batch_move;
13+
unsigned int nr_max_cache;
14+
15+
struct percpu_ida free_tags;
16+
struct percpu_ida reserved_tags;
17+
18+
struct request **rqs;
19+
struct list_head page_list;
20+
};
21+
522

623
extern struct blk_mq_tags *blk_mq_init_tags(unsigned int nr_tags, unsigned int reserved_tags, int node);
724
extern void blk_mq_free_tags(struct blk_mq_tags *tags);

0 commit comments

Comments
 (0)