summaryrefslogtreecommitdiffstats
path: root/block/blk-mq-sched.c
diff options
context:
space:
mode:
authorOmar Sandoval <osandov@fb.com>2017-02-02 18:42:39 -0500
committerJens Axboe <axboe@fb.com>2017-02-02 18:57:56 -0500
commit0cacba6cf8252438f8166bd3fa1c3370dd28a769 (patch)
treec2b1dc91a0dadcc07be4e2fded65622d176c2720 /block/blk-mq-sched.c
parente17354961bb50931ec7b33f59c0713dcf98ac7d2 (diff)
blk-mq-sched: bypass the scheduler for flushes entirely
There's a weird inconsistency that flushes are mostly hidden from the scheduler, but it needs to be aware of them in ->insert_requests(). Instead of having every scheduler call blk_mq_sched_bypass_insert(), let's do it in the common framework. Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block/blk-mq-sched.c')
-rw-r--r--block/blk-mq-sched.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
index 114814ec3d49..3ec52f494094 100644
--- a/block/blk-mq-sched.c
+++ b/block/blk-mq-sched.c
@@ -289,7 +289,8 @@ void blk_mq_sched_request_inserted(struct request *rq)
289} 289}
290EXPORT_SYMBOL_GPL(blk_mq_sched_request_inserted); 290EXPORT_SYMBOL_GPL(blk_mq_sched_request_inserted);
291 291
292bool blk_mq_sched_bypass_insert(struct blk_mq_hw_ctx *hctx, struct request *rq) 292static bool blk_mq_sched_bypass_insert(struct blk_mq_hw_ctx *hctx,
293 struct request *rq)
293{ 294{
294 if (rq->tag == -1) { 295 if (rq->tag == -1) {
295 rq->rq_flags |= RQF_SORTED; 296 rq->rq_flags |= RQF_SORTED;
@@ -305,7 +306,6 @@ bool blk_mq_sched_bypass_insert(struct blk_mq_hw_ctx *hctx, struct request *rq)
305 spin_unlock(&hctx->lock); 306 spin_unlock(&hctx->lock);
306 return true; 307 return true;
307} 308}
308EXPORT_SYMBOL_GPL(blk_mq_sched_bypass_insert);
309 309
310static void blk_mq_sched_restart_hctx(struct blk_mq_hw_ctx *hctx) 310static void blk_mq_sched_restart_hctx(struct blk_mq_hw_ctx *hctx)
311{ 311{
@@ -363,6 +363,9 @@ void blk_mq_sched_insert_request(struct request *rq, bool at_head,
363 return; 363 return;
364 } 364 }
365 365
366 if (e && blk_mq_sched_bypass_insert(hctx, rq))
367 goto run;
368
366 if (e && e->type->ops.mq.insert_requests) { 369 if (e && e->type->ops.mq.insert_requests) {
367 LIST_HEAD(list); 370 LIST_HEAD(list);
368 371
@@ -374,6 +377,7 @@ void blk_mq_sched_insert_request(struct request *rq, bool at_head,
374 spin_unlock(&ctx->lock); 377 spin_unlock(&ctx->lock);
375 } 378 }
376 379
380run:
377 if (run_queue) 381 if (run_queue)
378 blk_mq_run_hw_queue(hctx, async); 382 blk_mq_run_hw_queue(hctx, async);
379} 383}
@@ -385,6 +389,23 @@ void blk_mq_sched_insert_requests(struct request_queue *q,
385 struct blk_mq_hw_ctx *hctx = blk_mq_map_queue(q, ctx->cpu); 389 struct blk_mq_hw_ctx *hctx = blk_mq_map_queue(q, ctx->cpu);
386 struct elevator_queue *e = hctx->queue->elevator; 390 struct elevator_queue *e = hctx->queue->elevator;
387 391
392 if (e) {
393 struct request *rq, *next;
394
395 /*
396 * We bypass requests that already have a driver tag assigned,
397 * which should only be flushes. Flushes are only ever inserted
398 * as single requests, so we shouldn't ever hit the
399 * WARN_ON_ONCE() below (but let's handle it just in case).
400 */
401 list_for_each_entry_safe(rq, next, list, queuelist) {
402 if (WARN_ON_ONCE(rq->tag != -1)) {
403 list_del_init(&rq->queuelist);
404 blk_mq_sched_bypass_insert(hctx, rq);
405 }
406 }
407 }
408
388 if (e && e->type->ops.mq.insert_requests) 409 if (e && e->type->ops.mq.insert_requests)
389 e->type->ops.mq.insert_requests(hctx, list, false); 410 e->type->ops.mq.insert_requests(hctx, list, false);
390 else 411 else