summaryrefslogtreecommitdiff
path: root/drivers/md/bcache/util.c
diff options
context:
space:
mode:
authorKent Overstreet <kmo@daterainc.com>2013-11-12 01:58:34 +0400
committerKent Overstreet <kmo@daterainc.com>2013-12-17 02:22:59 +0400
commit16749c23c00c686ed168471963e3ddb0f3fcd855 (patch)
treec64fc28761ab499bbcdcf1f626576d1781c87ba9 /drivers/md/bcache/util.c
parent6d3d1a9c542b19dff1c7d7c8354d0869e4655287 (diff)
downloadlinux-16749c23c00c686ed168471963e3ddb0f3fcd855.tar.xz
bcache: New writeback PD controller
The old writeback PD controller could get into states where it had throttled all the way down and take way too long to recover - it was too complicated to really understand what it was doing. This rewrites a good chunk of it to hopefully be simpler and make more sense, and it also pays more attention to units which should make the behaviour a bit easier to understand. Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Diffstat (limited to 'drivers/md/bcache/util.c')
-rw-r--r--drivers/md/bcache/util.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/md/bcache/util.c b/drivers/md/bcache/util.c
index 462214eeacbe..bb37618e7664 100644
--- a/drivers/md/bcache/util.c
+++ b/drivers/md/bcache/util.c
@@ -209,7 +209,13 @@ uint64_t bch_next_delay(struct bch_ratelimit *d, uint64_t done)
{
uint64_t now = local_clock();
- d->next += div_u64(done, d->rate);
+ d->next += div_u64(done * NSEC_PER_SEC, d->rate);
+
+ if (time_before64(now + NSEC_PER_SEC, d->next))
+ d->next = now + NSEC_PER_SEC;
+
+ if (time_after64(now - NSEC_PER_SEC * 2, d->next))
+ d->next = now - NSEC_PER_SEC * 2;
return time_after64(d->next, now)
? div_u64(d->next - now, NSEC_PER_SEC / HZ)