blk_mq_sched_mark_restart_hctx() must be called before blk_mq_dispatch_rq_list() is called. Make sure that BLK_MQ_S_SCHED_RESTART is set before any blk_mq_dispatch_rq_list() call occurs. Fixes: commit b347689ffbca ("blk-mq-sched: improve dispatching from sw queue") Signed-off-by: Bart Van Assche <bart.vanassche@xxxxxxx> Cc: Ming Lei <ming.lei@xxxxxxxxxx> Cc: Omar Sandoval <osandov@xxxxxx> Cc: Christoph Hellwig <hch@xxxxxx> Cc: Hannes Reinecke <hare@xxxxxxx> Cc: Johannes Thumshirn <jthumshirn@xxxxxxx> --- block/blk-mq-sched.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c index d8e3533d3218..c4e0cb5f6f1f 100644 --- a/block/blk-mq-sched.c +++ b/block/blk-mq-sched.c @@ -208,8 +208,8 @@ void blk_mq_sched_dispatch_requests(struct blk_mq_hw_ctx *hctx) * on the dispatch list or we were able to dispatch from the * dispatch list. */ + blk_mq_sched_mark_restart_hctx(hctx); if (!list_empty(&rq_list)) { - blk_mq_sched_mark_restart_hctx(hctx); if (blk_mq_dispatch_rq_list(q, &rq_list, false)) { if (has_sched_dispatch) blk_mq_do_dispatch_sched(hctx); -- 2.15.0