Skip to content

Commit

Permalink
blk-mq: don't commit_rqs() if none were queued
Browse files Browse the repository at this point in the history
Unburden the drivers from checking if a call to commit_rqs() is valid by
not calling it when there are no requests to commit.

Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Keith Busch authored and Jens Axboe committed Apr 6, 2020
1 parent c52abf5 commit 536167d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions block/blk-mq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list,
* the driver there was more coming, but that turned out to
* be a lie.
*/
if (q->mq_ops->commit_rqs)
if (q->mq_ops->commit_rqs && queued)
q->mq_ops->commit_rqs(hctx);

spin_lock(&hctx->lock);
Expand Down Expand Up @@ -1911,6 +1911,8 @@ blk_status_t blk_mq_request_issue_directly(struct request *rq, bool last)
void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx,
struct list_head *list)
{
int queued = 0;

while (!list_empty(list)) {
blk_status_t ret;
struct request *rq = list_first_entry(list, struct request,
Expand All @@ -1926,15 +1928,16 @@ void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx,
break;
}
blk_mq_end_request(rq, ret);
}
} else
queued++;
}

/*
* If we didn't flush the entire list, we could have told
* the driver there was more coming, but that turned out to
* be a lie.
*/
if (!list_empty(list) && hctx->queue->mq_ops->commit_rqs)
if (!list_empty(list) && hctx->queue->mq_ops->commit_rqs && queued)
hctx->queue->mq_ops->commit_rqs(hctx);
}

Expand Down

0 comments on commit 536167d

Please sign in to comment.