.commit_rqs() is supposed to handle partial dispatch when driver may not see .last of flag passed to .queue_rq(). We have added .commit_rqs() in case of partial dispatch and all consumers of bd->last have implemented .commit_rqs() callback, so it is perfect to pass real .last flag of the request list to .queue_rq() instead of faking it by trying to allocate driver tag for next request in the batching list. Cc: Sagi Grimberg <sagi@xxxxxxxxxxx> Cc: Baolin Wang <baolin.wang7@xxxxxxxxx> Cc: Christoph Hellwig <hch@xxxxxxxxxxxxx> Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx> --- block/blk-mq.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index f064e7923ea5..f8c4b59022d7 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1169,16 +1169,6 @@ static void blk_mq_update_dispatch_busy(struct blk_mq_hw_ctx *hctx, bool busy) static void blk_mq_handle_dev_resource(struct request *rq, struct list_head *list) { - struct request *next = - list_first_entry_or_null(list, struct request, queuelist); - - /* - * If an I/O scheduler has been configured and we got a driver tag for - * the next request already, free it. - */ - if (next) - blk_mq_put_driver_tag(next); - list_add(&rq->queuelist, list); __blk_mq_requeue_request(rq); } @@ -1203,7 +1193,7 @@ bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list, bool got_budget) { struct request_queue *q = hctx->queue; - struct request *rq, *nxt; + struct request *rq; bool no_tag = false; int errors, queued; blk_status_t ret = BLK_STS_OK; @@ -1254,17 +1244,7 @@ bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list, list_del_init(&rq->queuelist); bd.rq = rq; - - /* - * Flag last if we have no more requests, or if we have more - * but can't assign a driver tag to it. - */ - if (list_empty(list)) - bd.last = true; - else { - nxt = list_first_entry(list, struct request, queuelist); - bd.last = !blk_mq_get_driver_tag(nxt); - } + bd.last = !!list_empty(list); ret = q->mq_ops->queue_rq(hctx, &bd); if (ret == BLK_STS_RESOURCE || ret == BLK_STS_DEV_RESOURCE) { -- 2.25.2