From: Chengkaitao When adding a request to the sort_list/fifo_list, the kernel assigns {jiffies + dd->fifo_expire[data_dir]} to the fifo_time member. Consequently, we must subtract {dd->fifo_expire[rq_data_dir(rq)]} in the started_after function. In contrast, Commit (725f22a1477c) introduced changes to utilize the fifo_timevmember of requests on a dispatch list. The patch assigns {jiffies} to the fifo_time member when adding a request to a dispatch list. However, it continues to use the started_after function, which still subtracts {dd->fifo_expire[rq_data_dir(rq)]} from the start_time. The commit message does not explain this design choice, though it appears reasonably justifiable since dispatch lists should inherently have higher priority than sort_lists/fifo_lists. Thus, the default fifo_time set for dispatch lists should be smaller than that set for sort_lists/fifo_lists. Originally, {dd->fifo_expire[data_dir]} was exclusively used in the deadline_check_fifo function to control the timing of scanning fifo_lists. This subsequently determines the offset for the next scan of sort_lists via {dd->per_prio[prio].latest_pos[data_dir]}. Therefore, a larger {dd->fifo_expire[data_dir]} value makes it less likely for timed-out requests to be scanned. However, Commit (725f22a1477c) reversed the semantic meaning of {dd->fifo_expire[data_dir]}. When adding a request to a dispatch list, the patch only assigns {jiffies} to the fifo_time member without compensating for the {start_time -= dd->fifo_expire[rq_data_dir(rq)]} operation in the started_after function. This results in larger {dd->fifo_expire[data_dir]} values making timed-out requests more likely to be scanned. By default, fifo_expire[DD_WRITE] > fifo_expire[DD_READ], which incorrectly gives write-IO-requests higher priority than read-IO-requests and creates inherently illogical prioritization. On the other hand, the Commit (725f22a1477c) merges the effects of fifo_expire and prio_aging_expire on the same code behavior, creating redundant interactions. To address this, our new patch introduces numerical compensation for {dd->fifo_expire[data_dir]} when adding requests to dispatch lists. To maintain original logic as much as possible while enhancing dispatch list priority, we additionally subtract {dd->prio_aging_expire / 2} from the fifo_time, with default values, {dd->prio_aging_expire / 2} equals {dd->fifo_expire[DD_WRITE]}. Signed-off-by: Chengkaitao --- v2: Add a more detailed commit message Link to V1: https://lore.kernel.org/all/20250926023818.16223-1-pilgrimtao@gmail.com/ block/mq-deadline.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/mq-deadline.c b/block/mq-deadline.c index 3e741d33142d..fedc66187150 100644 --- a/block/mq-deadline.c +++ b/block/mq-deadline.c @@ -659,7 +659,8 @@ static void dd_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq, if (flags & BLK_MQ_INSERT_AT_HEAD) { list_add(&rq->queuelist, &per_prio->dispatch); - rq->fifo_time = jiffies; + rq->fifo_time = jiffies + dd->fifo_expire[data_dir] + - dd->prio_aging_expire / 2; } else { deadline_add_rq_rb(per_prio, rq); -- 2.50.1 (Apple Git-155)