]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journald,ratelimit: fix wrong calculation of burst_modulate() (#4218)
authorHATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
Mon, 26 Sep 2016 15:36:20 +0000 (00:36 +0900)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 26 Sep 2016 15:36:20 +0000 (11:36 -0400)
This patch fixes wrong calculation of burst_modulate(), which now calculates
the values smaller than really expected ones if available disk space is
strictly more than 1MB.

In particular, if available disk space is strictly more than 1MB and strictly
less than 16MB, the resulted value becomes smaller than its original one.

>>> (math.log2(1*1024**2)-16) / 4
1.0
>>> (math.log2(16*1024**2)-16) / 4
2.0
>>> (math.log2(256*1024**2)-16) / 4
3.0
→ This matches the comment in the function.

src/journal/journald-rate-limit.c

index fce799a6ce0f3b1e9d5f060d48ce6ad65fffb461..d30bf92cec64036c148a86f0ee01d1d195a876b2 100644 (file)
@@ -190,7 +190,7 @@ static unsigned burst_modulate(unsigned burst, uint64_t available) {
         if (k <= 20)
                 return burst;
 
-        burst = (burst * (k-20)) / 4;
+        burst = (burst * (k-16)) / 4;
 
         /*
          * Example: