blk-mq-sched: decide how to handle flush rq via RQF_FLUSH_SEQ
In case of IO scheduler we always pre-allocate one driver tag before calling blk_insert_flush(), and flush request will be marked as RQF_FLUSH_SEQ once it is in flush machinery. So if RQF_FLUSH_SEQ isn't set, we call blk_insert_flush() to handle the request, otherwise the flush request is dispatched to ->dispatch list directly. This is a preparation patch for not preallocating a driver tag for flush requests, and for not treating flush requests as a special case. This is similar to what the legacy path does. Signed-off-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>hifive-unleashed-5.1
parent
598906f814
commit
a6a252e649
|
@ -345,21 +345,23 @@ void blk_mq_sched_request_inserted(struct request *rq)
|
||||||
EXPORT_SYMBOL_GPL(blk_mq_sched_request_inserted);
|
EXPORT_SYMBOL_GPL(blk_mq_sched_request_inserted);
|
||||||
|
|
||||||
static bool blk_mq_sched_bypass_insert(struct blk_mq_hw_ctx *hctx,
|
static bool blk_mq_sched_bypass_insert(struct blk_mq_hw_ctx *hctx,
|
||||||
|
bool has_sched,
|
||||||
struct request *rq)
|
struct request *rq)
|
||||||
{
|
{
|
||||||
if (rq->tag == -1) {
|
/* dispatch flush rq directly */
|
||||||
rq->rq_flags |= RQF_SORTED;
|
if (rq->rq_flags & RQF_FLUSH_SEQ) {
|
||||||
return false;
|
spin_lock(&hctx->lock);
|
||||||
|
list_add(&rq->queuelist, &hctx->dispatch);
|
||||||
|
spin_unlock(&hctx->lock);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
if (has_sched) {
|
||||||
* If we already have a real request tag, send directly to
|
rq->rq_flags |= RQF_SORTED;
|
||||||
* the dispatch list.
|
WARN_ON(rq->tag != -1);
|
||||||
*/
|
}
|
||||||
spin_lock(&hctx->lock);
|
|
||||||
list_add(&rq->queuelist, &hctx->dispatch);
|
return false;
|
||||||
spin_unlock(&hctx->lock);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -385,12 +387,13 @@ void blk_mq_sched_insert_request(struct request *rq, bool at_head,
|
||||||
struct blk_mq_ctx *ctx = rq->mq_ctx;
|
struct blk_mq_ctx *ctx = rq->mq_ctx;
|
||||||
struct blk_mq_hw_ctx *hctx = blk_mq_map_queue(q, ctx->cpu);
|
struct blk_mq_hw_ctx *hctx = blk_mq_map_queue(q, ctx->cpu);
|
||||||
|
|
||||||
if (rq->tag == -1 && op_is_flush(rq->cmd_flags)) {
|
/* flush rq in flush machinery need to be dispatched directly */
|
||||||
|
if (!(rq->rq_flags & RQF_FLUSH_SEQ) && op_is_flush(rq->cmd_flags)) {
|
||||||
blk_mq_sched_insert_flush(hctx, rq, can_block);
|
blk_mq_sched_insert_flush(hctx, rq, can_block);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e && blk_mq_sched_bypass_insert(hctx, rq))
|
if (blk_mq_sched_bypass_insert(hctx, !!e, rq))
|
||||||
goto run;
|
goto run;
|
||||||
|
|
||||||
if (e && e->type->ops.mq.insert_requests) {
|
if (e && e->type->ops.mq.insert_requests) {
|
||||||
|
@ -428,7 +431,7 @@ void blk_mq_sched_insert_requests(struct request_queue *q,
|
||||||
list_for_each_entry_safe(rq, next, list, queuelist) {
|
list_for_each_entry_safe(rq, next, list, queuelist) {
|
||||||
if (WARN_ON_ONCE(rq->tag != -1)) {
|
if (WARN_ON_ONCE(rq->tag != -1)) {
|
||||||
list_del_init(&rq->queuelist);
|
list_del_init(&rq->queuelist);
|
||||||
blk_mq_sched_bypass_insert(hctx, rq);
|
blk_mq_sched_bypass_insert(hctx, true, rq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue