f2fs: fix incorrect bimodal calculation
authorChao Yu <chao2.yu@samsung.com>
Wed, 23 Sep 2015 01:25:43 +0000 (09:25 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Fri, 9 Oct 2015 23:20:53 +0000 (16:20 -0700)
In update_sit_info, we use div_u64 to handle 'u64 divide u64' case, but
div_u64 can only handle 32-bits divisor, so our divisor with u64 type
passed to div_u64 will overflow, result in the wrong calculation when
show debug info of f2fs as below:

BDF: 464, avg. vblocks: 23509
(BDF should never exceed 100)

So change to use div64_u64 to handle this case correctly.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/debug.c

index ebfcc4039057a9f6b021f05e1d2c113283e22515..615a307a787111c18a0256d995bf60ee7b7ddc20 100644 (file)
@@ -118,7 +118,7 @@ static void update_sit_info(struct f2fs_sb_info *sbi)
                }
        }
        dist = div_u64(MAIN_SECS(sbi) * hblks_per_sec * hblks_per_sec, 100);
-       si->bimodal = div_u64(bimodal, dist);
+       si->bimodal = div64_u64(bimodal, dist);
        if (si->dirty_count)
                si->avg_vblocks = div_u64(total_vblocks, ndirty);
        else
This page took 0.025261 seconds and 5 git commands to generate.