diff options
author | Carlos Maiolino <cem@kernel.org> | 2025-04-22 12:27:29 +0200 |
---|---|---|
committer | Carlos Maiolino <cem@kernel.org> | 2025-04-22 14:41:13 +0200 |
commit | 171cea5ee523cc04425271429422edf6d28c5b9b (patch) | |
tree | e8c89c0a179f23a262baae8f95dcd70c63f8be51 | |
parent | a33b5a08cbbdd7aadff95f40cbb45ab86841679e (diff) | |
download | xfs-linux-math_fix.tar.gz |
XFS: fix zoned gc threshold math for 32-bit archesmath_fix
xfs_zoned_need_gc makes use of mult_frac() to calculate the threshold
for triggering the zoned garbage collector, but, turns out mult_frac()
doesn't properly work with 64-bit data types and this caused build
failures on some 32-bit architectures.
Fix this by essentially open coding mult_frac() in a 64-bit friendly
way.
Notice we don't need to bother with counters underflow here because
xfs_estimate_freecounter() will always return a positive value, as it
leverages percpu_counter_read_positive to read such counters.
Fixes: 845abeb1f06a ("xfs: add tunable threshold parameter for triggering zone GC")
-rw-r--r-- | fs/xfs/xfs_zone_gc.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/fs/xfs/xfs_zone_gc.c b/fs/xfs/xfs_zone_gc.c index 8c541ca718722d..81c94dd1d5966b 100644 --- a/fs/xfs/xfs_zone_gc.c +++ b/fs/xfs/xfs_zone_gc.c @@ -170,7 +170,8 @@ bool xfs_zoned_need_gc( struct xfs_mount *mp) { - s64 available, free; + s64 available, free, threshold; + s32 remainder; if (!xfs_group_marked(mp, XG_TYPE_RTG, XFS_RTG_RECLAIMABLE)) return false; @@ -183,7 +184,12 @@ xfs_zoned_need_gc( return true; free = xfs_estimate_freecounter(mp, XC_FREE_RTEXTENTS); - if (available < mult_frac(free, mp->m_zonegc_low_space, 100)) + + threshold = div_s64_rem(free, 100, &remainder); + threshold = threshold * mp->m_zonegc_low_space + + remainder * div_s64(mp->m_zonegc_low_space, 100); + + if (available < threshold) return true; return false; |