Skip to content

Commit

Permalink
f2fs: avoid an overflow during utilization calculation
Browse files Browse the repository at this point in the history
The current f2fs uses all the block counts with 32 bit numbers, which is able to
cover about 15TB volume.

But in calculation of utilization, f2fs multiplies the count by 100 which can
induce overflow.
This patch fixes this.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
  • Loading branch information
Jaegeuk Kim committed Sep 3, 2013
1 parent c34e333 commit 222cbdc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/f2fs/segment.h
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,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 div_u64(valid_user_blocks(sbi) * 100, sbi->user_block_count);
return div_u64((u64)valid_user_blocks(sbi) * 100, sbi->user_block_count);
}

/*
Expand Down

0 comments on commit 222cbdc

Please sign in to comment.