Skip to content

Commit cdef54d

Browse files
Christoph Hellwigaxboe
authored andcommitted
blk-mq: remove alloc_hctx and free_hctx methods
There is no need for drivers to control hardware context allocation now that we do the context to node mapping in common code. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@fb.com>
1 parent 75bb462 commit cdef54d

4 files changed

Lines changed: 6 additions & 60 deletions

File tree

‎block/blk-mq.c‎

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,21 +1335,6 @@ struct blk_mq_hw_ctx *blk_mq_map_queue(struct request_queue *q, const int cpu)
13351335
}
13361336
EXPORT_SYMBOL(blk_mq_map_queue);
13371337

1338-
struct blk_mq_hw_ctx *blk_mq_alloc_single_hw_queue(struct blk_mq_tag_set *set,
1339-
unsigned int hctx_index,
1340-
int node)
1341-
{
1342-
return kzalloc_node(sizeof(struct blk_mq_hw_ctx), GFP_KERNEL, node);
1343-
}
1344-
EXPORT_SYMBOL(blk_mq_alloc_single_hw_queue);
1345-
1346-
void blk_mq_free_single_hw_queue(struct blk_mq_hw_ctx *hctx,
1347-
unsigned int hctx_index)
1348-
{
1349-
kfree(hctx);
1350-
}
1351-
EXPORT_SYMBOL(blk_mq_free_single_hw_queue);
1352-
13531338
static void blk_mq_free_rq_map(struct blk_mq_tag_set *set,
13541339
struct blk_mq_tags *tags, unsigned int hctx_idx)
13551340
{
@@ -1590,7 +1575,7 @@ static void blk_mq_free_hw_queues(struct request_queue *q,
15901575

15911576
queue_for_each_hw_ctx(q, hctx, i) {
15921577
free_cpumask_var(hctx->cpumask);
1593-
set->ops->free_hctx(hctx, i);
1578+
kfree(hctx);
15941579
}
15951580
}
15961581

@@ -1811,7 +1796,8 @@ struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *set)
18111796
for (i = 0; i < set->nr_hw_queues; i++) {
18121797
int node = blk_mq_hw_queue_to_node(map, i);
18131798

1814-
hctxs[i] = set->ops->alloc_hctx(set, i, node);
1799+
hctxs[i] = kzalloc_node(sizeof(struct blk_mq_hw_ctx),
1800+
GFP_KERNEL, node);
18151801
if (!hctxs[i])
18161802
goto err_hctxs;
18171803

@@ -1898,7 +1884,7 @@ struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *set)
18981884
if (!hctxs[i])
18991885
break;
19001886
free_cpumask_var(hctxs[i]->cpumask);
1901-
set->ops->free_hctx(hctxs[i], i);
1887+
kfree(hctxs[i]);
19021888
}
19031889
err_map:
19041890
kfree(hctxs);
@@ -1983,9 +1969,7 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)
19831969
if (set->queue_depth < set->reserved_tags + BLK_MQ_TAG_MIN)
19841970
return -EINVAL;
19851971

1986-
if (!set->nr_hw_queues ||
1987-
!set->ops->queue_rq || !set->ops->map_queue ||
1988-
!set->ops->alloc_hctx || !set->ops->free_hctx)
1972+
if (!set->nr_hw_queues || !set->ops->queue_rq || !set->ops->map_queue)
19891973
return -EINVAL;
19901974

19911975

‎drivers/block/null_blk.c‎

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -321,18 +321,6 @@ static int null_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *rq)
321321
return BLK_MQ_RQ_QUEUE_OK;
322322
}
323323

