Skip to content

Commit

Permalink
blk-mq: split out tag initialization, support shared tags
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Christoph Hellwig authored and axboe committed Apr 15, 2014
1 parent ed44832 commit 24d2f90
Show file tree
Hide file tree
Showing 8 changed files with 262 additions and 200 deletions.
6 changes: 3 additions & 3 deletions block/blk-mq-cpumap.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@ int blk_mq_update_queue_map(unsigned int *map, unsigned int nr_queues)
return 0;
}

unsigned int *blk_mq_make_queue_map(struct blk_mq_reg *reg)
unsigned int *blk_mq_make_queue_map(struct blk_mq_tag_set *set)
{
unsigned int *map;

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

if (!blk_mq_update_queue_map(map, reg->nr_hw_queues))
if (!blk_mq_update_queue_map(map, set->nr_hw_queues))
return map;

kfree(map);
Expand Down
14 changes: 0 additions & 14 deletions block/blk-mq-tag.c
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/percpu_ida.h>

#include <linux/blk-mq.h>
#include "blk.h"
#include "blk-mq.h"
#include "blk-mq-tag.h"

/*
* Per tagged queue (tag address space) map
*/
struct blk_mq_tags {
unsigned int nr_tags;
unsigned int nr_reserved_tags;
unsigned int nr_batch_move;
unsigned int nr_max_cache;

struct percpu_ida free_tags;
struct percpu_ida reserved_tags;
};

void blk_mq_wait_for_tags(struct blk_mq_tags *tags)
{
int tag = blk_mq_get_tag(tags, __GFP_WAIT, false);
Expand Down
19 changes: 18 additions & 1 deletion block/blk-mq-tag.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
#ifndef INT_BLK_MQ_TAG_H
#define INT_BLK_MQ_TAG_H

struct blk_mq_tags;
#include <linux/percpu_ida.h>

/*
* Tag address space map.
*/
struct blk_mq_tags {
unsigned int nr_tags;
unsigned int nr_reserved_tags;
unsigned int nr_batch_move;
unsigned int nr_max_cache;

struct percpu_ida free_tags;
struct percpu_ida reserved_tags;

struct request **rqs;
struct list_head page_list;
};


extern struct blk_mq_tags *blk_mq_init_tags(unsigned int nr_tags, unsigned int reserved_tags, int node);
extern void blk_mq_free_tags(struct blk_mq_tags *tags);
Expand Down
Loading

0 comments on commit 24d2f90

Please sign in to comment.