public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] blk-throttle: fix possible io stall when doing upgrade
@ 2017-09-25 10:46 Joseph Qi
  2017-09-25 17:22 ` Shaohua Li
  0 siblings, 1 reply; 9+ messages in thread
From: Joseph Qi @ 2017-09-25 10:46 UTC (permalink / raw)
  To: linux-block; +Cc: Jens Axboe, Shaohua Li, boyu.mt, wenqing.lz, qijiang.qj

From: Joseph Qi <qijiang.qj@alibaba-inc.com>

Currently it will try to dispatch bio in throtl_upgrade_state. This may
lead to io stall in the following case.
Say the hierarchy is like:
/-test1
  |-subtest1
and subtest1 has 32 queued bios now.

throtl_pending_timer_fn            throtl_upgrade_state
------------------------------------------------------------------------
                                   upgrade to max
                                   throtl_select_dispatch
                                   throtl_schedule_next_dispatch
throtl_select_dispatch
throtl_schedule_next_dispatch

Since throtl_select_dispatch will move queued bios from subtest1 to
test1 in throtl_upgrade_state, it will then just do nothing in
throtl_pending_timer_fn. As a result, queued bios won't be dispatched
any more if no proper timer scheduled.
Fix this issue by just scheduling dispatch now and let the dispatch be
done only in timer.

Signed-off-by: Joseph Qi <qijiang.qj@alibaba-inc.com>
---
 block/blk-throttle.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index 0fea76a..29d282f 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -1909,13 +1909,11 @@ static void throtl_upgrade_state(struct throtl_data *td)
 		struct throtl_grp *tg = blkg_to_tg(blkg);
 		struct throtl_service_queue *sq = &tg->service_queue;
 
-		tg->disptime = jiffies - 1;
-		throtl_select_dispatch(sq);
-		throtl_schedule_next_dispatch(sq, false);
+		tg->disptime = jiffies;
+		throtl_schedule_next_dispatch(sq, true);
 	}
 	rcu_read_unlock();
-	throtl_select_dispatch(&td->service_queue);
-	throtl_schedule_next_dispatch(&td->service_queue, false);
+	throtl_schedule_next_dispatch(&td->service_queue, true);
 	queue_work(kthrotld_workqueue, &td->dispatch_work);
 }
 
-- 
1.9.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-09-28 21:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-25 10:46 [PATCH] blk-throttle: fix possible io stall when doing upgrade Joseph Qi
2017-09-25 17:22 ` Shaohua Li
2017-09-26  1:06   ` Joseph Qi
2017-09-26  2:48     ` Shaohua Li
2017-09-26  3:16       ` Joseph Qi
2017-09-27 21:38         ` Shaohua Li
2017-09-28  3:48           ` Joseph Qi
2017-09-28 11:19             ` Joseph Qi
2017-09-28 21:18               ` Shaohua Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox