summaryrefslogtreecommitdiffstats
path: root/block/blk-mq.c
diff options
context:
space:
mode:
authorBart Van Assche <bart.vanassche@sandisk.com>2017-04-07 14:16:51 -0400
committerJens Axboe <axboe@fb.com>2017-04-07 14:45:49 -0400
commit710c785f80ace49049aef1a003c0b8b932a58af8 (patch)
treedfff69a1504bba79ed689741eb4a24096daf5ac4 /block/blk-mq.c
parent705cda97ee3abb6ea38d651b54f4da83c2bb2a4a (diff)
blk-mq: Clarify comments in blk_mq_dispatch_rq_list()
The blk_mq_dispatch_rq_list() implementation got modified several times but the comments in that function were not updated every time. Since it is nontrivial what is going on, update the comments in blk_mq_dispatch_rq_list(). Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com> Cc: Omar Sandoval <osandov@fb.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Hannes Reinecke <hare@suse.de> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block/blk-mq.c')
-rw-r--r--block/blk-mq.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c
index ad057fe572a4..e536dacfae4c 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1063,8 +1063,8 @@ bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list)
1063 */ 1063 */
1064 if (!list_empty(list)) { 1064 if (!list_empty(list)) {
1065 /* 1065 /*
1066 * If we got a driver tag for the next request already, 1066 * If an I/O scheduler has been configured and we got a driver
1067 * free it again. 1067 * tag for the next request already, free it again.
1068 */ 1068 */
1069 rq = list_first_entry(list, struct request, queuelist); 1069 rq = list_first_entry(list, struct request, queuelist);
1070 blk_mq_put_driver_tag(rq); 1070 blk_mq_put_driver_tag(rq);
@@ -1074,16 +1074,24 @@ bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list)
1074 spin_unlock(&hctx->lock); 1074 spin_unlock(&hctx->lock);
1075 1075
1076 /* 1076 /*
1077 * the queue is expected stopped with BLK_MQ_RQ_QUEUE_BUSY, but 1077 * If SCHED_RESTART was set by the caller of this function and
1078 * it's possible the queue is stopped and restarted again 1078 * it is no longer set that means that it was cleared by another
1079 * before this. Queue restart will dispatch requests. And since 1079 * thread and hence that a queue rerun is needed.
1080 * requests in rq_list aren't added into hctx->dispatch yet,
1081 * the requests in rq_list might get lost.
1082 * 1080 *
1083 * blk_mq_run_hw_queue() already checks the STOPPED bit 1081 * If TAG_WAITING is set that means that an I/O scheduler has
1082 * been configured and another thread is waiting for a driver
1083 * tag. To guarantee fairness, do not rerun this hardware queue
1084 * but let the other thread grab the driver tag.
1084 * 1085 *
1085 * If RESTART or TAG_WAITING is set, then let completion restart 1086 * If no I/O scheduler has been configured it is possible that
1086 * the queue instead of potentially looping here. 1087 * the hardware queue got stopped and restarted before requests
1088 * were pushed back onto the dispatch list. Rerun the queue to
1089 * avoid starvation. Notes:
1090 * - blk_mq_run_hw_queue() checks whether or not a queue has
1091 * been stopped before rerunning a queue.
1092 * - Some but not all block drivers stop a queue before
1093 * returning BLK_MQ_RQ_QUEUE_BUSY. Two exceptions are scsi-mq
1094 * and dm-rq.
1087 */ 1095 */
1088 if (!blk_mq_sched_needs_restart(hctx) && 1096 if (!blk_mq_sched_needs_restart(hctx) &&
1089 !test_bit(BLK_MQ_S_TAG_WAITING, &hctx->state)) 1097 !test_bit(BLK_MQ_S_TAG_WAITING, &hctx->state))