Skip to content

Commit 344e9ff

Browse files
committed
block: add queue_is_mq() helper
Various spots check for q->mq_ops being non-NULL, but provide a helper to do this instead. Where the ->mq_ops != NULL check is redundant, remove it. Since mq == rq-based now that legacy is gone, get rid of the queue_is_rq_based() and just use queue_is_mq() everywhere. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent dabcefa commit 344e9ff

14 files changed

Lines changed: 36 additions & 42 deletions

File tree

‎block/blk-cgroup.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,7 +1324,7 @@ int blkcg_activate_policy(struct request_queue *q,
13241324
if (blkcg_policy_enabled(q, pol))
13251325
return 0;
13261326

1327-
if (q->mq_ops)
1327+
if (queue_is_mq(q))
13281328
blk_mq_freeze_queue(q);
13291329
pd_prealloc:
13301330
if (!pd_prealloc) {
@@ -1363,7 +1363,7 @@ int blkcg_activate_policy(struct request_queue *q,
13631363

13641364
spin_unlock_irq(&q->queue_lock);
13651365
out_bypass_end:
1366-
if (q->mq_ops)
1366+
if (queue_is_mq(q))
13671367
blk_mq_unfreeze_queue(q);
13681368
if (pd_prealloc)
13691369
pol->pd_free_fn(pd_prealloc);
@@ -1387,7 +1387,7 @@ void blkcg_deactivate_policy(struct request_queue *q,
13871387
if (!blkcg_policy_enabled(q, pol))
13881388
return;
13891389

1390-
if (q->mq_ops)
1390+
if (queue_is_mq(q))
13911391
blk_mq_freeze_queue(q);
13921392

13931393
spin_lock_irq(&q->queue_lock);
@@ -1405,7 +1405,7 @@ void blkcg_deactivate_policy(struct request_queue *q,
14051405

14061406
spin_unlock_irq(&q->queue_lock);
14071407

1408-
if (q->mq_ops)
1408+
if (queue_is_mq(q))
14091409
blk_mq_unfreeze_queue(q);
14101410
}
14111411
EXPORT_SYMBOL_GPL(blkcg_deactivate_policy);

‎block/blk-core.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ void blk_sync_queue(struct request_queue *q)
232232
del_timer_sync(&q->timeout);
233233
cancel_work_sync(&q->timeout_work);
234234

235-
if (q->mq_ops) {
235+
if (queue_is_mq(q)) {
236236
struct blk_mq_hw_ctx *hctx;
237237
int i;
238238

@@ -281,7 +281,7 @@ void blk_set_queue_dying(struct request_queue *q)
281281
*/
282282
blk_freeze_queue_start(q);
283283

284-
if (q->mq_ops)
284+
if (queue_is_mq(q))
285285
blk_mq_wake_waiters(q);
286286

287287
/* Make blk_queue_enter() reexamine the DYING flag. */
@@ -356,7 +356,7 @@ void blk_cleanup_queue(struct request_queue *q)
356356
* blk_freeze_queue() should be enough for cases of passthrough
357357
* request.
358358
*/
359-
if (q->mq_ops && blk_queue_init_done(q))
359+
if (queue_is_mq(q) && blk_queue_init_done(q))
360360
blk_mq_quiesce_queue(q);
361361

362362
/* for synchronous bio-based driver finish in-flight integrity i/o */
@@ -374,7 +374,7 @@ void blk_cleanup_queue(struct request_queue *q)
374374

375375
blk_exit_queue(q);
376376

377-
if (q->mq_ops)
377+
if (queue_is_mq(q))
378378
blk_mq_free_queue(q);
379379

380380
percpu_ref_exit(&q->q_usage_counter);
@@ -982,7 +982,7 @@ generic_make_request_checks(struct bio *bio)
982982
* For a REQ_NOWAIT based request, return -EOPNOTSUPP
983983
* if queue is not a request based queue.
984984
*/
985-
if ((bio->bi_opf & REQ_NOWAIT) && !queue_is_rq_based(q))
985+
if ((bio->bi_opf & REQ_NOWAIT) && !queue_is_mq(q))
986986
goto not_supported;
987987

988988
if (should_fail_bio(bio))
@@ -1657,7 +1657,7 @@ EXPORT_SYMBOL_GPL(rq_flush_dcache_pages);
16571657
*/
16581658
int blk_lld_busy(struct request_queue *q)
16591659
{
1660-
if (q->mq_ops && q->mq_ops->busy)
1660+
if (queue_is_mq(q) && q->mq_ops->busy)
16611661
return q->mq_ops->busy(q);
16621662

16631663
return 0;

‎block/blk-flush.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,7 @@ static void blk_kick_flush(struct request_queue *q, struct blk_flush_queue *fq,
273273
* assigned to empty flushes, and we deadlock if we are expecting
274274
* other requests to make progress. Don't defer for that case.
275275
*/
276-
if (!list_empty(&fq->flush_data_in_flight) &&
277-
!(q->mq_ops && q->elevator) &&
276+
if (!list_empty(&fq->flush_data_in_flight) && q->elevator &&
278277
time_before(jiffies,
279278
fq->flush_pending_since + FLUSH_PENDING_TIMEOUT))
280279
return;

‎block/blk-mq.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ void blk_freeze_queue_start(struct request_queue *q)
150150
freeze_depth = atomic_inc_return(&q->mq_freeze_depth);
151151
if (freeze_depth == 1) {
152152
percpu_ref_kill(&q->q_usage_counter);
153-
if (q->mq_ops)
153+
if (queue_is_mq(q))
154154
blk_mq_run_hw_queues(q, false);
155155
}
156156
}

‎block/blk-sysfs.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ queue_requests_store(struct request_queue *q, const char *page, size_t count)
6868
unsigned long nr;
6969
int ret, err;
7070

71-
if (!q->mq_ops)
71+
if (!queue_is_mq(q))
7272
return -EINVAL;
7373

7474
ret = queue_var_store(&nr, page, count);
@@ -835,12 +835,12 @@ static void __blk_release_queue(struct work_struct *work)
835835

836836
blk_queue_free_zone_bitmaps(q);
837837

838-
if (q->mq_ops)
838+
if (queue_is_mq(q))
839839
blk_mq_release(q);
840840

841841
blk_trace_shutdown(q);
842842

843-
if (q->mq_ops)
843+
if (queue_is_mq(q))
844844
blk_mq_debugfs_unregister(q);
845845

846846
bioset_exit(&q->bio_split);
@@ -914,7 +914,7 @@ int blk_register_queue(struct gendisk *disk)
914914
goto unlock;
915915
}
916916

917-
if (q->mq_ops) {
917+
if (queue_is_mq(q)) {
918918
__blk_mq_register_dev(dev, q);
919919
blk_mq_debugfs_register(q);
920920
}
@@ -925,7 +925,7 @@ int blk_register_queue(struct gendisk *disk)
925925

926926
blk_throtl_register_queue(q);
927927

928-
if ((q->mq_ops && q->elevator)) {
928+
if (q->elevator) {
929929
ret = elv_register_queue(q);
930930
if (ret) {
931931
mutex_unlock(&q->sysfs_lock);
@@ -974,7 +974,7 @@ void blk_unregister_queue(struct gendisk *disk)
974974
* Remove the sysfs attributes before unregistering the queue data
975975
* structures that can be modified through sysfs.
976976
*/
977-
if (q->mq_ops)
977+
if (queue_is_mq(q))
978978
blk_mq_unregister_dev(disk_to_dev(disk), q);
979979
mutex_unlock(&q->sysfs_lock);
980980

@@ -983,7 +983,7 @@ void blk_unregister_queue(struct gendisk *disk)
983983
blk_trace_remove_sysfs(disk_to_dev(disk));
984984

985985
mutex_lock(&q->sysfs_lock);
986-
if (q->mq_ops && q->elevator)
986+
if (q->elevator)
987987
elv_unregister_queue(q);
988988
mutex_unlock(&q->sysfs_lock);
989989

‎block/blk-throttle.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2456,7 +2456,7 @@ void blk_throtl_register_queue(struct request_queue *q)
24562456
td->throtl_slice = DFL_THROTL_SLICE_HD;
24572457
#endif
24582458

2459-
td->track_bio_latency = !queue_is_rq_based(q);
2459+
td->track_bio_latency = !queue_is_mq(q);
24602460
if (!td->track_bio_latency)
24612461
blk_stat_enable_accounting(q);
24622462
}

‎block/blk-wbt.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ void wbt_enable_default(struct request_queue *q)
701701
if (!test_bit(QUEUE_FLAG_REGISTERED, &q->queue_flags))
702702
return;
703703

704-
if (q->mq_ops && IS_ENABLED(CONFIG_BLK_WBT_MQ))
704+
if (queue_is_mq(q) && IS_ENABLED(CONFIG_BLK_WBT_MQ))
705705
wbt_init(q);
706706
}
707707
EXPORT_SYMBOL_GPL(wbt_enable_default);

‎block/blk-zoned.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ int blk_revalidate_disk_zones(struct gendisk *disk)
421421
* BIO based queues do not use a scheduler so only q->nr_zones
422422
* needs to be updated so that the sysfs exposed value is correct.
423423
*/
424-
if (!queue_is_rq_based(q)) {
424+
if (!queue_is_mq(q)) {
425425
q->nr_zones = nr_zones;
426426
return 0;
427427
}

‎block/bsg.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ int bsg_register_queue(struct request_queue *q, struct device *parent,
471471
/*
472472
* we need a proper transport to send commands, not a stacked device
473473
*/
474-
if (!queue_is_rq_based(q))
474+
if (!queue_is_mq(q))
475475
return 0;
476476

477477
bcd = &q->bsg_dev;

‎block/elevator.c‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ static int __elevator_change(struct request_queue *q, const char *name)
667667
/*
668668
* Special case for mq, turn off scheduling
669669
*/
670-
if (q->mq_ops && !strncmp(name, "none", 4))
670+
if (!strncmp(name, "none", 4))
671671
return elevator_switch(q, NULL);
672672

673673
strlcpy(elevator_name, name, sizeof(elevator_name));
@@ -685,8 +685,7 @@ static int __elevator_change(struct request_queue *q, const char *name)
685685

686686
static inline bool elv_support_iosched(struct request_queue *q)
687687
{
688-
if (q->mq_ops && q->tag_set && (q->tag_set->flags &
689-
BLK_MQ_F_NO_SCHED))
688+
if (q->tag_set && (q->tag_set->flags & BLK_MQ_F_NO_SCHED))
690689
return false;
691690
return true;
692691
}
@@ -696,7 +695,7 @@ ssize_t elv_iosched_store(struct request_queue *q, const char *name,
696695
{
697696
int ret;
698697

699-
if (!q->mq_ops || !elv_support_iosched(q))
698+
if (!queue_is_mq(q) || !elv_support_iosched(q))
700699
return count;
701700

702701
ret = __elevator_change(q, name);
@@ -713,7 +712,7 @@ ssize_t elv_iosched_show(struct request_queue *q, char *name)
713712
struct elevator_type *__e;
714713
int len = 0;
715714

716-
if (!queue_is_rq_based(q))
715+
if (!queue_is_mq(q))
717716
return sprintf(name, "none\n");
718717

719718
if (!q->elevator)
@@ -732,7 +731,7 @@ ssize_t elv_iosched_show(struct request_queue *q, char *name)
732731
}
733732
spin_unlock(&elv_list_lock);
734733

735-
if (q->mq_ops && q->elevator)
734+
if (q->elevator)
736735
len += sprintf(name+len, "none");
737736

738737
len += sprintf(len+name, "\n");

0 commit comments

Comments
 (0)