]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
f2fs: avoid an overflow during utilization calculation
authorJaegeuk Kim <jaegeuk.kim@samsung.com>
Tue, 3 Sep 2013 04:41:37 +0000 (13:41 +0900)
committerJaegeuk Kim <jaegeuk.kim@samsung.com>
Tue, 3 Sep 2013 04:41:37 +0000 (13:41 +0900)
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>
fs/f2fs/segment.h

index cd9bd93212add8ea29ac3e1ae4e0c6d1c2f6a645..e0d6d3abf396c4a461d8e23cec7f9cad10ed8771 100644 (file)
@@ -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);
 }
 
 /*