Skip to content

Commit 8f5fea6

Browse files
David Jefferyaxboe
authored andcommitted
blk-mq: avoid extending delays of active hctx from blk_mq_delay_run_hw_queues
When blk_mq_delay_run_hw_queues sets an hctx to run in the future, it can reset the delay length for an already pending delayed work run_work. This creates a scenario where multiple hctx may have their queues set to run, but if one runs first and finds nothing to do, it can reset the delay of another hctx and stall the other hctx's ability to run requests. To avoid this I/O stall when an hctx's run_work is already pending, leave it untouched to run at its current designated time rather than extending its delay. The work will still run which keeps closed the race calling blk_mq_delay_run_hw_queues is needed for while also avoiding the I/O stall. Signed-off-by: David Jeffery <djeffery@redhat.com> Reviewed-by: Ming Lei <ming.lei@redhat.com> Link: https://lore.kernel.org/r/20220131203337.GA17666@redhat Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 24b45e6 commit 8f5fea6

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

block/blk-mq.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2179,6 +2179,14 @@ void blk_mq_delay_run_hw_queues(struct request_queue *q, unsigned long msecs)
21792179
queue_for_each_hw_ctx(q, hctx, i) {
21802180
if (blk_mq_hctx_stopped(hctx))
21812181
continue;
2182+
/*
2183+
* If there is already a run_work pending, leave the
2184+
* pending delay untouched. Otherwise, a hctx can stall
2185+
* if another hctx is re-delaying the other's work
2186+
* before the work executes.
2187+
*/
2188+
if (delayed_work_pending(&hctx->run_work))
2189+
continue;
21822190
/*
21832191
* Dispatch from this hctx either if there's no hctx preferred
21842192
* by IO scheduler or if it has requests that bypass the

0 commit comments

Comments
 (0)