*/
if (total && td->rate_bps[ddir] && td->o.rate_ign_think) {
uint64_t missed = (td->rate_bps[ddir] * total) / 1000000ULL;
+ uint64_t bs = td->o.min_bs[ddir];
+ uint64_t usperop = bs * 1000000ULL / td->rate_bps[ddir];
uint64_t over;
- if (total >= 1000000)
- over = td->o.min_bs[ddir];
+ if (usperop <= total)
+ over = bs;
else
- over = (td->o.min_bs[ddir] * total) / 1000000ULL;
+ over = (usperop - total) / usperop * -bs;
td->rate_io_issue_bytes[ddir] += (missed - over);
}