summaryrefslogtreecommitdiffstats
path: root/drivers/md/bcache/util.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-01-27 14:44:53 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-01-27 14:44:53 +0100
commitcc11f372e9371ec3a3dad02396dbe0a55eec0b8f (patch)
treefd22bdac975ee61053e787ad96c912fddc485370 /drivers/md/bcache/util.c
parentStaging: rtl8812ae: disable due to build errors (diff)
parentMerge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml (diff)
downloadlinux-cc11f372e9371ec3a3dad02396dbe0a55eec0b8f.tar.xz
linux-cc11f372e9371ec3a3dad02396dbe0a55eec0b8f.zip
Merge branch 'master' into staging-next
We need the network changes in staging-next in order to be able to fix up the rtl8821ae driver to build properly. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
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)