Skip to content

Commit 1b2ff19

Browse files
Jan Karaaxboe
authored andcommitted
blk-flush: Queue through IO scheduler when flush not required
Currently blk_insert_flush() just adds flush request to q->queue_head when flush is not required. That completely bypasses IO scheduler so e.g. CFQ can be idling waiting for new request to arrive and will idle through the whole window unnecessarily. Luckily this only happens in rare cases as usually checks in generic_make_request_checks() clear FLUSH and FUA flags early if they are not needed. When no flushing is actually required, we can easily fix the problem by properly queueing the request through the IO scheduler. Ideally IO scheduler should be also made aware of requests queued via blk_flush_queue_rq(). However inserting flush request through IO scheduler can have unwanted side-effects since due to flush batching delaying the flush request in IO scheduler will delay all flush requests possibly coming from other processes. So we keep adding the request directly to q->queue_head. Signed-off-by: Jan Kara <jack@suse.com> Reviewed-by: Jeff Moyer <jmoyer@redhat.com> Signed-off-by: Jens Axboe <axboe@fb.com>
1 parent b2b7e00 commit 1b2ff19

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

block/blk-flush.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ void blk_insert_flush(struct request *rq)
422422
if (q->mq_ops) {
423423
blk_mq_insert_request(rq, false, false, true);
424424
} else
425-
list_add_tail(&rq->queuelist, &q->queue_head);
425+
q->elevator->type->ops.elevator_add_req_fn(q, rq);
426426
return;
427427
}
428428

0 commit comments

Comments
 (0)