Skip to content

Commit 1beabab

Browse files
YuKuai-huaweiaxboe
authored andcommitted
blk-throttle: fix lower control under super low iops limit
User will configure allowed iops limit in 1s, and calculate_io_allowed() will calculate allowed iops in the slice by: limit * HZ / throtl_slice However, if limit is quite low, the result can be 0, then allowed IO in the slice is 0, this will cause missing dispatch and control will be lower than limit. For example, set iops_limit to 5 with HD disk, and test will found that iops will be 3. This is usually not a big deal, because user will unlikely to configure such low iops limit, however, this is still a problem in the extreme scene. Fix the problem by making sure the wait time calculated by tg_within_iops_limit() should allow at least one IO to be dispatched. Signed-off-by: Yu Kuai <[email protected]> Acked-by: Tejun Heo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 3991657 commit 1beabab

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

block/blk-throttle.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,9 @@ static unsigned long tg_within_iops_limit(struct throtl_grp *tg, struct bio *bio
704704

705705
/* Calc approx time to dispatch */
706706
jiffy_wait = jiffy_elapsed_rnd - jiffy_elapsed;
707+
708+
/* make sure at least one io can be dispatched after waiting */
709+
jiffy_wait = max(jiffy_wait, HZ / iops_limit + 1);
707710
return jiffy_wait;
708711
}
709712

0 commit comments

Comments
 (0)