提交 12fc760f 编写于 作者: C Changman Lee 提交者: Jaegeuk Kim

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: NChangman Lee <cm224.lee@samsung.com>
Reviewed-by: NNamjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
上级 47b3bc90
......@@ -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);
}
/*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册