Skip to content

Commit f9cd4bf

Browse files
committed
block: get rid of MQ scheduler ops union
This is a remnant of when we had ops for both SQ and MQ schedulers. Now it's just MQ, so get rid of the union. Reviewed-by: Omar Sandoval <osandov@fb.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent a1ce35f commit f9cd4bf

9 files changed

Lines changed: 53 additions & 56 deletions

File tree

‎block/bfq-iosched.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5724,7 +5724,7 @@ static struct elv_fs_entry bfq_attrs[] = {
57245724
};
57255725

57265726
static struct elevator_type iosched_bfq_mq = {
5727-
.ops.mq = {
5727+
.ops = {
57285728
.limit_depth = bfq_limit_depth,
57295729
.prepare_request = bfq_prepare_request,
57305730
.requeue_request = bfq_finish_requeue_request,

‎block/blk-ioc.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ static void ioc_exit_icq(struct io_cq *icq)
4848
if (icq->flags & ICQ_EXITED)
4949
return;
5050

51-
if (et->ops.mq.exit_icq)
52-
et->ops.mq.exit_icq(icq);
51+
if (et->ops.exit_icq)
52+
et->ops.exit_icq(icq);
5353

5454
icq->flags |= ICQ_EXITED;
5555
}
@@ -396,8 +396,8 @@ struct io_cq *ioc_create_icq(struct io_context *ioc, struct request_queue *q,
396396
if (likely(!radix_tree_insert(&ioc->icq_tree, q->id, icq))) {
397397
hlist_add_head(&icq->ioc_node, &ioc->icq_list);
398398
list_add(&icq->q_node, &q->icq_list);
399-
if (et->ops.mq.init_icq)
400-
et->ops.mq.init_icq(icq);
399+
if (et->ops.init_icq)
400+
et->ops.init_icq(icq);
401401
} else {
402402
kmem_cache_free(et->icq_cache, icq);
403403
icq = ioc_lookup_icq(ioc, q);

‎block/blk-mq-sched.c‎

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,13 @@ static void blk_mq_do_dispatch_sched(struct blk_mq_hw_ctx *hctx)
8585
do {
8686
struct request *rq;
8787

88-
if (e->type->ops.mq.has_work &&
89-
!e->type->ops.mq.has_work(hctx))
88+
if (e->type->ops.has_work && !e->type->ops.has_work(hctx))
9089
break;
9190

9291
if (!blk_mq_get_dispatch_budget(hctx))
9392
break;
9493

95-
rq = e->type->ops.mq.dispatch_request(hctx);
94+
rq = e->type->ops.dispatch_request(hctx);
9695
if (!rq) {
9796
blk_mq_put_dispatch_budget(hctx);
9897
break;
@@ -163,7 +162,7 @@ void blk_mq_sched_dispatch_requests(struct blk_mq_hw_ctx *hctx)
163162
{
164163
struct request_queue *q = hctx->queue;
165164
struct elevator_queue *e = q->elevator;
166-
const bool has_sched_dispatch = e && e->type->ops.mq.dispatch_request;
165+
const bool has_sched_dispatch = e && e->type->ops.dispatch_request;
167166
LIST_HEAD(rq_list);
168167

169168
/* RCU or SRCU read lock is needed before checking quiesced flag */
@@ -314,9 +313,9 @@ bool __blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio)
314313
struct blk_mq_hw_ctx *hctx = blk_mq_map_queue(q, ctx->cpu);
315314
bool ret = false;
316315

317-
if (e && e->type->ops.mq.bio_merge) {
316+
if (e && e->type->ops.bio_merge) {
318317
blk_mq_put_ctx(ctx);
319-
return e->type->ops.mq.bio_merge(hctx, bio);
318+
return e->type->ops.bio_merge(hctx, bio);
320319
}
321320

322321
if ((hctx->flags & BLK_MQ_F_SHOULD_MERGE) &&
@@ -380,11 +379,11 @@ void blk_mq_sched_insert_request(struct request *rq, bool at_head,
380379
if (blk_mq_sched_bypass_insert(hctx, !!e, rq))
381380
goto run;
382381

383-
if (e && e->type->ops.mq.insert_requests) {
382+
if (e && e->type->ops.insert_requests) {
384383
LIST_HEAD(list);
385384

386385
list_add(&rq->queuelist, &list);
387-
e->type->ops.mq.insert_requests(hctx, &list, at_head);
386+
e->type->ops.insert_requests(hctx, &list, at_head);
388387
} else {
389388
spin_lock(&ctx->lock);
390389
__blk_mq_insert_request(hctx, rq, at_head);
@@ -403,8 +402,8 @@ void blk_mq_sched_insert_requests(struct request_queue *q,
403402
struct blk_mq_hw_ctx *hctx = blk_mq_map_queue(q, ctx->cpu);
404403
struct elevator_queue *e = hctx->queue->elevator;
405404

406-
if (e && e->type->ops.mq.insert_requests)
407-
e->type->ops.mq.insert_requests(hctx, list, false);
405+
if (e && e->type->ops.insert_requests)
406+
e->type->ops.insert_requests(hctx, list, false);
408407
else {
409408
/*
410409
* try to issue requests directly if the hw queue isn't
@@ -489,15 +488,15 @@ int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e)
489488
goto err;
490489
}
491490

492-
ret = e->ops.mq.init_sched(q, e);
491+
ret = e->ops.init_sched(q, e);
493492
if (ret)
494493
goto err;
495494

496495
blk_mq_debugfs_register_sched(q);
497496

498497
queue_for_each_hw_ctx(q, hctx, i) {
499-
if (e->ops.mq.init_hctx) {
500-
ret = e->ops.mq.init_hctx(hctx, i);
498+
if (e->ops.init_hctx) {
499+
ret = e->ops.init_hctx(hctx, i);
501500
if (ret) {
502501
eq = q->elevator;
503502
blk_mq_exit_sched(q, eq);
@@ -523,14 +522,14 @@ void blk_mq_exit_sched(struct request_queue *q, struct elevator_queue *e)
523522

524523
queue_for_each_hw_ctx(q, hctx, i) {
525524
blk_mq_debugfs_unregister_sched_hctx(hctx);
526-
if (e->type->ops.mq.exit_hctx && hctx->sched_data) {
527-
e->type->ops.mq.exit_hctx(hctx, i);
525+
if (e->type->ops.exit_hctx && hctx->sched_data) {
526+
e->type->ops.exit_hctx(hctx, i);
528527
hctx->sched_data = NULL;
529528
}
530529
}
531530
blk_mq_debugfs_unregister_sched(q);
532-
if (e->type->ops.mq.exit_sched)
533-
e->type->ops.mq.exit_sched(e);
531+
if (e->type->ops.exit_sched)
532+
e->type->ops.exit_sched(e);
534533
blk_mq_sched_tags_teardown(q);
535534
q->elevator = NULL;
536535
}

‎block/blk-mq-sched.h‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ blk_mq_sched_allow_merge(struct request_queue *q, struct request *rq,
4343
{
4444
struct elevator_queue *e = q->elevator;
4545

46-
if (e && e->type->ops.mq.allow_merge)
47-
return e->type->ops.mq.allow_merge(q, rq, bio);
46+
if (e && e->type->ops.allow_merge)
47+
return e->type->ops.allow_merge(q, rq, bio);
4848

4949
return true;
5050
}
@@ -53,34 +53,34 @@ static inline void blk_mq_sched_completed_request(struct request *rq, u64 now)
5353
{
5454
struct elevator_queue *e = rq->q->elevator;
5555

56-
if (e && e->type->ops.mq.completed_request)
57-
e->type->ops.mq.completed_request(rq, now);
56+
if (e && e->type->ops.completed_request)
57+
e->type->ops.completed_request(rq, now);
5858
}
5959

6060
static inline void blk_mq_sched_started_request(struct request *rq)
6161
{
6262
struct request_queue *q = rq->q;
6363
struct elevator_queue *e = q->elevator;
6464

65-
if (e && e->type->ops.mq.started_request)
66-
e->type->ops.mq.started_request(rq);
65+
if (e && e->type->ops.started_request)
66+
e->type->ops.started_request(rq);
6767
}
6868

6969
static inline void blk_mq_sched_requeue_request(struct request *rq)
7070
{
7171
struct request_queue *q = rq->q;
7272
struct elevator_queue *e = q->elevator;
7373

74-
if (e && e->type->ops.mq.requeue_request)
75-
e->type->ops.mq.requeue_request(rq);
74+
if (e && e->type->ops.requeue_request)
75+
e->type->ops.requeue_request(rq);
7676
}
7777

7878
static inline bool blk_mq_sched_has_work(struct blk_mq_hw_ctx *hctx)
7979
{
8080
struct elevator_queue *e = hctx->queue->elevator;
8181

82-
if (e && e->type->ops.mq.has_work)
83-
return e->type->ops.mq.has_work(hctx);
82+
if (e && e->type->ops.has_work)
83+
return e->type->ops.has_work(hctx);
8484

8585
return false;
8686
}

‎block/blk-mq.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,9 @@ static struct request *blk_mq_get_request(struct request_queue *q,
363363
* dispatch list. Don't include reserved tags in the
364364
* limiting, as it isn't useful.
365365
*/
366-
if (!op_is_flush(op) && e->type->ops.mq.limit_depth &&
366+
if (!op_is_flush(op) && e->type->ops.limit_depth &&
367367
!(data->flags & BLK_MQ_REQ_RESERVED))
368-
e->type->ops.mq.limit_depth(op, data);
368+
e->type->ops.limit_depth(op, data);
369369
} else {
370370
blk_mq_tag_busy(data->hctx);
371371
}
@@ -383,11 +383,11 @@ static struct request *blk_mq_get_request(struct request_queue *q,
383383
rq = blk_mq_rq_ctx_init(data, tag, op);
384384
if (!op_is_flush(op)) {
385385
rq->elv.icq = NULL;
386-
if (e && e->type->ops.mq.prepare_request) {
386+
if (e && e->type->ops.prepare_request) {
387387
if (e->type->icq_cache && rq_ioc(bio))
388388
blk_mq_sched_assign_ioc(rq, bio);
389389

390-
e->type->ops.mq.prepare_request(rq, bio);
390+
e->type->ops.prepare_request(rq, bio);
391391
rq->rq_flags |= RQF_ELVPRIV;
392392
}
393393
}
@@ -491,8 +491,8 @@ void blk_mq_free_request(struct request *rq)
491491
struct blk_mq_hw_ctx *hctx = blk_mq_map_queue(q, ctx->cpu);
492492

493493
if (rq->rq_flags & RQF_ELVPRIV) {
494-
if (e && e->type->ops.mq.finish_request)
495-
e->type->ops.mq.finish_request(rq);
494+
if (e && e->type->ops.finish_request)
495+
e->type->ops.finish_request(rq);
496496
if (rq->elv.icq) {
497497
put_io_context(rq->elv.icq->ioc);
498498
rq->elv.icq = NULL;

‎block/elevator.c‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ static int elv_iosched_allow_bio_merge(struct request *rq, struct bio *bio)
6161
struct request_queue *q = rq->q;
6262
struct elevator_queue *e = q->elevator;
6363

64-
if (e->type->ops.mq.allow_merge)
65-
return e->type->ops.mq.allow_merge(q, rq, bio);
64+
if (e->type->ops.allow_merge)
65+
return e->type->ops.allow_merge(q, rq, bio);
6666

6767
return 1;
6868
}
@@ -180,7 +180,7 @@ static void elevator_release(struct kobject *kobj)
180180
void elevator_exit(struct request_queue *q, struct elevator_queue *e)
181181
{
182182
mutex_lock(&e->sysfs_lock);
183-
if (e->type->ops.mq.exit_sched)
183+
if (e->type->ops.exit_sched)
184184
blk_mq_exit_sched(q, e);
185185
mutex_unlock(&e->sysfs_lock);
186186

@@ -329,8 +329,8 @@ enum elv_merge elv_merge(struct request_queue *q, struct request **req,
329329
return ELEVATOR_BACK_MERGE;
330330
}
331331

332-
if (e->type->ops.mq.request_merge)
333-
return e->type->ops.mq.request_merge(q, req, bio);
332+
if (e->type->ops.request_merge)
333+
return e->type->ops.request_merge(q, req, bio);
334334

335335
return ELEVATOR_NO_MERGE;
336336
}
@@ -381,8 +381,8 @@ void elv_merged_request(struct request_queue *q, struct request *rq,
381381
{
382382
struct elevator_queue *e = q->elevator;
383383

384-
if (e->type->ops.mq.request_merged)
385-
e->type->ops.mq.request_merged(q, rq, type);
384+
if (e->type->ops.request_merged)
385+
e->type->ops.request_merged(q, rq, type);
386386

387387
if (type == ELEVATOR_BACK_MERGE)
388388
elv_rqhash_reposition(q, rq);
@@ -396,8 +396,8 @@ void elv_merge_requests(struct request_queue *q, struct request *rq,
396396
struct elevator_queue *e = q->elevator;
397397
bool next_sorted = false;
398398

399-
if (e->type->ops.mq.requests_merged)
400-
e->type->ops.mq.requests_merged(q, rq, next);
399+
if (e->type->ops.requests_merged)
400+
e->type->ops.requests_merged(q, rq, next);
401401

402402
elv_rqhash_reposition(q, rq);
403403

@@ -413,8 +413,8 @@ struct request *elv_latter_request(struct request_queue *q, struct request *rq)
413413
{
414414
struct elevator_queue *e = q->elevator;
415415

416-
if (e->type->ops.mq.next_request)
417-
return e->type->ops.mq.next_request(q, rq);
416+
if (e->type->ops.next_request)
417+
return e->type->ops.next_request(q, rq);
418418

419419
return NULL;
420420
}
@@ -423,8 +423,8 @@ struct request *elv_former_request(struct request_queue *q, struct request *rq)
423423
{
424424
struct elevator_queue *e = q->elevator;
425425

426-
if (e->type->ops.mq.former_request)
427-
return e->type->ops.mq.former_request(q, rq);
426+
if (e->type->ops.former_request)
427+
return e->type->ops.former_request(q, rq);
428428

429429
return NULL;
430430
}

‎block/kyber-iosched.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ static const struct blk_mq_debugfs_attr kyber_hctx_debugfs_attrs[] = {
10171017
#endif
10181018

10191019
static struct elevator_type kyber_sched = {
1020-
.ops.mq = {
1020+
.ops = {
10211021
.init_sched = kyber_init_sched,
10221022
.exit_sched = kyber_exit_sched,
10231023
.init_hctx = kyber_init_hctx,

‎block/mq-deadline.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ static const struct blk_mq_debugfs_attr deadline_queue_debugfs_attrs[] = {
761761
#endif
762762

763763
static struct elevator_type mq_deadline = {
764-
.ops.mq = {
764+
.ops = {
765765
.insert_requests = dd_insert_requests,
766766
.dispatch_request = dd_dispatch_request,
767767
.prepare_request = dd_prepare_request,

‎include/linux/elevator.h‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ struct elevator_type
6969
struct kmem_cache *icq_cache;
7070

7171
/* fields provided by elevator implementation */
72-
union {
73-
struct elevator_mq_ops mq;
74-
} ops;
72+
struct elevator_mq_ops ops;
7573

7674
size_t icq_size; /* see iocontext.h */
7775
size_t icq_align; /* ditto */

0 commit comments

Comments
 (0)