@@ -4429,6 +4429,18 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)
}
EXPORT_SYMBOL(blk_mq_alloc_tag_set);
+int blk_mq_init_alloc_tag_set(struct blk_mq_tag_set *set,
+ const struct blk_mq_ops *ops, unsigned int nr_hw_queues,
+ unsigned int queue_depth, void *driver_data)
+{
+ set->ops = ops;
+ set->nr_hw_queues = nr_hw_queues;
+ set->queue_depth = queue_depth;
+ set->driver_data = driver_data;
+ return blk_mq_alloc_tag_set(set);
+}
+EXPORT_SYMBOL_GPL(blk_mq_init_alloc_tag_set);
+
/* allocate and initialize a tagset for a simple single-queue device */
int blk_mq_alloc_sq_tag_set(struct blk_mq_tag_set *set,
const struct blk_mq_ops *ops, unsigned int queue_depth,
@@ -1926,12 +1926,8 @@ static int null_init_tag_set(struct nullb *nullb, struct blk_mq_tag_set *set)
flags |= BLK_MQ_F_BLOCKING;
}
- set->ops = &null_mq_ops;
set->cmd_size = sizeof(struct nullb_cmd);
set->flags = flags;
- set->driver_data = nullb;
- set->nr_hw_queues = hw_queues;
- set->queue_depth = queue_depth;
set->numa_node = numa_node;
if (poll_queues) {
set->nr_hw_queues += poll_queues;
@@ -1940,7 +1936,8 @@ static int null_init_tag_set(struct nullb *nullb, struct blk_mq_tag_set *set)
set->nr_maps = 1;
}
- return blk_mq_alloc_tag_set(set);
+ return blk_mq_init_alloc_tag_set(set, &null_mq_ops, hw_queues,
+ queue_depth, nullb);
}
static int null_validate_conf(struct nullb_device *dev)
@@ -707,7 +707,9 @@ struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *);
int blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
struct request_queue *q);
void blk_mq_destroy_queue(struct request_queue *);
-
+int blk_mq_init_alloc_tag_set(struct blk_mq_tag_set *set,
+ const struct blk_mq_ops *ops, unsigned int nr_hw_queues,
+ unsigned int queue_depth, void *driver_data);
int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set);
int blk_mq_alloc_sq_tag_set(struct blk_mq_tag_set *set,
const struct blk_mq_ops *ops, unsigned int queue_depth,
Add and use a helper to initialize the common fields of the tag_set. The newly added helper blk_mq_init_alloc_tag_set() replaces existing call to blk_mq_alloc_tag_set() and takes following arguments to initialize tag_set before calling blk_mq_alloc_tag_set() :- * blk_mq_ops * number of h/w queues * queue depth * driver data The number of arguments to the new API are similar to the existing API blk_mq_alloc_sq_tag_set() used in block layer to eliminate the common code to initialize and allocate tag_set. This initialization is spread all over the block drivers. This avoids code repetation of inialization code of tag set in current block drivers and any future ones. Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com> --- block/blk-mq.c | 12 ++++++++++++ drivers/block/null_blk/main.c | 7 ++----- include/linux/blk-mq.h | 4 +++- 3 files changed, 17 insertions(+), 6 deletions(-)