diff options
author | Changman Lee <cm224.lee@samsung.com> | 2013-02-25 09:38:02 +0100 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2013-03-08 02:02:56 +0100 |
commit | 12fc760fd632a96f49e96f519c4aed4eb279bb61 (patch) | |
tree | 09d54e3295705601aa0d600fd9a8e94aca444174 /fs/f2fs | |
parent | Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/ker... (diff) | |
download | linux-12fc760fd632a96f49e96f519c4aed4eb279bb61.tar.xz linux-12fc760fd632a96f49e96f519c4aed4eb279bb61.zip |
f2fs: fix overflow when calculating utilization on 32-bit
Use div_u64 to fix overflow when calculating utilization.
*long int* is 4-bytes on 32-bit so (user blocks * 100) might be
overflow if disk size is over e.g. 512GB.
Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Reviewed-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs/f2fs')
-rw-r--r-- | fs/f2fs/segment.h | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index 552dadbb2327..e399bd4d3af8 100644 --- a/fs/f2fs/segment.h +++ b/fs/f2fs/segment.h @@ -464,8 +464,7 @@ static inline bool has_not_enough_free_secs(struct f2fs_sb_info *sbi, int freed) static inline int utilization(struct f2fs_sb_info *sbi) { - return (long int)valid_user_blocks(sbi) * 100 / - (long int)sbi->user_block_count; + return div_u64(valid_user_blocks(sbi) * 100, sbi->user_block_count); } /* |