diff options
| -rw-r--r-- | block/blk-throttle.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/block/blk-throttle.c b/block/blk-throttle.c index c1bc1b6c887a..56ad4531b412 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c | |||
| @@ -430,6 +430,7 @@ static bool tg_with_in_iops_limit(struct throtl_data *td, struct throtl_grp *tg, | |||
| 430 | bool rw = bio_data_dir(bio); | 430 | bool rw = bio_data_dir(bio); |
| 431 | unsigned int io_allowed; | 431 | unsigned int io_allowed; |
| 432 | unsigned long jiffy_elapsed, jiffy_wait, jiffy_elapsed_rnd; | 432 | unsigned long jiffy_elapsed, jiffy_wait, jiffy_elapsed_rnd; |
| 433 | u64 tmp; | ||
| 433 | 434 | ||
| 434 | jiffy_elapsed = jiffy_elapsed_rnd = jiffies - tg->slice_start[rw]; | 435 | jiffy_elapsed = jiffy_elapsed_rnd = jiffies - tg->slice_start[rw]; |
| 435 | 436 | ||
| @@ -439,7 +440,20 @@ static bool tg_with_in_iops_limit(struct throtl_data *td, struct throtl_grp *tg, | |||
| 439 | 440 | ||
| 440 | jiffy_elapsed_rnd = roundup(jiffy_elapsed_rnd, throtl_slice); | 441 | jiffy_elapsed_rnd = roundup(jiffy_elapsed_rnd, throtl_slice); |
| 441 | 442 | ||
| 442 | io_allowed = (tg->iops[rw] * jiffy_elapsed_rnd) / HZ; | 443 | /* |
| 444 | * jiffy_elapsed_rnd should not be a big value as minimum iops can be | ||
| 445 | * 1 then at max jiffy elapsed should be equivalent of 1 second as we | ||
| 446 | * will allow dispatch after 1 second and after that slice should | ||
| 447 | * have been trimmed. | ||
| 448 | */ | ||
| 449 | |||
| 450 | tmp = (u64)tg->iops[rw] * jiffy_elapsed_rnd; | ||
| 451 | do_div(tmp, HZ); | ||
| 452 | |||
| 453 | if (tmp > UINT_MAX) | ||
| 454 | io_allowed = UINT_MAX; | ||
| 455 | else | ||
| 456 | io_allowed = tmp; | ||
| 443 | 457 | ||
| 444 | if (tg->io_disp[rw] + 1 <= io_allowed) { | 458 | if (tg->io_disp[rw] + 1 <= io_allowed) { |
| 445 | if (wait) | 459 | if (wait) |
