Commit 12fc760fd632a96f49e96f519c4aed4eb279bb61
Committed by
Jaegeuk Kim
1 parent
47b3bc9073
Exists in
master
and in
20 other branches
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>
Showing 1 changed file with 1 additions and 2 deletions Side-by-side Diff
fs/f2fs/segment.h
... | ... | @@ -464,8 +464,7 @@ |
464 | 464 | |
465 | 465 | static inline int utilization(struct f2fs_sb_info *sbi) |
466 | 466 | { |
467 | - return (long int)valid_user_blocks(sbi) * 100 / | |
468 | - (long int)sbi->user_block_count; | |
467 | + return div_u64(valid_user_blocks(sbi) * 100, sbi->user_block_count); | |
469 | 468 | } |
470 | 469 | |
471 | 470 | /* |