Skip to content

Commit

Permalink
ext4: fixup 64-bit divides in 3.0-stable backport of upstream fix
Browse files Browse the repository at this point in the history
Orabug: 17488415

Replace C division operators with div64_u64 for divides introduced in:
commit 503f4bdcc078e7abee273a85ce322de81b18a224
ext4: use atomic64_t for the per-flexbg free_clusters count

Specific to the 3.0-stable backport of the upstream patch.

Signed-off-by: Todd Poynor <[email protected]>
Reviewed-by: "Theodore Ts'o" <[email protected]>
Cc: Christoph Biedl <[email protected]>
Cc: Lukas Czerner <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

(cherry picked from commit a58e3e13f5f8c03a88195c45771b2ef3a7a53f75)

Signed-off-by: Todd Vierling <[email protected]>
Acked-by: John Haxby <[email protected]>
Signed-off-by: Brian Maly <[email protected]>
  • Loading branch information
toddpoynor authored and Brian Maly committed Feb 24, 2018
1 parent fa86ac6 commit 176750b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fs/ext4/ialloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <linux/random.h>
#include <linux/bitops.h>
#include <linux/blkdev.h>
#include <linux/math64.h>
#include <asm/byteorder.h>

#include "ext4.h"
Expand Down Expand Up @@ -356,7 +357,7 @@ static int find_group_flex(struct super_block *sb, struct inode *parent,

find_close_to_parent:
flexbg_free_blocks = atomic64_read(&flex_group[best_flex].free_blocks);
flex_freeb_ratio = flexbg_free_blocks * 100 / blocks_per_flex;
flex_freeb_ratio = div64_u64(flexbg_free_blocks * 100, blocks_per_flex);
if (atomic_read(&flex_group[best_flex].free_inodes) &&
flex_freeb_ratio > free_block_ratio)
goto found_flexbg;
Expand All @@ -371,7 +372,7 @@ static int find_group_flex(struct super_block *sb, struct inode *parent,
continue;

flexbg_free_blocks = atomic64_read(&flex_group[i].free_blocks);
flex_freeb_ratio = flexbg_free_blocks * 100 / blocks_per_flex;
flex_freeb_ratio = div64_u64(flexbg_free_blocks * 100, blocks_per_flex);

if (flex_freeb_ratio > free_block_ratio &&
(atomic_read(&flex_group[i].free_inodes))) {
Expand Down

0 comments on commit 176750b

Please sign in to comment.