Skip to content

Commit 536167d

Browse files
keithbuschaxboe
authored andcommitted
blk-mq: don't commit_rqs() if none were queued
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 <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent c52abf5 commit 536167d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

block/blk-mq.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,7 @@ bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list,
12891289
* the driver there was more coming, but that turned out to
12901290
* be a lie.
12911291
*/
1292-
if (q->mq_ops->commit_rqs)
1292+
if (q->mq_ops->commit_rqs && queued)
12931293
q->mq_ops->commit_rqs(hctx);
12941294

12951295
spin_lock(&hctx->lock);
@@ -1911,6 +1911,8 @@ blk_status_t blk_mq_request_issue_directly(struct request *rq, bool last)
19111911
void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx,
19121912
struct list_head *list)
19131913
{
1914+
int queued = 0;
1915+
19141916
while (!list_empty(list)) {
19151917
blk_status_t ret;
19161918
struct request *rq = list_first_entry(list, struct request,
@@ -1926,15 +1928,16 @@ void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx,
19261928
break;
19271929
}
19281930
blk_mq_end_request(rq, ret);
1929-
}
1931+
} else
1932+
queued++;
19301933
}
19311934

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

0 commit comments

Comments
 (0)