diff options
author | Andreas Gruenbacher <agruenba@redhat.com> | 2019-05-17 14:18:43 -0400 |
---|---|---|
committer | Andreas Gruenbacher <agruenba@redhat.com> | 2019-05-22 08:09:44 -0400 |
commit | 5a5ec83d6ac974b12085cd99b196795f14079037 (patch) | |
tree | ba7ac34e9dbe8e0795b3704e36d5bdb88dc01faa /fs/gfs2 | |
parent | a188339ca5a396acc588e5851ed7e19f66b0ebd9 (diff) |
gfs2: Fix sign extension bug in gfs2_update_stats
Commit 4d207133e9c3 changed the types of the statistic values in struct
gfs2_lkstats from s64 to u64. Because of that, what should be a signed
value in gfs2_update_stats turned into an unsigned value. When shifted
right, we end up with a large positive value instead of a small negative
value, which results in an incorrect variance estimate.
Fixes: 4d207133e9c3 ("gfs2: Make statistics unsigned, suitable for use with do_div()")
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Cc: stable@vger.kernel.org # v4.4+
Diffstat (limited to 'fs/gfs2')
-rw-r--r-- | fs/gfs2/lock_dlm.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/fs/gfs2/lock_dlm.c b/fs/gfs2/lock_dlm.c index 31df26ed7854..69bd1597bacf 100644 --- a/fs/gfs2/lock_dlm.c +++ b/fs/gfs2/lock_dlm.c | |||
@@ -31,9 +31,10 @@ | |||
31 | * @delta is the difference between the current rtt sample and the | 31 | * @delta is the difference between the current rtt sample and the |
32 | * running average srtt. We add 1/8 of that to the srtt in order to | 32 | * running average srtt. We add 1/8 of that to the srtt in order to |
33 | * update the current srtt estimate. The variance estimate is a bit | 33 | * update the current srtt estimate. The variance estimate is a bit |
34 | * more complicated. We subtract the abs value of the @delta from | 34 | * more complicated. We subtract the current variance estimate from |
35 | * the current variance estimate and add 1/4 of that to the running | 35 | * the abs value of the @delta and add 1/4 of that to the running |
36 | * total. | 36 | * total. That's equivalent to 3/4 of the current variance |
37 | * estimate plus 1/4 of the abs of @delta. | ||
37 | * | 38 | * |
38 | * Note that the index points at the array entry containing the smoothed | 39 | * Note that the index points at the array entry containing the smoothed |
39 | * mean value, and the variance is always in the following entry | 40 | * mean value, and the variance is always in the following entry |
@@ -49,7 +50,7 @@ static inline void gfs2_update_stats(struct gfs2_lkstats *s, unsigned index, | |||
49 | s64 delta = sample - s->stats[index]; | 50 | s64 delta = sample - s->stats[index]; |
50 | s->stats[index] += (delta >> 3); | 51 | s->stats[index] += (delta >> 3); |
51 | index++; | 52 | index++; |
52 | s->stats[index] += ((abs(delta) - s->stats[index]) >> 2); | 53 | s->stats[index] += (s64)(abs(delta) - s->stats[index]) >> 2; |
53 | } | 54 | } |
54 | 55 | ||
55 | /** | 56 | /** |