324-
static struct blk_mq_hw_ctx *null_alloc_hctx(struct blk_mq_tag_set *set,
325-
unsigned int hctx_index,
326-
int node)
327-
{
328-
return kzalloc_node(sizeof(struct blk_mq_hw_ctx), GFP_KERNEL, node);
329-
}
330-
331-
static void null_free_hctx(struct blk_mq_hw_ctx *hctx, unsigned int hctx_index)
332-
{
333-
kfree(hctx);
334-
}
335-
336324
static void null_init_queue(struct nullb *nullb, struct nullb_queue *nq)
337325
{
338326
BUG_ON(!nullb);
@@ -360,17 +348,6 @@ static struct blk_mq_ops null_mq_ops = {
360348
.map_queue = blk_mq_map_queue,
361349
.init_hctx = null_init_hctx,
362350
.complete = null_softirq_done_fn,
363-
.alloc_hctx = blk_mq_alloc_single_hw_queue,
364-
.free_hctx = blk_mq_free_single_hw_queue,
365-
};
366-
367-
static struct blk_mq_ops null_mq_ops_pernode = {
368-
.queue_rq = null_queue_rq,
369-
.map_queue = blk_mq_map_queue,
370-
.init_hctx = null_init_hctx,
371-
.complete = null_softirq_done_fn,
372-
.alloc_hctx = null_alloc_hctx,
373-
.free_hctx = null_free_hctx,
374351
};
375352

376353
static void null_del_dev(struct nullb *nullb)
@@ -496,10 +473,7 @@ static int null_add_dev(void)
496473
goto out_free_nullb;
497474

498475
if (queue_mode == NULL_Q_MQ) {
499-
if (use_per_node_hctx)
500-
nullb->tag_set.ops = &null_mq_ops_pernode;
501-
else
502-
nullb->tag_set.ops = &null_mq_ops;
476+
nullb->tag_set.ops = &null_mq_ops;
503477
nullb->tag_set.nr_hw_queues = submit_queues;
504478
nullb->tag_set.queue_depth = hw_queue_depth;
505479
nullb->tag_set.numa_node = home_node;

‎drivers/block/virtio_blk.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,6 @@ static int virtblk_init_request(void *data, struct request *rq,
497497
static struct blk_mq_ops virtio_mq_ops = {
498498
.queue_rq = virtio_queue_rq,
499499
.map_queue = blk_mq_map_queue,
500-
.alloc_hctx = blk_mq_alloc_single_hw_queue,
501-
.free_hctx = blk_mq_free_single_hw_queue,
502500
.complete = virtblk_request_done,
503501
.init_request = virtblk_init_request,
504502
};

‎include/linux/blk-mq.h‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ struct blk_mq_tag_set {
7979

8080
typedef int (queue_rq_fn)(struct blk_mq_hw_ctx *, struct request *);
8181
typedef struct blk_mq_hw_ctx *(map_queue_fn)(struct request_queue *, const int);
82-
typedef struct blk_mq_hw_ctx *(alloc_hctx_fn)(struct blk_mq_tag_set *,
83-
unsigned int, int);
84-
typedef void (free_hctx_fn)(struct blk_mq_hw_ctx *, unsigned int);
8582
typedef int (init_hctx_fn)(struct blk_mq_hw_ctx *, void *, unsigned int);
8683
typedef void (exit_hctx_fn)(struct blk_mq_hw_ctx *, unsigned int);
8784
typedef int (init_request_fn)(void *, struct request *, unsigned int,
@@ -107,12 +104,6 @@ struct blk_mq_ops {
107104

108105
softirq_done_fn *complete;
109106

110-
/*
111-
* Override for hctx allocations (should probably go)
112-
*/
113-
alloc_hctx_fn *alloc_hctx;
114-
free_hctx_fn *free_hctx;
115-
116107
/*
117108
* Called when the block layer side of a hardware queue has been
118109
* set up, allowing the driver to allocate/init matching structures.
@@ -166,7 +157,6 @@ struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag);
166157

167158
struct blk_mq_hw_ctx *blk_mq_map_queue(struct request_queue *, const int ctx_index);
168159
struct blk_mq_hw_ctx *blk_mq_alloc_single_hw_queue(struct blk_mq_tag_set *, unsigned int, int);
169-
void blk_mq_free_single_hw_queue(struct blk_mq_hw_ctx *, unsigned int);
170160

171161
void blk_mq_end_io(struct request *rq, int error);
172162
void __blk_mq_end_io(struct request *rq, int error);

0 commit comments

Comments
 (0)