Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

XFS: fix zoned gc threshold math for 32-bit arches

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")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202504181233.F7D9Atra-lkp@intel.com/
Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hans Holmberg <hans.holmberg@wdc.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>

+8 -2
+8 -2
fs/xfs/xfs_zone_gc.c
··· 170 170 xfs_zoned_need_gc( 171 171 struct xfs_mount *mp) 172 172 { 173 - s64 available, free; 173 + s64 available, free, threshold; 174 + s32 remainder; 174 175 175 176 if (!xfs_group_marked(mp, XG_TYPE_RTG, XFS_RTG_RECLAIMABLE)) 176 177 return false; ··· 184 183 return true; 185 184 186 185 free = xfs_estimate_freecounter(mp, XC_FREE_RTEXTENTS); 187 - if (available < mult_frac(free, mp->m_zonegc_low_space, 100)) 186 + 187 + threshold = div_s64_rem(free, 100, &remainder); 188 + threshold = threshold * mp->m_zonegc_low_space + 189 + remainder * div_s64(mp->m_zonegc_low_space, 100); 190 + 191 + if (available < threshold) 188 192 return true; 189 193 190 194 return false;