[v2,1/2] blk-mq: In blk_mq_dispatch_rq_list() "no budget" is a reason to kick
diff mbox series

Message ID 20200402085050.v2.1.I1f95c459e51962b8d2c83e869913b6befda2255c@changeid
State New
Headers show
Series
  • blk-mq: Fix two causes of IO stalls found in reboot testing
Related show

Commit Message

Doug Anderson April 2, 2020, 3:51 p.m. UTC
In blk_mq_dispatch_rq_list(), if blk_mq_sched_needs_restart() returns
true and the driver returns BLK_STS_RESOURCE then we'll kick the
queue.  However, there's another case where we might need to kick it.
If we were unable to get budget we can be in much the same state as
when the driver returns BLK_STS_RESOURCE, so we should treat it the
same.

Signed-off-by: Douglas Anderson <dianders@chromium.org>
---

Changes in v2: None

 block/blk-mq.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Comments

Ming Lei April 3, 2020, 1:55 a.m. UTC | #1
On Thu, Apr 02, 2020 at 08:51:29AM -0700, Douglas Anderson wrote:
> In blk_mq_dispatch_rq_list(), if blk_mq_sched_needs_restart() returns
> true and the driver returns BLK_STS_RESOURCE then we'll kick the
> queue.  However, there's another case where we might need to kick it.
> If we were unable to get budget we can be in much the same state as
> when the driver returns BLK_STS_RESOURCE, so we should treat it the
> same.

The situation is really similar, especially the restart handler may
not see the request which may not be added to hctx->dispatch, so

Reviewed-by: Ming Lei <ming.lei@redhat.com>


Thanks, 
Ming

Patch
diff mbox series

diff --git a/block/blk-mq.c b/block/blk-mq.c
index d92088dec6c3..2cd8d2b49ff4 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1189,6 +1189,7 @@  bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list,
 	bool no_tag = false;
 	int errors, queued;
 	blk_status_t ret = BLK_STS_OK;
+	bool no_budget_avail = false;
 
 	if (list_empty(list))
 		return false;
@@ -1205,8 +1206,10 @@  bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list,
 		rq = list_first_entry(list, struct request, queuelist);
 
 		hctx = rq->mq_hctx;
-		if (!got_budget && !blk_mq_get_dispatch_budget(hctx))
+		if (!got_budget && !blk_mq_get_dispatch_budget(hctx)) {
+			no_budget_avail = true;
 			break;
+		}
 
 		if (!blk_mq_get_driver_tag(rq)) {
 			/*
@@ -1311,13 +1314,15 @@  bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list,
 		 *
 		 * If driver returns BLK_STS_RESOURCE and SCHED_RESTART
 		 * bit is set, run queue after a delay to avoid IO stalls
-		 * that could otherwise occur if the queue is idle.
+		 * that could otherwise occur if the queue is idle.  We'll do
+		 * similar if we couldn't get budget and SCHED_RESTART is set.
 		 */
 		needs_restart = blk_mq_sched_needs_restart(hctx);
 		if (!needs_restart ||
 		    (no_tag && list_empty_careful(&hctx->dispatch_wait.entry)))
 			blk_mq_run_hw_queue(hctx, true);
-		else if (needs_restart && (ret == BLK_STS_RESOURCE))
+		else if (needs_restart && (ret == BLK_STS_RESOURCE ||
+					   no_budget_avail))
 			blk_mq_delay_run_hw_queue(hctx, BLK_MQ_RESOURCE_DELAY);
 
 		blk_mq_update_dispatch_busy(hctx, true);